feat:完善项目信息

This commit is contained in:
henry
2022-01-04 15:37:00 +08:00
parent 40841a4a27
commit d2b182952c
8 changed files with 343 additions and 26 deletions

View File

@ -11,15 +11,52 @@ type ManageLaboratory struct {
*model.ManageLaboratory
}
type ManageLaboratoryInfo struct {
model.Model
Name string `json:"name"`
Industry string `json:"-"`
Username string `json:"username"`
Mobile string `json:"mobile"`
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
SettledAt time.Time `json:"settled_at"`
type (
ManageLaboratoryInfo struct {
model.Model
Name string `json:"name"`
Industry string `json:"-"`
Username string `json:"username"`
Mobile string `json:"mobile"`
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
SettledAt time.Time `json:"settled_at"`
}
// ManageLaboratoryInstance 实验室信息
ManageLaboratoryInstance struct {
*model.ManageLaboratory
ResearchName string `json:"research_name"`
ExpertCount int `json:"expert_count"`
CollectCount int `json:"collect_count"`
VisitCount int `json:"visit_count"`
}
)
// Instance 实验室信息
func (m *ManageLaboratory) Instance(where ...*model.ModelWhere) ([]*ManageLaboratoryInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS l").
Select("l.id", "l.image", "l.url", "l.industry", "l.keyword", "l.contact", "l.contact_mobile", "l.research",
"e.name AS research_name", "e.count AS expert_count", "c.count AS collect_count", "v.count AS visit_count").
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON l.research_id = e.id", model.NewManageResearch().TableName())).
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(laboratory_id) AS count FROM %s WHERE examine_status = %d AND is_deleted = %d GROUP BY laboratory_id) AS e ON l.id = e.laboratory_id",
model.NewManageExpert().TableName(), model.ExamineStatusForAgree, 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)).
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.UserVisitKindForLaboratory, model.DeleteStatusForNot)).
Where("l.examine_status = ?", model.ExamineStatusForAgree).
Where("l.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
}
out := make([]*ManageLaboratoryInstance, 0)
err := db.Scan(&out).Error
return out, err
}
// Laboratory 实验室信息

View File

@ -11,6 +11,36 @@ type SysPatent struct {
*model.SysPatent
}
type SysPatentInfo struct {
model.Model
Kind model.SysParentKind `json:"kind"`
Title string `json:"title"`
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
// Instance 专利信息
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS p").
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
Where("p.shelf_status = ?", model.ShelfStatusForUp).
Where("p.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*SysPatentInfo, 0)
if err := db.Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
var count int64
db := orm.GetDB().Table(m.TableName())

View File

@ -30,6 +30,41 @@ type TechnologyAchievementInstance struct {
CollectCount int `json:"collect_count"`
}
// TechnologyAchievementsInfo 技术成果信息
type TechnologyAchievementsInfo struct {
*model.TechnologyAchievement
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
}
// Achievements 成果信息
func (m *TechnologyAchievement) Achievements(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementsInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS a").
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
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)).
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.status = ?", model.TechnologyAchievementStatusForAgree).
Where("a.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*TechnologyAchievementsInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// Instance 成果信息
func (m *TechnologyAchievement) Instance(where ...*model.ModelWhere) ([]*TechnologyAchievementInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS a").

View File

@ -10,6 +10,40 @@ type UserPatent struct {
*model.UserPatent
}
type (
// PatentInstance 专利信息
PatentInstance struct {
model.Model
Title string `json:"title"`
ApplyAt string `json:"apply_at"`
}
)
// Patent 专利信息
func (m *UserPatent) Instance(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*PatentInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS u_p").
Select("p.id", "p.title", "p.apply_at", "p.description").
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_p.patent_id = p.id",
model.NewSysPatent().TableName())).
Where("u_p.is_deleted = ?", model.DeleteStatusForNot).
Where("p.shelf_status = ?", model.ShelfStatusForUp)
if len(where) > 0 {
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
}
out := make([]*PatentInstance, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// Patents 专利信息
func (m *UserPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*model.SysPatent, error) {
db := orm.GetDB().Table(m.TableName()+" AS u").