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

@ -121,13 +121,13 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
}
// patent 专利信息
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
func patent(expectID uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询用户的专利信息
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
var count int64
out, err := mTechnologyPatentExpert.Patents(uids, page, pageSize, &count)
out, err := mTechnologyPatentExpert.Patents(page, pageSize, &count, model2.NewWhere("u.expert_id", expectID))
if err != nil {
return nil, err

View File

@ -8,6 +8,7 @@ import (
"SciencesServer/app/session"
config2 "SciencesServer/config"
"SciencesServer/utils"
"errors"
"fmt"
"strings"
)
@ -57,6 +58,8 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
if err != nil {
return nil, err
} else if out.ManageExpert == nil {
return nil, errors.New("操作错误,专家信息不存在或已被删除")
}
mTechnologyPatent := model.NewTechnologyPatent()
@ -119,13 +122,13 @@ func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages
// Patent 专利信息
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.user(id)
//uids, err := c.user(id)
//
//if err != nil {
// return nil, err
//}
if err != nil {
return nil, err
}
return patent(uids, page, pageSize)
return patent(id, page, pageSize)
}
// Paper 论文信息

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 {