feat:完善项目信息

This commit is contained in:
henry
2021-12-27 11:48:44 +08:00
parent 4926c5b765
commit 45b2e85cfd
23 changed files with 92 additions and 240 deletions

View File

@ -64,8 +64,8 @@ func (m *ManageExpert) CompanyVisit(page, pageSize int, count *int64, where ...*
db := orm.GetDB().Table(m.TableName()+" e").
Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "v.date AS visit_at",
"c.name AS company_name").
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 %s AS v ON e.id = v.object_id AND v.kind = %d AND v.is_deleted = %d",
model.NewUserVisit().TableName(), model.UserVisitKindForCompany, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS u_c ON v.uid = u_c.uid AND u_c.invalid_status = %d",
model.NewUserCompany().TableName(), model.InvalidStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).

View File

@ -28,10 +28,10 @@ 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, 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))
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON l.id = v.object_id",
model.NewUserVisit().TableName(), model.UserCollectKindForLaboratory, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON l.id = c.object_id",
model.NewUserCollect().TableName(), model.UserCollectKindForLaboratory, model.DeleteStatusForNot))
if len(where) > 0 {
for _, v := range where {

View File

@ -24,8 +24,8 @@ type TechnologyAchievementInfo struct {
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS a").
Select("a.id", "a.title", "a.industry", "v.count AS visit_count", "a.shelf_status", "a.created_at").
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d) AS v ON a.id = v.achievement_id",
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
Where("a.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {

View File

@ -30,10 +30,10 @@ 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, 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))
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
model.NewUserVisit().TableName(), model.UserVisitKindForTechnologyProduct, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON p.id = c.object_id",
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot))
out := make([]*TechnologyProductInfo, 0)

View File

@ -1,11 +0,0 @@
package model
import "SciencesServer/app/common/model"
type TechnologyProductCollect struct {
*model.TechnologyProductCollect
}
func NewTechnologyProductCollect() *TechnologyProductCollect {
return &TechnologyProductCollect{model.NewTechnologyProductCollect()}
}

View File

@ -0,0 +1,11 @@
package model
import "SciencesServer/app/common/model"
type UserCollect struct {
*model.UserCollect
}
func NewUserCollect() *UserCollect {
return &UserCollect{model.NewUserCollect()}
}

View File

@ -7,17 +7,19 @@ import (
"time"
)
type TechnologyProductVisit struct {
*model.TechnologyProductVisit
type UserVisit struct {
*model.UserVisit
}
type TechnologyProductVisitInfo struct {
model.Model
VisitAt time.Time `json:"visit_at"`
model.ManageCompanyBasic
}
type (
ProductVisitInfo struct {
model.Model
VisitAt time.Time `json:"visit_at"`
model.ManageCompanyBasic
}
)
func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductVisitInfo, error) {
func (m *UserVisit) Product(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ProductVisitInfo, error) {
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").
@ -25,9 +27,10 @@ func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where .
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("v.kind = ?", model.UserVisitKindForTechnologyProduct).
Where("u_c.id > ?", 0)
out := make([]*TechnologyProductVisitInfo, 0)
out := make([]*ProductVisitInfo, 0)
if len(where) > 0 {
for _, v := range where {
@ -43,6 +46,6 @@ func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where .
return out, nil
}
func NewTechnologyProductVisit() *TechnologyProductVisit {
return &TechnologyProductVisit{model.NewTechnologyProductVisit()}
func NewUserVisit() *UserVisit {
return &UserVisit{model.NewUserVisit()}
}