feat:优化项目信息
This commit is contained in:
@ -244,8 +244,7 @@ func (*Manage) ExpertPatent(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Enterprise)).
|
data, err := manage.NewExpert()(api.GetSession()(c).(*session.Enterprise)).Patent(form.Convert(), form.Page, form.PageSize)
|
||||||
Patent(form.Convert(), form.Page, form.PageSize)
|
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ type (
|
|||||||
// PatentInfo 专利信息
|
// PatentInfo 专利信息
|
||||||
PatentInfo struct {
|
PatentInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.TechnologyPatentBasicInfo
|
*model.TechnologyPatentExpertInfo
|
||||||
}
|
}
|
||||||
// PatentInstance 专利信息
|
// PatentInstance 专利信息
|
||||||
PatentInstance struct {
|
PatentInstance struct {
|
||||||
@ -112,26 +112,20 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// patent 专利信息
|
// patent 专利信息
|
||||||
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
func patent(expertID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
|
||||||
var count int64
|
var count int64
|
||||||
out := make([]*model.TechnologyPatentBasicInfo, 0)
|
|
||||||
|
|
||||||
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{
|
out, err := mTechnologyPatentExpert.Patent(page, pageSize, &count, model2.NewWhere("u.expert_id", expertID))
|
||||||
"id", "title", "apply_at", "description",
|
|
||||||
}, page, pageSize, &count, &model2.ModelWhereOrder{
|
if err != nil {
|
||||||
Where: model2.NewWhere("uid", uids),
|
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
|
||||||
}, &model2.ModelWhereOrder{
|
|
||||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list := make([]*PatentInfo, 0)
|
list := make([]*PatentInfo, 0)
|
||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &PatentInfo{
|
list = append(list, &PatentInfo{
|
||||||
ID: v.GetEncodeID(), TechnologyPatentBasicInfo: v,
|
ID: v.GetEncodeID(), TechnologyPatentExpertInfo: v,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
@ -254,13 +254,12 @@ func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages
|
|||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
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 {
|
//if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
//}
|
||||||
|
return patent(id, page, pageSize)
|
||||||
return patent(uids, page, pageSize)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper 论文信息
|
// Paper 论文信息
|
||||||
|
@ -18,7 +18,6 @@ type TechnologyPatentExpertInfo struct {
|
|||||||
ApplyCode string `json:"apply_code"`
|
ApplyCode string `json:"apply_code"`
|
||||||
ApplyName string `json:"apply_name"`
|
ApplyName string `json:"apply_name"`
|
||||||
ApplyAt string `json:"apply_at"`
|
ApplyAt string `json:"apply_at"`
|
||||||
model.Shelf
|
|
||||||
Status model.TechnologyPatentStatus `json:"status"`
|
Status model.TechnologyPatentStatus `json:"status"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
@ -26,7 +25,7 @@ type TechnologyPatentExpertInfo struct {
|
|||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
func (m *TechnologyPatentExpert) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
|
func (m *TechnologyPatentExpert) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS u").
|
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())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewTechnologyPatent().TableName())).
|
||||||
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
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 {
|
if err := db.Count(count).Error; err != nil {
|
||||||
return nil, err
|
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 nil, err
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
|
@ -121,13 +121,13 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// patent 专利信息
|
// patent 专利信息
|
||||||
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
func patent(expectID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
// 查询用户的专利信息
|
// 查询用户的专利信息
|
||||||
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
|
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
|
||||||
|
|
||||||
var count int64
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
config2 "SciencesServer/config"
|
config2 "SciencesServer/config"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -57,6 +58,8 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else if out.ManageExpert == nil {
|
||||||
|
return nil, errors.New("操作错误,专家信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mTechnologyPatent := model.NewTechnologyPatent()
|
||||||
|
|
||||||
@ -119,13 +122,13 @@ func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages
|
|||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
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 patent(id, page, pageSize)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return patent(uids, page, pageSize)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper 论文信息
|
// Paper 论文信息
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"SciencesServer/app/common/model"
|
"SciencesServer/app/common/model"
|
||||||
"SciencesServer/serve/orm"
|
"SciencesServer/serve/orm"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TechnologyPatentExpert struct {
|
type TechnologyPatentExpert struct {
|
||||||
@ -14,21 +13,16 @@ type TechnologyPatentExpert struct {
|
|||||||
type TechnologyPatentExpertInfo struct {
|
type TechnologyPatentExpertInfo struct {
|
||||||
model.Model
|
model.Model
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
ApplyCode string `json:"apply_code"`
|
||||||
ApplyAt string `json:"apply_at"`
|
ApplyAt string `json:"apply_at"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patents 专利信息
|
// Patents 专利信息
|
||||||
func (m *TechnologyPatentExpert) Patents(uid []uint64, page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
|
func (m *TechnologyPatentExpert) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentExpertInfo, error) {
|
||||||
_uids := make([]string, 0)
|
db := orm.GetDB().Table(m.TableName()+" AS u").
|
||||||
|
Select("p.id", "p.title", "p.apply_code", "p.apply_at", "p.description").
|
||||||
for _, u := range uid {
|
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewTechnologyPatent().TableName())).
|
||||||
_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)).
|
|
||||||
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
|
Reference in New Issue
Block a user