feat:优化项目信息

This commit is contained in:
henry
2022-02-09 22:26:09 +08:00
parent 957a4436a8
commit 1b5026edce
7 changed files with 36 additions and 48 deletions

View File

@ -4,7 +4,6 @@ import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"strings"
)
type TechnologyPatentExpert struct {
@ -14,21 +13,16 @@ type TechnologyPatentExpert struct {
type TechnologyPatentExpertInfo struct {
model.Model
Title string `json:"title"`
ApplyCode string `json:"apply_code"`
ApplyAt string `json:"apply_at"`
Description string `json:"description"`
}
// Patents 专利信息
func (m *TechnologyPatentExpert) Patents(uid []uint64, page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
_uids := make([]string, 0)
for _, u := range uid {
_uids = append(_uids, fmt.Sprintf("%d", u))
}
db := orm.GetDB().Table(model.NewTechnologyPatent().TableName()+" AS p").
Select("p.id", "p.title", "p.apply_at", "p.description").
Joins(fmt.Sprintf("RIGHT JOIN (SELECT patent_id FROM %s WHERE uid IN (%v) is_deleted = %d patent_id) AS u ON p.id = u.patent_id",
model.NewTechnologyPatent().TableName(), strings.Join(_uids, ","), model.DeleteStatusForNot)).
func (m *TechnologyPatentExpert) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS u").
Select("p.id", "p.title", "p.apply_code", "p.apply_at", "p.description").
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewTechnologyPatent().TableName())).
Where("u.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {