feat:优化项目信息
This commit is contained in:
@ -248,7 +248,7 @@ func (c *Examine) Launch(id uint64, identity, status int, remark string, params
|
||||
return err
|
||||
}
|
||||
if err = model2.UpdatesWhere(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": mUserInstance.Identity | identity, "updated_at": now,
|
||||
"identity": v.Identity | identity, "updated_at": now,
|
||||
}, []*model2.ModelWhere{
|
||||
model2.NewWhere("id", v.ID),
|
||||
}, tx); err != nil {
|
||||
@ -264,7 +264,7 @@ func (c *Examine) Launch(id uint64, identity, status int, remark string, params
|
||||
if err := json.Unmarshal([]byte(cache), _session); err != nil {
|
||||
return err
|
||||
}
|
||||
_session.Identity = mUserInstance.Identity | identity
|
||||
_session.Identity = v.Identity | identity
|
||||
|
||||
if userIdentity.IsSelected == model2.UserIdentitySelectedForYes {
|
||||
_session.SelectIdentity = identity
|
||||
|
@ -3,6 +3,7 @@ package technology
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/sys"
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
@ -87,7 +88,27 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
|
||||
if err = model2.Create(mTechnologyPatent.TechnologyPatent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentID(mTechnologyPatent.ID),
|
||||
service.WithPatentTitle(mTechnologyPatent.Title),
|
||||
)
|
||||
// 查询分类信息
|
||||
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||
|
||||
isExist, err = model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "ipc", "industry_detail"},
|
||||
model2.NewWhere("ipc", c.IPCCode))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mTechnologyPatentClassify.GetIndustryDetailAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||
}
|
||||
service.WithPatentIndustry(strings.Join(_industrys, ";"))(manage)
|
||||
}
|
||||
return manage.Create()
|
||||
})
|
||||
}
|
||||
|
||||
@ -96,7 +117,7 @@ func (c *PatentParams) edit(uid uint64) error {
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = c.ID
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "open_code"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "open_code", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -135,7 +156,17 @@ func (c *PatentParams) edit(uid uint64) error {
|
||||
mTechnologyPatent.PrincipalClaim = c.PrincipalClaim
|
||||
mTechnologyPatent.IPCCode = c.IPCCode
|
||||
mTechnologyPatent.Status = model2.TechnologyPatentStatus(c.Status)
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentID(mTechnologyPatent.ID),
|
||||
service.WithPatentTitle(mTechnologyPatent.Title),
|
||||
)
|
||||
return manage.Update()
|
||||
})
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
@ -273,9 +304,16 @@ func (c *Patent) Shelf(id uint64, status int) error {
|
||||
} else if mTechnologyPatent.UID != c.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
||||
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
||||
"shelf": status, "updated_at": time.Now(),
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentID(mTechnologyPatent.ID),
|
||||
service.WithPatentShow(status),
|
||||
)
|
||||
return manage.Update()
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
@ -292,7 +330,13 @@ func (c *Patent) Delete(id uint64) error {
|
||||
} else if mTechnologyPatent.UID != c.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mTechnologyPatent.TechnologyPatent)
|
||||
if err = model2.Delete(mTechnologyPatent.TechnologyPatent); err != nil {
|
||||
return err
|
||||
}
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentID(mTechnologyPatent.ID),
|
||||
)
|
||||
return manage.Delete()
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
|
11
app/api/enterprise/model/technology_patent_classify.go
Normal file
11
app/api/enterprise/model/technology_patent_classify.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import model2 "SciencesServer/app/common/model"
|
||||
|
||||
type TechnologyPatentClassify struct {
|
||||
*model2.TechnologyPatentClassify
|
||||
}
|
||||
|
||||
func NewTechnologyPatentClassify() *TechnologyPatentClassify {
|
||||
return &TechnologyPatentClassify{model2.NewTechnologyPatentClassify()}
|
||||
}
|
@ -10,6 +10,7 @@ type ESPatent struct {
|
||||
ID uint64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Industry string `json:"industry"` // 行业领域
|
||||
IsShow int `json:"is_show"` // 展示
|
||||
}
|
||||
|
||||
type ESPatentOption func(patent *ESPatent)
|
||||
@ -24,8 +25,22 @@ func (this *ESPatent) Create() error {
|
||||
}
|
||||
|
||||
func (this *ESPatent) Update() error {
|
||||
_bytes, _ := json.Marshal(this)
|
||||
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
||||
_map := make(map[string]interface{}, 0)
|
||||
|
||||
if this.Title != "" {
|
||||
_map["title"] = this.Title
|
||||
}
|
||||
if this.Industry != "" {
|
||||
_map["industry"] = this.Industry
|
||||
}
|
||||
if this.IsShow != 0 {
|
||||
_map["is_show"] = this.IsShow
|
||||
}
|
||||
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _map)
|
||||
}
|
||||
|
||||
func (this *ESPatent) Delete() error {
|
||||
return es.Delete(this.Index(), fmt.Sprintf("%d", this.ID))
|
||||
}
|
||||
|
||||
func (this *ESPatent) Search(page, pageSize int) (interface{}, int64, error) {
|
||||
@ -38,6 +53,8 @@ func (this *ESPatent) Search(page, pageSize int) (interface{}, int64, error) {
|
||||
if this.Industry != "" {
|
||||
termParams["industry"] = this.Industry
|
||||
}
|
||||
termParams["is_show"] = 1
|
||||
|
||||
return es.Search(this, this.Index(), &es.SearchParams{
|
||||
TermParams: termParams,
|
||||
MustParams: mustParams,
|
||||
@ -62,6 +79,12 @@ func WithPatentIndustry(industry string) ESPatentOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithPatentShow(show int) ESPatentOption {
|
||||
return func(patent *ESPatent) {
|
||||
patent.IsShow = show
|
||||
}
|
||||
}
|
||||
|
||||
func NewESPatent(options ...ESPatentOption) *ESPatent {
|
||||
out := new(ESPatent)
|
||||
|
||||
|
Reference in New Issue
Block a user