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 {

View File

@ -25,7 +25,7 @@ func (m *ManageLaboratory) Laboratory(page, pageSize int, count *int64, where ..
db := orm.GetDB().Table(m.TableName()+" AS l").
Select("l.id", "l.name", "l.industry", "u.name AS username", "u.mobile", "v.count AS visit_count", "c.count AS collect_count").
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON l.uid = u.uuid", model.NewUserInstance().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS v ON l.id = v.laboratory_id AND v.is_deleted = %d",
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS v ON l.id = v.laboratory_id",
model.NewManageLaboratoryVisit().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS c ON l.id = c.laboratory_id",
model.NewManageLaboratoryCollect().TableName(), model.DeleteStatusForNot))

View File

@ -30,9 +30,9 @@ func (m *TechnologyProduct) Product(page, pageSize int, count *int64, where ...*
db := orm.GetDB().Table(m.TableName()+" AS p").
Select("p.id", "p.title", "p.image", "p.maturity", "p.industry", "p.cooperation_mode", "p.keyword",
"v.count AS v visit_count", "c.count AS collect_count").
Joins(fmt.Sprintf("(SELECT company_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY company_id) AS v ON p.id = v.company_id",
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS v ON p.id = v.product_id",
model.NewTechnologyProductVisit().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("(SELECT company_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY company_id) AS c ON p.id = c.company_id",
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS c ON p.id = c.product_id",
model.NewTechnologyProductCollect().TableName(), model.DeleteStatusForNot))
out := make([]*TechnologyProductInfo, 0)

View File

@ -21,8 +21,11 @@ func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where .
db := orm.GetDB().Table(m.TableName()+" AS v").
Select("v.id", "v.visit_at", "c.id AS company_id", "c.name AS company_name", "c.image AS company_image",
"c.kind AS company_kind", "c.url AS company_url").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON v.company_id = c.id", model.NewManageCompany().TableName())).
Where("v.is_deleted = ?", model.DeleteStatusForNot)
Joins(fmt.Sprintf("LEFT JOIN %s AS u_c ON v.uid = c.uid AND u_c.invalid_status = %d AND u_c.is_deleted = %d",
model.NewUserCompany().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
Where("v.is_deleted = ?", model.DeleteStatusForNot).
Where("u_c.id > ?", 0)
out := make([]*TechnologyProductVisitInfo, 0)