feat:完善项目管理

This commit is contained in:
henry
2021-12-13 11:22:19 +08:00
parent b9cc39d37a
commit a512713ba6
8 changed files with 39 additions and 13 deletions

View File

@ -14,19 +14,22 @@ type ManageExpert struct {
// 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"`
Name string `json:"name"`
Mobile string `json:"mobile"`
Industry string `json:"-"`
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_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.count AS 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))
Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS v ON e.id = v.expert_id",
model.NewManageExpertVisit().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS c ON e.id = c.expert_id",
model.NewManageExpertCollect().TableName(), model.DeleteStatusForNot))
if len(where) > 0 {
for _, v := range where {