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/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/admin/controller/technology/patent.go b/app/api/admin/controller/technology/patent.go index face4df..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", "tenant_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 @@ -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 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/api/enterprise/api/technology.go b/app/api/enterprise/api/technology.go index 6b8048d..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"` @@ -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/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) 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/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) diff --git a/utils/array.go b/utils/array.go index 7d7798a..a89021a 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).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() } }