feat:优化项目信息,待测试修改

This commit is contained in:
henry
2022-02-06 18:01:32 +08:00
parent c8578940bf
commit a25464289f
25 changed files with 404 additions and 483 deletions

View File

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

View File

@ -6,11 +6,11 @@ import (
"fmt"
)
type SysPatent struct {
*model.SysPatent
type TechnologyPatent struct {
*model.TechnologyPatent
}
type SysPatentInfo struct {
type TechnologyPatentInfo struct {
model.Model
Kind model.SysParentKind `json:"kind"`
Title string `json:"title"`
@ -18,12 +18,22 @@ type SysPatentInfo struct {
ApplyAt string `json:"apply_at"`
}
type (
// TechnologyPatentBasicInfo 专利信息
TechnologyPatentBasicInfo struct {
model.Model
Title string `json:"title"`
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
)
// Instance 专利信息
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
func (m *TechnologyPatent) Instance(where ...*model.ModelWhere) ([]*TechnologyPatentInfo, 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)).
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
Where("p.shelf_status = ?", model.ShelfStatusForUp).
Where("p.is_deleted = ?", model.DeleteStatusForNot)
@ -32,7 +42,7 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*SysPatentInfo, 0)
out := make([]*TechnologyPatentInfo, 0)
if err := db.Scan(&out).Error; err != nil {
return nil, err
@ -41,11 +51,11 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
}
// Patents 专利信息
func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
func (m *TechnologyPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentInfo, 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)).
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
Where("p.shelf_status = ?", model.ShelfStatusForUp).
Where("p.is_deleted = ?", model.DeleteStatusForNot)
@ -54,7 +64,7 @@ func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.Mo
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*SysPatentInfo, 0)
out := make([]*TechnologyPatentInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
@ -67,16 +77,14 @@ func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.Mo
}
// Distribution 分布信息
func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
func (m *TechnologyPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
out := make([]*DataAreaDistributionInfo, 0)
err := orm.GetDB().Table(m.TableName()+" AS p").
Select("e.province", "e.city", "e.district", "GROUP_CONCAT(p_c.industry_detail SEPARATOR '&') AS industry").
Joins(fmt.Sprintf("RIGHT JOIN %s AS p_c ON p.ipc_code = p_c.ipc AND p_c.is_deleted = %d",
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("RIGHT JOIN %s AS u_p ON p.id = u_p.patent_id AND u_p.is_deleted = %d",
model.NewUserPatent().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON u_p.uid = u_e.uid", model.NewUserExpert().TableName())).
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON p.uid = u_e.uid", model.NewUserExpert().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
Where("p.is_deleted = ?", model.DeleteStatusForNot).
Where("p.shelf_status = ?", model.ShelfStatusForUp).
@ -86,6 +94,6 @@ func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
return out, err
}
func NewSysPatent() *SysPatent {
return &SysPatent{model.NewSysPatent()}
func NewTechnologyPatent() *TechnologyPatent {
return &TechnologyPatent{model.NewTechnologyPatent()}
}

View File

@ -1,50 +0,0 @@
package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
)
type UserPatent struct {
*model.UserPatent
}
type (
// PatentInfo 专利信息
PatentInfo struct {
model.Model
Title string `json:"title"`
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
)
// Patent 专利信息
func (m *UserPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*PatentInfo, 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([]*PatentInfo, 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
}
func NewUserPatent() *UserPatent {
return &UserPatent{model.NewUserPatent()}
}