From 3e432b2a6528aa6c69ef0a103b4976cdcac5eef7 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 7 Mar 2022 13:46:46 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=80=BB?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=AA=8C=E8=AF=81=E7=A0=81=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/admin/controller/technology/patent.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/admin/controller/technology/patent.go b/app/api/admin/controller/technology/patent.go index face4df..d1fe674 100644 --- a/app/api/admin/controller/technology/patent.go +++ b/app/api/admin/controller/technology/patent.go @@ -151,7 +151,7 @@ func (c *Patent) Form(params *PatentParams) error { if params.ID > 0 { mTechnologyPatent.ID = params.ID - isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "tenant_id", "uid", "apply_code", "ipc_code", "created_at"}) + isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "ipc_code", "created_at"}) if err != nil { return err @@ -268,7 +268,7 @@ func (c *Patent) Bind(id, uid uint64) error { mTechnologyPatent := model.NewTechnologyPatent() mTechnologyPatent.ID = id - isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "tenant_id"}) + isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"}) if err != nil { return err From 6f265db820a0af52781dcea13c0ae70aefe74f54 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 7 Mar 2022 15:49:17 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=80=BB?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=AA=8C=E8=AF=81=E7=A0=81=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/admin/controller/technology/patent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/admin/controller/technology/patent.go b/app/api/admin/controller/technology/patent.go index d1fe674..95c1e5a 100644 --- a/app/api/admin/controller/technology/patent.go +++ b/app/api/admin/controller/technology/patent.go @@ -151,7 +151,7 @@ func (c *Patent) Form(params *PatentParams) error { if params.ID > 0 { mTechnologyPatent.ID = params.ID - isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "ipc_code", "created_at"}) + isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "apply_code", "ipc_code", "created_at"}) if err != nil { return err From 8eeab34c34b4a29aaf780e97ec539501415be518 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 8 Mar 2022 13:56:34 +0800 Subject: [PATCH 3/7] =?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) From cf757ce7342b619948d054dd043f55a108091d4a Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 8 Mar 2022 14:33:32 +0800 Subject: [PATCH 4/7] up --- README.md | 2 +- app/api/website/api/config.go | 3 +-- app/basic/api/base.go | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9f3713..b4acf8a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ - 编译项目 ```bash -go bulid [-x|-o] +go build [-x|-o] ``` - 运行项目 diff --git a/app/api/website/api/config.go b/app/api/website/api/config.go index 25c5e9d..cc0b564 100644 --- a/app/api/website/api/config.go +++ b/app/api/website/api/config.go @@ -3,7 +3,6 @@ package api import ( "SciencesServer/app/api/website/controller" "SciencesServer/app/basic/api" - "strings" "github.com/gin-gonic/gin" ) @@ -19,6 +18,6 @@ func (*Config) Index(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := controller.NewConfig()(nil).Instance(form.Kind, strings.Split(form.Key, ",")) + data, err := controller.NewConfig()(nil).Instance(form.Kind, form.Key) api.APIResponse(err, data)(c) } diff --git a/app/basic/api/base.go b/app/basic/api/base.go index 3ebd080..711d93c 100644 --- a/app/basic/api/base.go +++ b/app/basic/api/base.go @@ -36,6 +36,7 @@ func GetTenantID() ApiHandle { value := c.GetHeader(config.ContentForTenantID) if value == "" { + // 登录身份 return uint64(1) } return utils.StringToUnit64(value) From 35de9164a66fd641ba9ddc58448403eea952fa58 Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 17 Mar 2022 12:11:38 +0800 Subject: [PATCH 5/7] =?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/admin/controller/manage/agent.go | 16 +++++++++------- app/api/enterprise/api/activity.go | 2 +- app/common/migrate/instance.go | 2 +- utils/array.go | 20 +++++++++++++++++++- utils/convert.go | 4 ++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/api/admin/controller/manage/agent.go b/app/api/admin/controller/manage/agent.go index 8e73bc5..a70973b 100644 --- a/app/api/admin/controller/manage/agent.go +++ b/app/api/admin/controller/manage/agent.go @@ -91,16 +91,18 @@ func (c *Agent) Instance(tenantID uint64, name string, status int, page, pageSiz Total int `json:"total"` Complete int `json:"complete"` }{} - // 筛选处理需求信息 - for _, val := range strings.Split(v.Demand, ";") { - objs := strings.Split(val, ":") + if v.Demand != "" { + // 筛选处理需求信息 + for _, val := range strings.Split(v.Demand, ";") { + objs := strings.Split(val, ":") - count := utils.StringToInt(objs[1]) + count := utils.StringToInt(objs[1]) - if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForClosedQuestions { - demand.Complete = count + if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForClosedQuestions { + demand.Complete = count + } + demand.Total += count } - demand.Total += count } list = append(list, &AgentInfo{ ID: v.GetEncodeID(), Name: v.Name, Mobile: v.Mobile, Industrys: industrys, diff --git a/app/api/enterprise/api/activity.go b/app/api/enterprise/api/activity.go index d188854..a389f3a 100644 --- a/app/api/enterprise/api/activity.go +++ b/app/api/enterprise/api/activity.go @@ -70,7 +70,7 @@ func (*Activity) ApplyDelete(c *gin.Context) { func (*Activity) Joins(c *gin.Context) { form := &struct { Title string `json:"title" form:"title"` - Status int `json:"status" form:"status"` // 1:未开始,2:进行中,3:已结束 + Status int `json:"status" form:"status"` api.PageForm }{} if err := api.Bind(form)(c); err != nil { diff --git a/app/common/migrate/instance.go b/app/common/migrate/instance.go index 433bf23..034ab70 100644 --- a/app/common/migrate/instance.go +++ b/app/common/migrate/instance.go @@ -139,7 +139,7 @@ func (this *Instance) Handle() { &synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()}, &synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()}, &synchronized{iModel: model.NewTechnologyPatent()}, &synchronized{iModel: model.NewTechnologyPatentExpert()}, &synchronized{iModel: model.NewTechnologyPatentClassify()}, - &synchronized{iModel: model.NewServiceDocking()}, + &synchronized{iModel: model.NewServiceDocking()}, &synchronized{iModel: model.NewServiceDemand()}, &synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()}, &synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()}, &synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()}, diff --git a/utils/array.go b/utils/array.go index 7d7798a..ac8659c 100644 --- a/utils/array.go +++ b/utils/array.go @@ -5,16 +5,34 @@ import ( "reflect" ) +// [1,2,3, 4, 5,6,7] +// 7 +// mid: 3 func InArray(search, needle interface{}) bool { val := reflect.ValueOf(needle) kind := val.Kind() if kind == reflect.Slice || kind == reflect.Array { - for i := 0; i < val.Len(); i++ { + _length := val.Len() + + if _length <= 0 { + return false + } else if _length == 1 { + return val.Index(0).Interface() == search + } + mid := _length >> 1 + + for i := 0; i < mid; i++ { if val.Index(i).Interface() == search { return true } + if val.Index((_length-1)-i).Interface() == search { + return true + } + } + if _length%2 > 0 { + return val.Index(mid+1).Interface() == search } } return false diff --git a/utils/convert.go b/utils/convert.go index 1831c40..3bfa183 100644 --- a/utils/convert.go +++ b/utils/convert.go @@ -84,6 +84,10 @@ func StructToMap(s interface{}, m map[string]interface{}) { fieldNum := tRef.NumField() for index := 0; index < fieldNum; index++ { + if mark, isExist := tRef.Field(index).Tag.Lookup("json"); isExist { + m[mark] = vRef.FieldByName(tRef.Field(index).Name).Interface() + continue + } m[tRef.Field(index).Name] = vRef.FieldByName(tRef.Field(index).Name).Interface() } } From 9f8f2504ff6d18a30dadf60021a4dceba817537e Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 17 Mar 2022 14:37:48 +0800 Subject: [PATCH 6/7] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/enterprise/api/technology.go b/app/api/enterprise/api/technology.go index 9082a02..2fab631 100644 --- a/app/api/enterprise/api/technology.go +++ b/app/api/enterprise/api/technology.go @@ -120,7 +120,7 @@ type ( Title string `json:"title" form:"title" binding:"required"` Description string `json:"description" form:"description" binding:"required"` api.ImageForm - File string `json:"file" form:"file" binding:"required"` + File string `json:"file" form:"file"` Industrys []string `json:"industrys" form:"industrys"` Customers []string `json:"customers" form:"customers"` Maturity int `json:"maturity" form:"maturity"` From 4735ee5834b3d4431416440f9cd0869e98fdd32d Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 18 Mar 2022 13:41:14 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/array.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/array.go b/utils/array.go index ac8659c..a89021a 100644 --- a/utils/array.go +++ b/utils/array.go @@ -32,7 +32,7 @@ func InArray(search, needle interface{}) bool { } } if _length%2 > 0 { - return val.Index(mid+1).Interface() == search + return val.Index(mid).Interface() == search } } return false