diff --git a/README.md b/README.md index 228955d..150116e 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ 中科云管理系统 -[comment]: <> (- 预览: https://preview.pro.antdv.com) - 环境和依赖 ---- @@ -46,12 +44,16 @@ pack - 发布项目 ```bash -linux:一:./server.sh(请注意修改文件提示的地方);二:nohup ./项目 &;三:DockerFile +linux + 一:./server.sh(请注意修改文件提示的地方); + 二:nohup ./项目 &; + 三:DockerFile ``` +> 请注意,注意修改`server.sh`、`DockerFile`配置信息 - 其他说明 - 项目目录 - - file 配置文件,不可删除 - - key 密钥管理,不可删除 - - cmd 项目执行入口 - - log 日志管理,自动生成 + - cmd 项目执行入口 + - file 配置文件,不可删除 + - key 密钥管理,不可删除 + - log 日志管理,自动生成 diff --git a/app/api/admin/controller/manage/examine.go b/app/api/admin/controller/manage/examine.go index 97feb93..7b1273b 100644 --- a/app/api/admin/controller/manage/examine.go +++ b/app/api/admin/controller/manage/examine.go @@ -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 diff --git a/app/api/enterprise/controller/technology/patent.go b/app/api/enterprise/controller/technology/patent.go index dae8433..1cab8b2 100644 --- a/app/api/enterprise/controller/technology/patent.go +++ b/app/api/enterprise/controller/technology/patent.go @@ -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 { diff --git a/app/api/enterprise/model/technology_patent_classify.go b/app/api/enterprise/model/technology_patent_classify.go new file mode 100644 index 0000000..56dde5a --- /dev/null +++ b/app/api/enterprise/model/technology_patent_classify.go @@ -0,0 +1,11 @@ +package model + +import model2 "SciencesServer/app/common/model" + +type TechnologyPatentClassify struct { + *model2.TechnologyPatentClassify +} + +func NewTechnologyPatentClassify() *TechnologyPatentClassify { + return &TechnologyPatentClassify{model2.NewTechnologyPatentClassify()} +} diff --git a/app/service/es_patent.go b/app/service/es_patent.go index 0d3f9ea..cf5c6a9 100644 --- a/app/service/es_patent.go +++ b/app/service/es_patent.go @@ -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) diff --git a/package.json b/package.json index cfca85c..cc535da 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ { "name": "BaiscServer-Window", "format": "zip", - "pattern": "{Serve.exe,config.yaml,keys/*,file/*,start.sh,stop.sh}", + "pattern": "{SciencesServe.exe,default_setting.yaml,default_engine.yaml,keys/*,file/*,server.sh}", "options": { "dot": true, "ignore": [ @@ -41,7 +41,7 @@ { "name": "BaiscServer-Linux", "format": "tar", - "pattern": "{SciencesServer,config.yaml,keys/*,file/*,start.sh,stop.sh}", + "pattern": "{SciencesServer,default_setting.yaml,default_engine.yaml,keys/*,file/*,Dockerfile,server.sh}", "options": { "dot": true, "ignore": [ diff --git a/serve/es/serve.go b/serve/es/serve.go index aa18f5f..8f622ff 100644 --- a/serve/es/serve.go +++ b/serve/es/serve.go @@ -27,11 +27,19 @@ func Create(index, id string, body []byte) error { } // Update 更新操作 -func Update(index, id string, body []byte) error { +func Update(index, id string, params map[string]interface{}) error { + scriptStr := "" + + for k := range params { + scriptStr += "ctx._source." + k + " = params." + k + ";" + } + script := elastic.NewScript(scriptStr).Params(params) + _, err := client.Update(). Index(index). Id(id). - Doc(string(body)). + Script(script). + //Doc(string(body)). Do(context.Background()) return err }