feat:优化项目信息
This commit is contained in:
@ -244,8 +244,7 @@ func (*Manage) ExpertPatent(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Enterprise)).
|
||||
Patent(form.Convert(), form.Page, form.PageSize)
|
||||
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Enterprise)).Patent(form.Convert(), form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.TechnologyPatentBasicInfo
|
||||
*model.TechnologyPatentExpertInfo
|
||||
}
|
||||
// PatentInstance 专利信息
|
||||
PatentInstance struct {
|
||||
@ -112,26 +112,20 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
|
||||
}
|
||||
|
||||
// patent 专利信息
|
||||
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
func patent(expertID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
|
||||
var count int64
|
||||
out := make([]*model.TechnologyPatentBasicInfo, 0)
|
||||
|
||||
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{
|
||||
"id", "title", "apply_at", "description",
|
||||
}, page, pageSize, &count, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", uids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
}); err != nil {
|
||||
out, err := mTechnologyPatentExpert.Patent(page, pageSize, &count, model2.NewWhere("u.expert_id", expertID))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PatentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &PatentInfo{
|
||||
ID: v.GetEncodeID(), TechnologyPatentBasicInfo: v,
|
||||
ID: v.GetEncodeID(), TechnologyPatentExpertInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -254,13 +254,12 @@ 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)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return patent(uids, page, pageSize)
|
||||
//uids, err := c.user(id)
|
||||
//
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
return patent(id, page, pageSize)
|
||||
}
|
||||
|
||||
// Paper 论文信息
|
||||
|
@ -14,11 +14,10 @@ type TechnologyPatentExpert struct {
|
||||
// TechnologyPatentExpertInfo 用户专利信息
|
||||
type TechnologyPatentExpertInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
ApplyCode string `json:"apply_code"`
|
||||
ApplyName string `json:"apply_name"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
model.Shelf
|
||||
Title string `json:"title"`
|
||||
ApplyCode string `json:"apply_code"`
|
||||
ApplyName string `json:"apply_name"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
Status model.TechnologyPatentStatus `json:"status"`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@ -26,7 +25,7 @@ type TechnologyPatentExpertInfo struct {
|
||||
// Patent 专利信息
|
||||
func (m *TechnologyPatentExpert) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS u").
|
||||
Select("u.id", "p.title", "p.apply_code", "p.apply_name", "p.apply_at", "p.status", "p.created_at").
|
||||
Select("p.id", "p.title", "p.apply_code", "p.apply_name", "p.apply_at", "p.status", "p.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewTechnologyPatent().TableName())).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
@ -40,7 +39,7 @@ func (m *TechnologyPatentExpert) Patent(page, pageSize int, count *int64, where
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("u.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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 论文信息
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user