feat:完善项目管理
This commit is contained in:
@ -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 {
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
18
app/common/model/manage_expert_collect.go
Normal file
18
app/common/model/manage_expert_collect.go
Normal file
@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
// ManageExpertCollect 专家收藏数据模型
|
||||
type ManageExpertCollect struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ExpertID uint64 `gorm:"column:expert_id;type:int(11);default:0;comment:专家ID" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageExpertCollect) TableName() string {
|
||||
return "manage_expert_collect"
|
||||
}
|
||||
|
||||
func NewManageExpertCollect() *ManageExpertCollect {
|
||||
return &ManageExpertCollect{}
|
||||
}
|
@ -5,6 +5,7 @@ import "time"
|
||||
// ManageExpertVisit 专家浏览记录数据模型
|
||||
type ManageExpertVisit struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ExpertID uint64 `gorm:"column:expert_id;index:idx_expert_visit_expert;type:int(11);default:0;comment:专家ID" json:"-"`
|
||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
||||
|
@ -5,6 +5,7 @@ import "time"
|
||||
// ManageLaboratoryVisit 实验室浏览记录数据模型
|
||||
type ManageLaboratoryVisit struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
LaboratoryID uint64 `gorm:"column:laboratory_id;index:idx_laboratory_visit_laboratory;type:int(11);default:0;comment:实验室ID" json:"-"`
|
||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
||||
|
@ -5,8 +5,8 @@ import "time"
|
||||
// TechnologyProductVisit 技术产品访问数据模型
|
||||
type TechnologyProductVisit struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
ProductID uint64 `gorm:"column:product_id;index:idx_product_visit_product;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
||||
CompanyID uint64 `gorm:"column:company_id;type:int(11);default:0;comment:公司ID" json:"company_id"`
|
||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
||||
ModelDeleted
|
||||
|
Reference in New Issue
Block a user