From 8eeab34c34b4a29aaf780e97ec539501415be518 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 8 Mar 2022 13:56:34 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/enterprise/api/technology.go | 26 +++++++++++++++++ .../enterprise/controller/technology/paper.go | 25 +++++++++++++++++ .../controller/technology/patent.go | 28 +++++++++++++++++++ router/address.go | 2 ++ 4 files changed, 81 insertions(+) diff --git a/app/api/enterprise/api/technology.go b/app/api/enterprise/api/technology.go index 6b8048d..9082a02 100644 --- a/app/api/enterprise/api/technology.go +++ b/app/api/enterprise/api/technology.go @@ -239,6 +239,19 @@ func (a *Technology) Paper(c *gin.Context) { api.APIResponse(err, data)(c) } +func (a *Technology) PaperSelect(c *gin.Context) { + form := &struct { + Title string `json:"title" form:"title" binding:"required"` + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + data, err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). + Select(form.Title) + api.APIResponse(err, data)(c) +} + func (a *Technology) PaperAdd(c *gin.Context) { form := new(paperForm) @@ -301,6 +314,19 @@ func (a *Technology) Patent(c *gin.Context) { api.APIResponse(err, data)(c) } +func (a *Technology) PatentSelect(c *gin.Context) { + form := &struct { + Title string `json:"title" form:"title" binding:"required"` + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). + Select(form.Title) + api.APIResponse(err, data)(c) +} + func (a *Technology) PatentDetail(c *gin.Context) { form := new(api.IDStringForm) diff --git a/app/api/enterprise/controller/technology/paper.go b/app/api/enterprise/controller/technology/paper.go index 860ab4d..7dd96ae 100644 --- a/app/api/enterprise/controller/technology/paper.go +++ b/app/api/enterprise/controller/technology/paper.go @@ -19,6 +19,10 @@ type Paper struct { type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper type ( + PaperBasic struct { + ID string `json:"id"` + Title string `json:"title"` + } PaperInfo struct { ID string `json:"id"` *model2.TechnologyPaper @@ -60,6 +64,27 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages, return &controller.ReturnPages{Data: list, Count: count}, nil } +func (c *Paper) Select(title string) ([]*PaperBasic, error) { + mTechnologyPaper := model.NewTechnologyPaper() + + where := make([]*model2.ModelWhereOrder, 0) + + if title != "" { + where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)}) + } + out := make([]*model2.TechnologyPaper, 0) + + if err := model2.ScanFields(mTechnologyPaper.TechnologyPaper, &out, []string{"id", "title"}, where...); err != nil { + return nil, err + } + list := make([]*PaperBasic, 0) + + for _, v := range out { + list = append(list, &PaperBasic{ID: v.GetEncodeID(), Title: v.Title}) + } + return list, nil +} + // Form 参数信息 func (c *Paper) Form(params *PaperParams) error { mTechnologyPaper := model.NewTechnologyPaper() diff --git a/app/api/enterprise/controller/technology/patent.go b/app/api/enterprise/controller/technology/patent.go index 651ba5d..5302028 100644 --- a/app/api/enterprise/controller/technology/patent.go +++ b/app/api/enterprise/controller/technology/patent.go @@ -22,6 +22,10 @@ type Patent struct { type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent type ( + PatentBasic struct { + ID string `json:"id"` + Title string `json:"title"` + } // PatentInfo 专利信息 PatentInfo struct { ID string `json:"id"` @@ -247,6 +251,30 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page return &controller.ReturnPages{Data: list, Count: count}, nil } +// Select 列表信息 +func (c *Patent) Select(title string) ([]*PatentBasic, error) { + where := make([]*model2.ModelWhereOrder, 0) + + if title != "" { + where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)}) + } + mTechnologyPatent := model.NewTechnologyPatent() + + out := make([]*model2.TechnologyPatent, 0) + + if err := model2.ScanFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title"}, where...); err != nil { + return nil, err + } + list := make([]*PatentBasic, 0) + + for _, v := range out { + list = append(list, &PatentBasic{ + ID: v.GetEncodeID(), Title: v.Title, + }) + } + return list, nil +} + // Match 搜索信息 func (c *Patent) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) { params := strings.Join([]string{ diff --git a/router/address.go b/router/address.go index 46e9b58..7a00e00 100644 --- a/router/address.go +++ b/router/address.go @@ -522,10 +522,12 @@ func registerEnterpriseAPI(app *gin.Engine) { { _api := new(api3.Technology) technologyV1.POST("/paper", _api.Paper) + technologyV1.POST("/paper/select", _api.PaperSelect) technologyV1.POST("/paper/add", _api.PaperAdd) technologyV1.POST("/paper/edit", _api.PaperEdit) technologyV1.POST("/paper/delete", _api.PaperDelete) technologyV1.POST("/patent", _api.Patent) + technologyV1.POST("/patent/select", _api.PatentSelect) technologyV1.POST("/patent/detail", _api.PatentDetail) technologyV1.POST("/patent/add", _api.PatentAdd) technologyV1.POST("/patent/edit", _api.PatentEdit)