feat:优化项目信息

This commit is contained in:
henry
2022-03-05 15:31:22 +08:00
parent dcb5948e91
commit 4dc8deaadb
27 changed files with 401 additions and 138 deletions

View File

@ -43,7 +43,7 @@ type (
}
// patentForm 专利参数
patentForm struct {
Kind int `json:"kind" form:"kind" binding:"kind"`
Kind int `json:"kind" form:"kind" binding:"required"`
Title string `json:"title" form:"title" binding:"required"`
FileUrl string `json:"file_url" form:"file_url"`
ApplyCode string `json:"apply_code" form:"apply_code" binding:"required"`
@ -56,7 +56,7 @@ type (
Inventor string `json:"inventor" form:"inventor"`
PrincipalClaim string `json:"principal_claim" form:"principal_claim"`
Description string `json:"description" form:"description"`
Status int `json:"status" form:"status" binding:"status"`
Status int `json:"status" form:"status"`
}
// demandForm 需求参数
demandForm struct {

View File

@ -22,7 +22,8 @@ type (
PaperInfo struct {
ID string `json:"id"`
*model2.TechnologyPaper
Tags []string `json:"tags"`
Keywords []string `json:"keywords"`
Tags []string `json:"tags"`
}
PaperParams struct {
ID uint64
@ -53,7 +54,8 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages,
list := make([]*PaperInfo, 0)
for _, v := range out {
list = append(list, &PaperInfo{ID: v.GetEncodeID(), TechnologyPaper: v, Tags: v.GetTagAttribute()})
list = append(list, &PaperInfo{ID: v.GetEncodeID(), TechnologyPaper: v, Keywords: v.GetKeywordAttribute(),
Tags: v.GetTagAttribute()})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -65,6 +65,15 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
return errors.New("操作错误,申请号或公开(公告)号已存在")
}
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
// 查询当前的专家信息
mUserExpert := model.NewUserExpert()
if isExist, err = model2.LastWhere(mUserExpert.UserExpert, []string{"id", "expert_id"}, model2.NewWhere("uid", uid),
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
return err
} else if !isExist {
return errors.New("操作错误,无专家信息")
}
mTechnologyPatent.Kind = model2.TechnologyPatentKind(c.Kind)
mTechnologyPatent.Title = c.Title
mTechnologyPatent.FileUrl = c.FileUrl
@ -83,15 +92,6 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
if err = model2.Create(mTechnologyPatent.TechnologyPatent, tx); err != nil {
return err
}
// 查询当前的专家信息
mUserExpert := model.NewUserExpert()
if isExist, err = model2.LastWhere(mUserExpert.UserExpert, []string{"id", "expert_id"}, model2.NewWhere("uid", uid),
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
return err
} else if !isExist {
return errors.New("操作错误,无专家信息")
}
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
mTechnologyPatentExpert.ExpertID = mUserExpert.ExpertID
mTechnologyPatentExpert.PatentID = mTechnologyPatent.ID
@ -215,7 +215,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
where := []*model2.ModelWhere{model2.NewWhereFindInSet("p.inventor", expert.Name)}
if kind <= 0 {
if kind > 0 {
where = append(where, model2.NewWhere("p.kind", kind))
}
if title != "" {

View File

@ -52,7 +52,7 @@ func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, e
if len(params) > 0 {
for k, v := range params {
db = db.Or(fmt.Sprintf("%s = %v AND is_deleted = %d", k, v, model.DeleteStatusForNot))
db = db.Or(fmt.Sprintf("'%s' = '%v' AND is_deleted = %d", k, v, model.DeleteStatusForNot))
}
}
err := db.Count(&count).Error

View File

@ -18,14 +18,15 @@ type TechnologyPatentExpertInfo struct {
ApplyCode string `json:"apply_code"`
ApplyName string `json:"apply_name"`
ApplyAt string `json:"apply_at"`
Inventor string `json:"inventor"`
Status model.TechnologyPatentStatus `json:"status"`
CreatedAt time.Time
CreatedAt time.Time `json:"created_at"`
}
// Patent 专利信息
func (m *TechnologyPatentExpert) Patent(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_name", "p.apply_at", "p.status", "p.created_at").
Select("p.id", "p.title", "p.apply_code", "p.apply_name", "p.apply_at", "p.inventor", "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)

View File

@ -0,0 +1 @@
package model