From 199e6f06698ec5785c37af2d097926e496f63331 Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 2 Dec 2021 18:05:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E5=85=A5?= =?UTF-8?q?=E9=A9=BB=E4=BF=A1=E6=81=AF=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/enterprise/api/settled.go | 95 +++++++++++++++++- .../enterprise/controller/settled/agent.go | 28 ++++++ .../enterprise/controller/settled/basic.go | 3 +- .../enterprise/controller/settled/company.go | 9 +- .../enterprise/controller/settled/expert.go | 99 ++++++++++++++++++- .../controller/settled/laboratory.go | 93 +++++++++++++++++ .../enterprise/controller/settled/research.go | 91 +++++++++++++++++ app/api/enterprise/model/manage_agent.go | 14 +++ app/api/enterprise/model/user_agent.go | 11 +++ app/api/enterprise/model/user_expert.go | 11 +++ app/api/enterprise/model/user_laboratory.go | 11 +++ app/api/enterprise/model/user_research.go | 11 +++ app/basic/config/public.go | 43 ++++---- app/common/model/manage_agent.go | 33 +++++++ app/common/model/manage_company.go | 4 +- app/common/model/manage_expert.go | 29 ++++-- app/common/model/manage_laboratory.go | 41 ++++++-- app/common/model/manage_research.go | 36 +++++-- app/common/model/user_agent.go | 4 + app/common/model/user_expert.go | 4 + app/common/model/user_laboratory.go | 4 + app/common/model/user_research.go | 4 + router/address.go | 3 + 23 files changed, 626 insertions(+), 55 deletions(-) create mode 100644 app/api/enterprise/controller/settled/agent.go create mode 100644 app/api/enterprise/controller/settled/laboratory.go create mode 100644 app/api/enterprise/controller/settled/research.go create mode 100644 app/api/enterprise/model/manage_agent.go create mode 100644 app/api/enterprise/model/user_agent.go create mode 100644 app/api/enterprise/model/user_expert.go create mode 100644 app/api/enterprise/model/user_laboratory.go create mode 100644 app/api/enterprise/model/user_research.go diff --git a/app/api/enterprise/api/settled.go b/app/api/enterprise/api/settled.go index 9e56883..7df16cd 100644 --- a/app/api/enterprise/api/settled.go +++ b/app/api/enterprise/api/settled.go @@ -3,21 +3,110 @@ package api import ( "SciencesServer/app/api/enterprise/controller/settled" "SciencesServer/app/basic/api" + "SciencesServer/app/basic/config" "SciencesServer/app/session" "github.com/gin-gonic/gin" ) type Settled struct{} +type ( + // settledForm 入驻平台参数 + settledForm struct { + api.ImageForm + Name string `json:"name" form:"name"` + Code string `json:"code" form:"code"` + Mobile string `json:"mobile" form:"mobile"` + config.Area + Industrys []string `json:"industrys" form:"industrys"` + Keywords []string `json:"keywords" form:"keywords"` + Introduce string `json:"introduce" form:"introduce"` + } +) + +func (c *settledForm) bind() *settled.BasicParams { + return &settled.BasicParams{Name: c.Name, Image: c.FilterImageURL(), Code: c.Code, Mobile: c.Mobile, + Introduce: c.Introduce, Area: c.Area, Industrys: c.Industrys, Keywords: c.Keywords, + } +} + +// Index 入驻信息 func (*Settled) Index(c *gin.Context) { settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).Index() } +// Company 公司入驻信息 func (*Settled) Company(c *gin.Context) { - settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). - Launch(nil, 0, nil) + form := &struct { + settledForm + InviterCode string `json:"inviter_code" form:"inviter_code"` + config.IdentityForCompany + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + err := settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). + Launch(form.settledForm.bind(), (&api.IDStringForm{ID: form.InviterCode}).Convert(), &form.IdentityForCompany) + api.APIResponse(err)(c) } +// Expert 专家入驻信息 func (*Settled) Expert(c *gin.Context) { - + form := &struct { + settledForm + config.IdentityForExpert + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + err := settled.NewExpert()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). + Launch(form.settledForm.bind(), &form.IdentityForExpert) + api.APIResponse(err)(c) +} + +// Research 研究机构入驻信息 +func (*Settled) Research(c *gin.Context) { + form := &struct { + settledForm + config.IdentityForResearch + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + err := settled.NewResearch()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). + Launch(form.settledForm.bind(), &form.IdentityForResearch) + api.APIResponse(err)(c) +} + +// Laboratory 实验室入驻信息 +func (*Settled) Laboratory(c *gin.Context) { + form := &struct { + settledForm + config.IdentityForLaboratory + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + err := settled.NewLaboratory()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). + Launch(form.settledForm.bind(), &form.IdentityForLaboratory) + api.APIResponse(err)(c) +} + +// Agent 经纪人入驻信息 +func (*Settled) Agent(c *gin.Context) { + form := &struct { + settledForm + config.IdentityForAgent + }{} + if err := api.Bind(form)(c); err != nil { + api.APIFailure(err.(error))(c) + return + } + err := settled.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)). + Launch(form.settledForm.bind(), &form.IdentityForAgent) + api.APIResponse(err)(c) } diff --git a/app/api/enterprise/controller/settled/agent.go b/app/api/enterprise/controller/settled/agent.go new file mode 100644 index 0000000..d396be0 --- /dev/null +++ b/app/api/enterprise/controller/settled/agent.go @@ -0,0 +1,28 @@ +package settled + +import ( + "SciencesServer/app/basic/config" + "SciencesServer/app/session" +) + +// Company 经纪人入驻信息 +type Agent struct { + *session.Enterprise + local string +} + +type AgentHandle func(session *session.Enterprise, local string) *Agent + +// Launch 经纪人入驻 +func (c *Agent) Launch(params *BasicParams, other *config.IdentityForAgent) error { + return nil +} + +func NewAgent() AgentHandle { + return func(session *session.Enterprise, local string) *Agent { + return &Agent{ + Enterprise: session, + local: local, + } + } +} diff --git a/app/api/enterprise/controller/settled/basic.go b/app/api/enterprise/controller/settled/basic.go index a77491b..c2d4fe9 100644 --- a/app/api/enterprise/controller/settled/basic.go +++ b/app/api/enterprise/controller/settled/basic.go @@ -16,8 +16,7 @@ import ( // BasicParams 基本信息 type BasicParams struct { - ID uint64 - Name, Image, Code, Introduce string + Name, Image, Code, Mobile, Introduce string config.Area Industrys, Keywords []string } diff --git a/app/api/enterprise/controller/settled/company.go b/app/api/enterprise/controller/settled/company.go index aa5acef..e3257ee 100644 --- a/app/api/enterprise/controller/settled/company.go +++ b/app/api/enterprise/controller/settled/company.go @@ -47,6 +47,7 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id return err } } + mManageCompany.ID = 0 } mManageCompany.Local.Local = c.local mManageCompany.InviterID = inviterID @@ -56,7 +57,7 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id mManageCompany.Area = model2.Area{ Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, } - mManageCompany.WebUrl = other.WebUrl + mManageCompany.Url = other.Url mManageCompany.SetIndustryAttribute(params.Industrys) mManageCompany.SetKeywordAttribute(params.Keywords) mManageCompany.Introduce = params.Introduce @@ -67,10 +68,8 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)}, tx); err != nil { return err } - if mManageCompany.ID <= 0 { - if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil { - return err - } + if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil { + return err } if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{ "status": model2.InvalidStatusForYes, "updated_at": time.Now(), diff --git a/app/api/enterprise/controller/settled/expert.go b/app/api/enterprise/controller/settled/expert.go index 9ad9e6d..5ace695 100644 --- a/app/api/enterprise/controller/settled/expert.go +++ b/app/api/enterprise/controller/settled/expert.go @@ -1,3 +1,100 @@ package settled -type Expert struct{} +import ( + "SciencesServer/app/api/enterprise/model" + "SciencesServer/app/basic/config" + model2 "SciencesServer/app/common/model" + "SciencesServer/app/session" + "SciencesServer/serve/orm" + "SciencesServer/utils" + "errors" + "gorm.io/gorm" + "time" +) + +// Expert 专家入驻信息 +type Expert struct { + *session.Enterprise + local string +} + +type ExpertHandle func(session *session.Enterprise, local string) *Expert + +// Launch 发起入驻 +func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) error { + if c.Identity&config.TenantUserIdentityForExpert > 0 { + return errors.New("操作错误,不可重复申请入驻") + } + mManageExpert := model.NewManageExpert() + // 查询相应专家入驻信息 + isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "status"}, + model2.NewWhere("mobile", params.Mobile), model2.NewWhere("local", c.local)) + + mUserExpert := model.NewUserExpert() + + if err != nil { + return err + } else if isExist { + // 审核中 + if mManageExpert.Status == model2.ExamineStatusForOngoing { + return errors.New("操作错误,当前该专家信息审核中,不可入驻") + } + // 审核通过 + if mManageExpert.Status == model2.ExamineStatusForAgree { + // 筛选企业条件 + if err = params.filter(config.TenantUserIdentityForCompany, + model2.NewWhere("expert_id", mManageExpert.ID)); err != nil { + return err + } + } + mUserExpert.ID = 0 + } + mManageExpert.Local.Local = c.local + mManageExpert.ResearchID = other.ResearchID + mManageExpert.LaboratoryID = other.LaboratoryID + mManageExpert.Image.Image = params.Image + mManageExpert.Name = params.Name + mManageExpert.Mobile = params.Mobile + mManageExpert.Area = model2.Area{ + Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, + } + //mManageExpert.Position = params.Mobile + mManageExpert.School = other.School + mManageExpert.Major = other.Major + mManageExpert.Job = other.Job + mManageExpert.Title = other.Title + mManageExpert.Gender = model2.Gender{Gender: model2.GenderKind(other.Gender)} + mManageExpert.WorkAt = utils.DataTimeToDate(other.WorkAt) + mManageExpert.SetIndustryAttribute(params.Industrys) + mManageExpert.SetKeywordAttribute(params.Keywords) + mManageExpert.SetResearchAttribute(other.Researchs) + mManageExpert.Introduce = params.Introduce + + return orm.GetDB().Transaction(func(tx *gorm.DB) error { + // 删除区域相同编码公司信息 + if err = model2.DeleteWhere(mManageExpert.ManageExpert, []*model2.ModelWhere{ + model2.NewWhere("mobile", params.Mobile), model2.NewWhere("local", c.local)}, tx); err != nil { + return err + } + if err = model2.Create(mManageExpert.ManageExpert, tx); err != nil { + return err + } + if err := model2.UpdatesWhere(mUserExpert.UserExpert, map[string]interface{}{ + "status": model2.InvalidStatusForYes, "updated_at": time.Now(), + }, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil { + return err + } + mUserExpert.UID = c.UID + mUserExpert.ExpertID = mManageExpert.ID + return model2.Create(mUserExpert.UserExpert, tx) + }) +} + +func NewExpert() ExpertHandle { + return func(session *session.Enterprise, local string) *Expert { + return &Expert{ + Enterprise: session, + local: local, + } + } +} diff --git a/app/api/enterprise/controller/settled/laboratory.go b/app/api/enterprise/controller/settled/laboratory.go new file mode 100644 index 0000000..f55a51a --- /dev/null +++ b/app/api/enterprise/controller/settled/laboratory.go @@ -0,0 +1,93 @@ +package settled + +import ( + "SciencesServer/app/api/enterprise/model" + "SciencesServer/app/basic/config" + model2 "SciencesServer/app/common/model" + "SciencesServer/app/session" + "SciencesServer/serve/orm" + "errors" + "gorm.io/gorm" + "time" +) + +// Laboratory 实验室入驻信息 +type Laboratory struct { + *session.Enterprise + local string +} + +type LaboratoryHandle func(session *session.Enterprise, local string) *Laboratory + +// Launch 实验室入驻 +func (c *Laboratory) Launch(params *BasicParams, other *config.IdentityForLaboratory) error { + if c.Identity&config.TenantUserIdentityForLaboratory > 0 { + return errors.New("操作错误,不可重复申请入驻") + } + mManageLaboratory := model.NewManageLaboratory() + // 查询相应专家入驻信息 + isExist, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "status"}, + model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)) + + mUserLaboratory := model.NewUserLaboratory() + + if err != nil { + return err + } else if isExist { + // 审核中 + if mManageLaboratory.Status == model2.ExamineStatusForOngoing { + return errors.New("操作错误,当前该实验室信息审核中,不可入驻") + } + // 审核通过 + if mManageLaboratory.Status == model2.ExamineStatusForAgree { + // 筛选企业条件 + if err = params.filter(config.TenantUserIdentityForCompany, + model2.NewWhere("laboratory_id", mManageLaboratory.ID)); err != nil { + return err + } + } + mManageLaboratory.ID = 0 + } + mManageLaboratory.Local.Local = c.local + mManageLaboratory.ResearchID = other.ResearchID + mManageLaboratory.Image.Image = params.Image + mManageLaboratory.Name = params.Name + mManageLaboratory.Code = params.Code + mManageLaboratory.Area = model2.Area{ + Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, + } + //mManageExpert.Position = params.Mobile + mManageLaboratory.Url = other.Url + mManageLaboratory.SetIndustryAttribute(params.Industrys) + mManageLaboratory.SetKeywordAttribute(params.Keywords) + mManageLaboratory.SetResearchAttribute(other.Researchs) + mManageLaboratory.Introduce = params.Introduce + + return orm.GetDB().Transaction(func(tx *gorm.DB) error { + // 删除区域相同编码公司信息 + if err = model2.DeleteWhere(mManageLaboratory.ManageLaboratory, []*model2.ModelWhere{ + model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)}, tx); err != nil { + return err + } + if err = model2.Create(mManageLaboratory.ManageLaboratory, tx); err != nil { + return err + } + if err := model2.UpdatesWhere(mUserLaboratory.UserLaboratory, map[string]interface{}{ + "status": model2.InvalidStatusForYes, "updated_at": time.Now(), + }, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil { + return err + } + mUserLaboratory.UID = c.UID + mUserLaboratory.LaboratoryID = mManageLaboratory.ID + return model2.Create(mUserLaboratory.UserLaboratory, tx) + }) +} + +func NewLaboratory() LaboratoryHandle { + return func(session *session.Enterprise, local string) *Laboratory { + return &Laboratory{ + Enterprise: session, + local: local, + } + } +} diff --git a/app/api/enterprise/controller/settled/research.go b/app/api/enterprise/controller/settled/research.go new file mode 100644 index 0000000..a319828 --- /dev/null +++ b/app/api/enterprise/controller/settled/research.go @@ -0,0 +1,91 @@ +package settled + +import ( + "SciencesServer/app/api/enterprise/model" + "SciencesServer/app/basic/config" + model2 "SciencesServer/app/common/model" + "SciencesServer/app/session" + "SciencesServer/serve/orm" + "errors" + "gorm.io/gorm" + "time" +) + +// Research 研究机构入驻信息 +type Research struct { + *session.Enterprise + local string +} + +type ResearchHandle func(session *session.Enterprise, local string) *Research + +// Launch 研究机构入驻 +func (c *Research) Launch(params *BasicParams, other *config.IdentityForResearch) error { + if c.Identity&config.TenantUserIdentityForResearch > 0 { + return errors.New("操作错误,不可重复申请入驻") + } + mManageResearch := model.NewManageResearch() + // 查询相应专家入驻信息 + isExist, err := model2.FirstField(mManageResearch.ManageResearch, []string{"id", "status"}, + model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)) + + mUserResearch := model.NewUserResearch() + + if err != nil { + return err + } else if isExist { + // 审核中 + if mManageResearch.Status == model2.ExamineStatusForOngoing { + return errors.New("操作错误,当前该研究机构信息审核中,不可入驻") + } + // 审核通过 + if mManageResearch.Status == model2.ExamineStatusForAgree { + // 筛选企业条件 + if err = params.filter(config.TenantUserIdentityForCompany, + model2.NewWhere("research_id", mManageResearch.ID)); err != nil { + return err + } + } + mManageResearch.ID = 0 + } + mManageResearch.Local.Local = c.local + mManageResearch.Image.Image = params.Image + mManageResearch.Name = params.Name + mManageResearch.Code = params.Code + mManageResearch.Area = model2.Area{ + Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, + } + //mManageExpert.Position = params.Mobile + mManageResearch.SetIndustryAttribute(params.Industrys) + mManageResearch.SetKeywordAttribute(params.Keywords) + mManageResearch.SetResearchAttribute(other.Researchs) + mManageResearch.Introduce = params.Introduce + + return orm.GetDB().Transaction(func(tx *gorm.DB) error { + // 删除区域相同编码公司信息 + if err = model2.DeleteWhere(mManageResearch.ManageResearch, []*model2.ModelWhere{ + model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)}, tx); err != nil { + return err + } + if err = model2.Create(mManageResearch.ManageResearch, tx); err != nil { + return err + } + if err := model2.UpdatesWhere(mUserResearch.UserResearch, map[string]interface{}{ + "status": model2.InvalidStatusForYes, "updated_at": time.Now(), + }, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil { + return err + } + mUserResearch.UID = c.UID + mUserResearch.ResearchID = mManageResearch.ID + return model2.Create(mUserResearch.UserResearch, tx) + }) +} + +func NewResearch() ResearchHandle { + return func(session *session.Enterprise, local string) *Research { + return &Research{ + Enterprise: session, + local: local, + } + } +} diff --git a/app/api/enterprise/model/manage_agent.go b/app/api/enterprise/model/manage_agent.go new file mode 100644 index 0000000..eaa3c49 --- /dev/null +++ b/app/api/enterprise/model/manage_agent.go @@ -0,0 +1,14 @@ +package model + +import ( + "SciencesServer/app/common/model" +) + +// ManageAgent 经纪人入驻数据信息 +type ManageAgent struct { + *model.ManageAgent +} + +func NewManageAgent() *ManageAgent { + return &ManageAgent{model.NewManageAgent()} +} diff --git a/app/api/enterprise/model/user_agent.go b/app/api/enterprise/model/user_agent.go new file mode 100644 index 0000000..2c966be --- /dev/null +++ b/app/api/enterprise/model/user_agent.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type UserAgent struct { + *model.UserAgent +} + +func NewUserAgent() *UserAgent { + return &UserAgent{model.NewUserAgent()} +} diff --git a/app/api/enterprise/model/user_expert.go b/app/api/enterprise/model/user_expert.go new file mode 100644 index 0000000..86db22a --- /dev/null +++ b/app/api/enterprise/model/user_expert.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type UserExpert struct { + *model.UserExpert +} + +func NewUserExpert() *UserExpert { + return &UserExpert{model.NewUserExpert()} +} diff --git a/app/api/enterprise/model/user_laboratory.go b/app/api/enterprise/model/user_laboratory.go new file mode 100644 index 0000000..8364dec --- /dev/null +++ b/app/api/enterprise/model/user_laboratory.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type UserLaboratory struct { + *model.UserLaboratory +} + +func NewUserLaboratory() *UserLaboratory { + return &UserLaboratory{model.NewUserLaboratory()} +} diff --git a/app/api/enterprise/model/user_research.go b/app/api/enterprise/model/user_research.go new file mode 100644 index 0000000..994173b --- /dev/null +++ b/app/api/enterprise/model/user_research.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type UserResearch struct { + *model.UserResearch +} + +func NewUserResearch() *UserResearch { + return &UserResearch{model.NewUserResearch()} +} diff --git a/app/basic/config/public.go b/app/basic/config/public.go index 957abff..f4df969 100644 --- a/app/basic/config/public.go +++ b/app/basic/config/public.go @@ -11,32 +11,41 @@ type Area struct { type ( // IdentityForCompany 公司附加信息 IdentityForCompany struct { - WebUrl string `json:"web_url" form:"web_url"` + Url string `json:"url" form:"url"` // 企业网站 } // IdentityForExpert 专家附加信息 IdentityForExpert struct { - TenantID uint64 `json:"tenant_id" form:"tenant_id"` - Longitude float64 `json:"longitude" form:"longitude"` // 经度 - Latitude float64 `json:"latitude" form:"latitude"` // 纬度 - School string `json:"school" form:"school"` - Major string `json:"major" form:"major"` - Job string `json:"job" form:"job"` - Title string `json:"title" form:"title"` - WorkAt string `json:"work_at" form:"work_at"` - Research string `json:"research" form:"research"` // 研究方向 + ResearchID uint64 `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID + LaboratoryID uint64 `json:"laboratory_id" form:"laboratory_id"` // 实验室ID + School string `json:"school" form:"school"` // 毕业院校 + Major string `json:"major" form:"major"` // 专业 + Job string `json:"job" form:"job"` // 职务 + Title string `json:"title" form:"title"` // 职称 + WorkAt string `json:"work_at" form:"work_at"` // 从业时间 + Gender int `json:"gender" form:"gender"` // 性别 + Researchs []string `json:"researchs" form:"researchs"` // 研究方向 } // IdentityForResearch 研究机构 IdentityForResearch struct { - Longitude float64 `json:"longitude" form:"longitude"` // 经度 - Latitude float64 `json:"latitude" form:"latitude"` // 纬度 - Research string `json:"research" form:"research"` // 研究领域方向 + Longitude float64 `json:"longitude" form:"longitude"` // 经度 + Latitude float64 `json:"latitude" form:"latitude"` // 纬度 + Researchs []string `json:"researchs" form:"researchs"` // 研究方向 } // IdentityForLaboratory 实验室 IdentityForLaboratory struct { - TenantID uint64 `json:"tenant_id" form:"tenant_id"` - Longitude float64 `json:"longitude" form:"longitude"` // 经度 - Latitude float64 `json:"latitude" form:"latitude"` // 纬度 - Research string `json:"research" form:"research"` // 研究领域方向 + ResearchID uint64 `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID + Url string `json:"url" form:"url"` // 实验室网站 + Longitude float64 `json:"longitude" form:"longitude"` // 经度 + Latitude float64 `json:"latitude" form:"latitude"` // 纬度 + Researchs []string `json:"researchs" form:"researchs"` // 研究方向 + } + // IdentityForAgent 经纪人 + IdentityForAgent struct { + ResearchID uint64 `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID + Url string `json:"url" form:"url"` // 实验室网站 + Longitude float64 `json:"longitude" form:"longitude"` // 经度 + Latitude float64 `json:"latitude" form:"latitude"` // 纬度 + Researchs []string `json:"researchs" form:"researchs"` // 研究方向 } ) diff --git a/app/common/model/manage_agent.go b/app/common/model/manage_agent.go index c6221cd..176b0d6 100644 --- a/app/common/model/manage_agent.go +++ b/app/common/model/manage_agent.go @@ -1,7 +1,20 @@ package model +import "SciencesServer/utils" + +// ManageAgent 经纪人入驻信息管理 type ManageAgent struct { Model + Local + Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"` + Mobile string `gorm:"column:mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"` + IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"` + Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:行业领域" json:"industry"` + Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"-"` + WorkExperience string `gorm:"column:work_experience;type:varchar(255);default:null;comment:工作经历" json:"work_experience"` + WorkPlace string `gorm:"column:work_place;type:varchar(255);default:0;comment:工作地点" json:"work_place"` + IDImage string `gorm:"column:id_image;type:text;default:null;comment:身份证图片" json:"-"` + CredentialImage string `gorm:"column:credential_image;type:varchar(255);default:null;comment:资格证书" json:"credential_image"` ModelDeleted ModelAt } @@ -10,6 +23,26 @@ func (m *ManageAgent) TableName() string { return "manage_agent" } +func (m *ManageAgent) GetIndustryAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Industry, &out) + return out +} + +func (m *ManageAgent) SetIndustryAttribute(value []string) { + m.Industry = utils.AnyToJSON(value) +} + +func (m *ManageAgent) GetKeywordAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Keyword, &out) + return out +} + +func (m *ManageAgent) SetKeywordAttribute(value []string) { + m.Keyword = utils.AnyToJSON(value) +} + func NewManageAgent() *ManageAgent { return &ManageAgent{} } diff --git a/app/common/model/manage_company.go b/app/common/model/manage_company.go index c2e31c6..06e4f02 100644 --- a/app/common/model/manage_company.go +++ b/app/common/model/manage_company.go @@ -2,7 +2,7 @@ package model import "SciencesServer/utils" -// ManageCompany 公司企业入住信息管理 +// ManageCompany 公司企业入驻信息管理 type ManageCompany struct { Model Local @@ -11,7 +11,7 @@ type ManageCompany struct { Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"` Image Area - WebUrl string `gorm:"column:web_url;type:varchar(255);default:null;comment:企业网站" json:"web_url"` + Url string `gorm:"column:url;type:varchar(255);default:null;comment:企业网站" json:"url"` Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:行业领域" json:"industry"` Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"` Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"` diff --git a/app/common/model/manage_expert.go b/app/common/model/manage_expert.go index 2385e45..06d74de 100644 --- a/app/common/model/manage_expert.go +++ b/app/common/model/manage_expert.go @@ -9,15 +9,20 @@ import ( type ManageExpert struct { Model Local - UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + Image + ResearchID uint64 `gorm:"column:research_id;type:int(11);default:0;comment:科研机构ID" json:"-"` + LaboratoryID uint64 `gorm:"column:laboratory_id;type:int(11);default:0;comment:实验室ID" json:"-"` + Name string `gorm:"column:name;type:varchar(30);default:null;comment:专家名称" json:"name"` + Mobile string `gorm:"column:mobile;type:varchar(15);default:null;comment:专家联系方式" json:"mobile"` Area - Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"` - School string `gorm:"column:school;type:varchar(50);default:null;comment:院校" json:"school"` - Major string `gorm:"column:major;type:varchar(50);default:null;comment:专业" json:"major"` - Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"` - Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"` + Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"` + School string `gorm:"column:school;type:varchar(50);default:null;comment:院校" json:"school"` + Major string `gorm:"column:major;type:varchar(50);default:null;comment:专业" json:"major"` + Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"` + Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"` + Gender WorkAt time.Time `gorm:"column:work_at;type:date;not null;comment:从业时间" json:"work_at"` - Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"` + Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:行业领域" json:"industry"` Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"` Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"` Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"` @@ -40,6 +45,16 @@ func (m *ManageExpert) SetIndustryAttribute(value []string) { m.Industry = utils.AnyToJSON(value) } +func (m *ManageExpert) GetResearchAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Research, &out) + return out +} + +func (m *ManageExpert) SetResearchAttribute(value []string) { + m.Research = utils.AnyToJSON(value) +} + func (m *ManageExpert) GetKeywordAttribute() []string { keywords := make([]string, 0) _ = utils.FromJSON(m.Keyword, &keywords) diff --git a/app/common/model/manage_laboratory.go b/app/common/model/manage_laboratory.go index 0791d3c..199de61 100644 --- a/app/common/model/manage_laboratory.go +++ b/app/common/model/manage_laboratory.go @@ -8,13 +8,14 @@ import ( type ManageLaboratory struct { Model Local - UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` - Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` - Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"` + ResearchID uint64 `gorm:"column:research_id;type:int(11);default:0;comment:科研机构ID" json:"-"` + Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` + Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"` Image Area + Url string `gorm:"column:url;type:varchar(255);default:null;comment:实验室网站" json:"url"` Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"` - Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"` + Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:行业领域" json:"industry"` Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"` Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"` Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"` @@ -27,14 +28,34 @@ func (m *ManageLaboratory) TableName() string { return "manage_laboratory" } -func (m *ManageLaboratory) GetKeywordAttribute() []string { - keywords := make([]string, 0) - _ = utils.FromJSON(m.Keyword, &keywords) - return keywords +func (m *ManageLaboratory) GetIndustryAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Industry, &out) + return out } -func (m *ManageLaboratory) SetKeywordAttribute(keywords []string) { - m.Keyword = utils.AnyToJSON(keywords) +func (m *ManageLaboratory) SetIndustryAttribute(value []string) { + m.Industry = utils.AnyToJSON(value) +} + +func (m *ManageLaboratory) GetKeywordAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Keyword, &out) + return out +} + +func (m *ManageLaboratory) SetKeywordAttribute(value []string) { + m.Keyword = utils.AnyToJSON(value) +} + +func (m *ManageLaboratory) GetResearchAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Research, &out) + return out +} + +func (m *ManageLaboratory) SetResearchAttribute(value []string) { + m.Research = utils.AnyToJSON(value) } func NewManageLaboratory() *ManageLaboratory { diff --git a/app/common/model/manage_research.go b/app/common/model/manage_research.go index 249456c..d9f93fd 100644 --- a/app/common/model/manage_research.go +++ b/app/common/model/manage_research.go @@ -7,13 +7,13 @@ import ( // ManageResearch 科研机构入住信息管理 type ManageResearch struct { Model - UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + Local Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"` Image Area Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"` - Industry string `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"` + Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:所属领域;行业信息" json:"industry"` Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"` Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"` Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"` @@ -26,14 +26,34 @@ func (m *ManageResearch) TableName() string { return "manage_expert" } -func (m *ManageResearch) GetKeywordAttribute() []string { - keywords := make([]string, 0) - _ = utils.FromJSON(m.Keyword, &keywords) - return keywords +func (m *ManageResearch) GetIndustryAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Industry, &out) + return out } -func (m *ManageResearch) SetKeywordAttribute(keywords []string) { - m.Keyword = utils.AnyToJSON(keywords) +func (m *ManageResearch) SetIndustryAttribute(value []string) { + m.Industry = utils.AnyToJSON(value) +} + +func (m *ManageResearch) GetKeywordAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Keyword, &out) + return out +} + +func (m *ManageResearch) SetKeywordAttribute(value []string) { + m.Keyword = utils.AnyToJSON(value) +} + +func (m *ManageResearch) GetResearchAttribute() []string { + out := make([]string, 0) + _ = utils.FromJSON(m.Research, &out) + return out +} + +func (m *ManageResearch) SetResearchAttribute(value []string) { + m.Research = utils.AnyToJSON(value) } func NewManageResearch() *ManageResearch { diff --git a/app/common/model/user_agent.go b/app/common/model/user_agent.go index 10b03f6..89a1323 100644 --- a/app/common/model/user_agent.go +++ b/app/common/model/user_agent.go @@ -1,7 +1,11 @@ package model +// UserAgent 用户经纪人数据模型 type UserAgent struct { Model + UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + AgentID uint64 `gorm:"column:agent_id;type:int(11);default:0;comment:经纪人模型ID" json:"-"` + InvalidStatus ModelDeleted ModelAt } diff --git a/app/common/model/user_expert.go b/app/common/model/user_expert.go index 4b17737..77a3048 100644 --- a/app/common/model/user_expert.go +++ b/app/common/model/user_expert.go @@ -1,7 +1,11 @@ package model +// UserExpert 用户专家数据模型 type UserExpert struct { Model + UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + ExpertID uint64 `gorm:"column:expert_id;type:int(11);default:0;comment:专家模型ID" json:"-"` + InvalidStatus ModelDeleted ModelAt } diff --git a/app/common/model/user_laboratory.go b/app/common/model/user_laboratory.go index 6720e1b..a538cf4 100644 --- a/app/common/model/user_laboratory.go +++ b/app/common/model/user_laboratory.go @@ -1,7 +1,11 @@ package model +// UserLaboratory 用户实验室数据模型 type UserLaboratory struct { Model + UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + LaboratoryID uint64 `gorm:"column:laboratory_id;type:int(11);default:0;comment:实验室模型ID" json:"-"` + InvalidStatus ModelDeleted ModelAt } diff --git a/app/common/model/user_research.go b/app/common/model/user_research.go index e02c0bd..a33698f 100644 --- a/app/common/model/user_research.go +++ b/app/common/model/user_research.go @@ -1,7 +1,11 @@ package model +// UserResearch 用户研究机构数据模型 type UserResearch struct { Model + UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + ResearchID uint64 `gorm:"column:research_id;type:int(11);default:0;comment:研究机构模型ID" json:"-"` + InvalidStatus ModelDeleted ModelAt } diff --git a/router/address.go b/router/address.go index a53f3b4..a635184 100644 --- a/router/address.go +++ b/router/address.go @@ -161,6 +161,9 @@ func registerEnterpriseAPI(app *gin.Engine) { settledV1.GET("", _api.Index) settledV1.POST("/company", _api.Company) settledV1.POST("/expert", _api.Expert) + settledV1.POST("/research", _api.Research) + settledV1.POST("/laboratory", _api.Laboratory) + settledV1.POST("/agent", _api.Agent) } // Technology 技术管理 technologyV1 := g.Group("/technology")