feat:完善项目管理,增加专家列表信息
This commit is contained in:
@ -1,11 +1,53 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ManageExpert struct {
|
||||
*model.ManageExpert
|
||||
}
|
||||
|
||||
// ManageExpertInfo 专家信息
|
||||
type ManageExpertInfo struct {
|
||||
model.Model
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
Industry string `json:"-"`
|
||||
VisitCount int `json:"visit_count"`
|
||||
SettledAt time.Time `json:"settled_at"`
|
||||
}
|
||||
|
||||
// Experts 专家信息
|
||||
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" e").
|
||||
Select("e.id", "e.name", "e.mobile", "e.industry", "v.visit_count", "e.examine_at AS settled_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS v ON e.id = v.expert_id AND v.is_deleted = %d",
|
||||
model.NewManageExpertVisit().TableName(), model.DeleteStatusForNot))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
if v.Condition == "" {
|
||||
db.Where(v.Value)
|
||||
continue
|
||||
}
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageExpertInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("e.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{model.NewManageExpert()}
|
||||
}
|
||||
|
Reference in New Issue
Block a user