From f4c02860b4b58b79725d320f411c594776c3f131 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 22 Dec 2021 17:18:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BC=98=E5=8C=96=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=8A=80=E6=9C=AF=E6=88=90?= =?UTF-8?q?=E6=9E=9C=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/enterprise/model/manage_expert.go | 2 +- app/api/enterprise/model/manage_laboratory.go | 2 +- app/api/enterprise/model/technology_product.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/enterprise/model/manage_expert.go b/app/api/enterprise/model/manage_expert.go index 03a1b09..4517d76 100644 --- a/app/api/enterprise/model/manage_expert.go +++ b/app/api/enterprise/model/manage_expert.go @@ -33,7 +33,7 @@ func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model db := orm.GetDB().Table(m.TableName()+" e"). Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "c.count AS collect_count", "e.examine_at AS settled_at"). - 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", + Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, SUM(count) 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)). diff --git a/app/api/enterprise/model/manage_laboratory.go b/app/api/enterprise/model/manage_laboratory.go index fade74d..05245b7 100644 --- a/app/api/enterprise/model/manage_laboratory.go +++ b/app/api/enterprise/model/manage_laboratory.go @@ -28,7 +28,7 @@ func (m *ManageLaboratory) Laboratory(page, pageSize int, count *int64, where .. Select("l.id", "l.name", "l.industry", "u.name AS username", "u.mobile", "v.count AS visit_count", "c.count AS collect_count", "l.examine_at AS settled_at"). Joins(fmt.Sprintf("LEFT JOIN %s AS u ON l.uid = u.uuid", model.NewUserInstance().TableName())). - 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", + Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, SUM(count) 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)) diff --git a/app/api/enterprise/model/technology_product.go b/app/api/enterprise/model/technology_product.go index 4db547a..2eb4adc 100644 --- a/app/api/enterprise/model/technology_product.go +++ b/app/api/enterprise/model/technology_product.go @@ -30,7 +30,7 @@ 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("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", + Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, SUM(count) 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("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))