feat:完善项目信息
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
@ -20,6 +21,39 @@ type TechnologyAchievementInfo struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type TechnologyAchievementInstance struct {
|
||||
TechnologyAchievementInfo
|
||||
Customer string `json:"-"`
|
||||
LeadStandard model.TechnologyProductLeadStandard `json:"lead_standard"`
|
||||
CooperationMode config.TechnologyCooperationMode `json:"cooperation_mode"`
|
||||
Keyword string `json:"-"`
|
||||
CollectCount int `json:"collect_count"`
|
||||
}
|
||||
|
||||
// Instance 成果信息
|
||||
func (m *TechnologyAchievement) Instance(where ...*model.ModelWhere) ([]*TechnologyAchievementInstance, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.title", "a.industry", "v.count AS visit_count", "c.count AS collect_count",
|
||||
"a.customer", "a.lead_standard", "a.cooperation_mode", "a.keyword", "a.created_at").
|
||||
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.UserVisitKindForTechnologyAchievement, 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 a.id = c.object_id",
|
||||
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*TechnologyAchievementInstance, 0)
|
||||
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Achievement 成果信息
|
||||
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
|
Reference in New Issue
Block a user