From 6d075dab4fbcf34bccdf2c730eab5e9f6468e46a Mon Sep 17 00:00:00 2001 From: henry Date: Sat, 15 Jan 2022 16:48:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/admin/api/manage.go | 2 +- app/api/admin/controller/manage/es.go | 28 +++++++ app/api/admin/controller/manage/examine.go | 31 +++++-- app/api/admin/controller/manage/instance.go | 10 +-- app/api/enterprise/api/account.go | 4 +- app/api/enterprise/api/home.go | 2 +- app/api/enterprise/api/manage.go | 8 +- app/api/enterprise/api/service.go | 10 +-- app/api/enterprise/api/settled.go | 2 +- app/api/enterprise/api/technology.go | 80 +++++++++---------- .../enterprise/controller/account/login.go | 16 ++-- .../enterprise/controller/account/register.go | 12 +-- .../enterprise/controller/home/instance.go | 8 +- .../controller/manage/enterprise.go | 12 +-- .../enterprise/controller/service/demand.go | 12 +-- .../enterprise/controller/settled/instance.go | 8 +- .../controller/technology/achievement.go | 10 +-- .../controller/technology/demand.go | 10 +-- .../controller/technology/instance.go | 10 +-- .../enterprise/controller/technology/paper.go | 12 +-- .../controller/technology/patent.go | 13 +-- .../controller/technology/product.go | 10 +-- .../controller/technology/project.go | 10 +-- .../enterprise/controller/technology/topic.go | 10 +-- app/common/model/common.go | 4 - app/common/model/service_demand.go | 2 +- app/common/model/technology_achievement.go | 2 +- app/common/model/technology_demand.go | 2 +- app/common/model/technology_instance.go | 2 +- app/common/model/technology_prodcut.go | 2 +- app/common/model/technology_project.go | 2 +- app/common/model/technology_topic.go | 2 +- app/common/model/user_cooperate_enterprise.go | 2 +- 33 files changed, 196 insertions(+), 154 deletions(-) create mode 100644 app/api/admin/controller/manage/es.go diff --git a/app/api/admin/api/manage.go b/app/api/admin/api/manage.go index 94b9316..786e94e 100644 --- a/app/api/admin/api/manage.go +++ b/app/api/admin/api/manage.go @@ -50,7 +50,7 @@ func (*Manage) Expert(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := manage.NewInstance()(api.GetSession()(c).(*session.Admin), api.GetTenantID()(c).(string)). + data, err := manage.NewInstance()(api.GetSession()(c).(*session.Admin), api.GetTenantID()(c).(uint64)). Expert(form.Name, form.Status, form.Page, form.PageSize) api.APIResponse(err, data) } diff --git a/app/api/admin/controller/manage/es.go b/app/api/admin/controller/manage/es.go new file mode 100644 index 0000000..b84d40a --- /dev/null +++ b/app/api/admin/controller/manage/es.go @@ -0,0 +1,28 @@ +package manage + +import ( + "SciencesServer/app/basic/config" + "SciencesServer/app/service" + "strings" +) + +type ESParams struct { + Identity int + Name string + Keywords, Industrys, Researchs []string +} + +func (this *ESParams) Set() { + _identitys := make([]string, 0) + + for _, v := range this.Industrys { + _identitys = append(_identitys, config.GetIndustryInfo(v, "-", "-")) + } + _ = service.NewESManage( + service.WithManageIdentity(this.Identity), + service.WithManageTitle(this.Name), + service.WithManageIndustry(strings.Join(_identitys, ";")), + service.WithManageKeyword(strings.Join(this.Keywords, ";")), + service.WithManageResearch(strings.Join(this.Researchs, ";")), + ).Create() +} diff --git a/app/api/admin/controller/manage/examine.go b/app/api/admin/controller/manage/examine.go index 1d42621..1e55154 100644 --- a/app/api/admin/controller/manage/examine.go +++ b/app/api/admin/controller/manage/examine.go @@ -18,8 +18,10 @@ type Examine struct { type ExamineHandle func(session *session.Admin) *Examine type ExamineManageInfo struct { - IModel model2.IModel - UIDs []uint64 // 用户表UUID + IModel model2.IModel + UIDs []uint64 // 用户表UUID + Name string + Keywords, Industrys, Researchs []string } // examineHandle 审核处理 @@ -60,7 +62,9 @@ func examineCompany(id, tenantID uint64) (*ExamineManageInfo, error) { model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil { return nil, err } - return &ExamineManageInfo{IModel: mManageCompany.ManageCompany, UIDs: uids}, nil + return &ExamineManageInfo{IModel: mManageCompany.ManageCompany, UIDs: uids, + Name: mManageCompany.Name, Industrys: mManageCompany.GetIndustryAttribute(), + Keywords: mManageCompany.GetKeywordAttribute()}, nil } func examineExpert(id, tenantID uint64) (*ExamineManageInfo, error) { @@ -82,7 +86,9 @@ func examineExpert(id, tenantID uint64) (*ExamineManageInfo, error) { model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil { return nil, err } - return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, UIDs: uids}, nil + return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, UIDs: uids, + Name: mManageExpert.Name, Industrys: mManageExpert.GetIndustryAttribute(), + Keywords: mManageExpert.GetKeywordAttribute(), Researchs: mManageExpert.GetResearchAttribute()}, nil } func examineResearch(id, tenantID uint64) (*ExamineManageInfo, error) { @@ -105,7 +111,9 @@ func examineResearch(id, tenantID uint64) (*ExamineManageInfo, error) { model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil { return nil, err } - return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, UIDs: uids}, nil + return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, UIDs: uids, + Name: mManageResearch.Name, Industrys: mManageResearch.GetIndustryAttribute(), + Keywords: mManageResearch.GetKeywordAttribute(), Researchs: mManageResearch.GetResearchAttribute()}, nil } func examineLaboratory(id, tenantID uint64) (*ExamineManageInfo, error) { @@ -128,7 +136,9 @@ func examineLaboratory(id, tenantID uint64) (*ExamineManageInfo, error) { model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil { return nil, err } - return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, UIDs: uids}, nil + return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, UIDs: uids, + Name: mManageLaboratory.Name, Industrys: mManageLaboratory.GetIndustryAttribute(), + Keywords: mManageLaboratory.GetKeywordAttribute(), Researchs: mManageLaboratory.GetResearchAttribute()}, nil } func examineAgent(id, tenantID uint64) (*ExamineManageInfo, error) { @@ -151,7 +161,9 @@ func examineAgent(id, tenantID uint64) (*ExamineManageInfo, error) { model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil { return nil, err } - return &ExamineManageInfo{IModel: mManageAgent.ManageAgent, UIDs: uids}, nil + return &ExamineManageInfo{IModel: mManageAgent.ManageAgent, UIDs: uids, + Name: mManageAgent.Name, Industrys: mManageAgent.GetIndustryAttribute(), + Keywords: mManageAgent.GetKeywordAttribute()}, nil } // Launch 发起审核 @@ -210,6 +222,11 @@ func (c *Examine) Launch(id uint64, identity, status int) error { return err } } + // 存放es中 + (&ESParams{ + Identity: identity, Name: data.Name, Keywords: data.Keywords, + Industrys: data.Industrys, Researchs: data.Researchs, + }).Set() return nil }) } diff --git a/app/api/admin/controller/manage/instance.go b/app/api/admin/controller/manage/instance.go index 8e0b92b..da80765 100644 --- a/app/api/admin/controller/manage/instance.go +++ b/app/api/admin/controller/manage/instance.go @@ -14,10 +14,10 @@ import ( type Instance struct { *session.Admin gorm.Model - local string + tenantID uint64 } -type InstanceHandle func(session *session.Admin, local string) *Instance +type InstanceHandle func(session *session.Admin, tenantID uint64) *Instance type ( // InstanceForExpert 专家信息 @@ -87,10 +87,10 @@ func (c *Instance) Expert(name string, status int, page, pageSize int) (*control } func NewInstance() InstanceHandle { - return func(session *session.Admin, local string) *Instance { + return func(session *session.Admin, tenantID uint64) *Instance { return &Instance{ - Admin: session, - local: local, + Admin: session, + tenantID: tenantID, } } } diff --git a/app/api/enterprise/api/account.go b/app/api/enterprise/api/account.go index eb2afd7..c887745 100644 --- a/app/api/enterprise/api/account.go +++ b/app/api/enterprise/api/account.go @@ -34,7 +34,7 @@ func (a *Account) Login(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := account.NewLogin()(api.GetTenantID()(c).(string)).Launch(account.LoginMode(form.Mode), &account.LoginParams{ + data, err := account.NewLogin()(api.GetTenantID()(c).(uint64)).Launch(account.LoginMode(form.Mode), &account.LoginParams{ Captcha: struct { Mobile string Captcha string @@ -54,7 +54,7 @@ func (a *Account) Register(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := account.NewRegister()(api.GetTenantID()(c).(string)).Launch(&account.RegisterParams{ + data, err := account.NewRegister()(api.GetTenantID()(c).(uint64)).Launch(&account.RegisterParams{ Name: form.Name, Mobile: form.Mobile, Captcha: form.Captcha, Password: form.Password, RepeatPass: form.RepeatPass, }) diff --git a/app/api/enterprise/api/home.go b/app/api/enterprise/api/home.go index 1471410..2a59c2f 100644 --- a/app/api/enterprise/api/home.go +++ b/app/api/enterprise/api/home.go @@ -10,6 +10,6 @@ import ( type Home struct{} func (*Home) Instance(c *gin.Context) { - data, err := home.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).Instance() + data, err := home.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).Instance() api.APIResponse(err, data) } diff --git a/app/api/enterprise/api/manage.go b/app/api/enterprise/api/manage.go index c735e10..95c0077 100644 --- a/app/api/enterprise/api/manage.go +++ b/app/api/enterprise/api/manage.go @@ -62,7 +62,7 @@ func (*Manage) Enterprise(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Mode, form.Title, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -74,7 +74,7 @@ func (*Manage) EnterpriseAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&manage.EnterpriseParams{Mode: form.Mode, Title: form.Title, Name: form.Name, Mobile: form.Mobile, Papers: form.paperInfo(), Patents: form.PatentInfo(), Content: form.Content, }) @@ -90,7 +90,7 @@ func (*Manage) EnterpriseEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&manage.EnterpriseParams{ID: form.Convert(), Mode: form.Mode, Title: form.Title, Name: form.Name, Mobile: form.Mobile, Papers: form.paperInfo(), Patents: form.PatentInfo(), Content: form.Content, }) @@ -104,7 +104,7 @@ func (*Manage) EnterpriseDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := manage.NewEnterprise()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } diff --git a/app/api/enterprise/api/service.go b/app/api/enterprise/api/service.go index c119f05..606e3b7 100644 --- a/app/api/enterprise/api/service.go +++ b/app/api/enterprise/api/service.go @@ -31,7 +31,7 @@ func (*Service) Demand(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Title, form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -43,7 +43,7 @@ func (*Service) DemandDetail(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Detail(form.Convert()) api.APIResponse(err, data)(c) } @@ -55,7 +55,7 @@ func (*Service) DemandAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&service.DemandParams{Kinds: form.Kinds, IsSubmit: form.IsSubmit, Title: form.Title, Name: form.Name, Mobile: form.Mobile, Description: form.Description, }) @@ -71,7 +71,7 @@ func (*Service) DemandEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&service.DemandParams{ID: form.Convert(), Kinds: form.Kinds, IsSubmit: form.IsSubmit, Title: form.Title, Name: form.Name, Mobile: form.Mobile, Description: form.Description, }) @@ -85,7 +85,7 @@ func (*Service) DemandDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } diff --git a/app/api/enterprise/api/settled.go b/app/api/enterprise/api/settled.go index 28fb135..4ed4dbd 100644 --- a/app/api/enterprise/api/settled.go +++ b/app/api/enterprise/api/settled.go @@ -32,7 +32,7 @@ func (c *settledForm) bind() *settled.BasicParams { // Index 入驻信息 func (*Settled) Index(c *gin.Context) { - data, err := settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).Index() + data, err := settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).Index() api.APIResponse(err, data)(c) } diff --git a/app/api/enterprise/api/technology.go b/app/api/enterprise/api/technology.go index d349a1e..af24bb5 100644 --- a/app/api/enterprise/api/technology.go +++ b/app/api/enterprise/api/technology.go @@ -156,7 +156,7 @@ func (a *Technology) Instance(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -168,7 +168,7 @@ func (a *Technology) InstanceAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.InstanceParams{ PatentID: form.PatentID, Territory: form.Territory, Title: form.Title, Company: form.Company, Images: form.FilterImageURL(), ProveImages: form.FilterProveImages(), Introduce: form.Introduce, Purpose: form.Purpose, @@ -187,7 +187,7 @@ func (a *Technology) InstanceEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.InstanceParams{ ID: form.Convert(), PatentID: form.PatentID, Territory: form.Territory, Title: form.Title, Company: form.Company, @@ -207,7 +207,7 @@ func (a *Technology) InstanceShelf(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Shelf(form.Convert(), form.Status) api.APIResponse(err)(c) } @@ -219,7 +219,7 @@ func (a *Technology) InstanceDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -233,7 +233,7 @@ func (a *Technology) Paper(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Title, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -245,7 +245,7 @@ func (a *Technology) PaperAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.PaperParams{ Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt, Keywords: form.Keywords, Tags: form.Tags, Remark: form.Remark, @@ -262,7 +262,7 @@ func (a *Technology) PaperEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.PaperParams{ ID: form.Convert(), Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt, Keywords: form.Keywords, Tags: form.Tags, Remark: form.Remark, @@ -277,7 +277,7 @@ func (a *Technology) PaperDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPaper()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -295,7 +295,7 @@ func (a *Technology) Patent(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Kind, form.Title, form.ApplyCode, form.OpenCode, form.IPCCode, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -307,7 +307,7 @@ func (a *Technology) PatentDetail(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Detail(form.Convert()) api.APIResponse(err, data)(c) } @@ -319,7 +319,7 @@ func (a *Technology) PatentAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.PatentParams{Kind: form.Kind, Title: form.Title, FileUrl: (&api.FileForm{File: form.FileUrl}).FilterURL(), ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyAt: form.ApplyAt, OpenCode: form.OpenCode, OpenAt: form.OpenAt, Inventor: form.Inventor, IPCCode: form.IPCCode, @@ -337,7 +337,7 @@ func (a *Technology) PatentEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.PatentParams{ID: form.Convert(), Kind: form.Kind, Title: form.Title, FileUrl: (&api.FileForm{File: form.FileUrl}).FilterURL(), ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyAt: form.ApplyAt, OpenCode: form.OpenCode, @@ -354,7 +354,7 @@ func (a *Technology) PatentDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -368,7 +368,7 @@ func (a *Technology) Demand(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -380,7 +380,7 @@ func (a *Technology) DemandDetail(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Detail(form.Convert()) api.APIResponse(err, data)(c) } @@ -392,7 +392,7 @@ func (a *Technology) DemandAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.DemandParams{ Title: form.Title, Introduce: form.Introduce, Name: form.Name, Mobile: form.Mobile, Deadline: form.Deadline, Industry: form.Industry, Kinds: form.Kinds, Budget: form.Budget, BudgetMode: form.BudgetMode, @@ -414,7 +414,7 @@ func (a *Technology) DemandEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.DemandParams{ ID: form.Convert(), Title: form.Title, Introduce: form.Introduce, Name: form.Name, Mobile: form.Mobile, Deadline: form.Deadline, Industry: form.Industry, Kinds: form.Kinds, Budget: form.Budget, BudgetMode: form.BudgetMode, @@ -434,7 +434,7 @@ func (a *Technology) DemandDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -448,7 +448,7 @@ func (a *Technology) Topic(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -460,7 +460,7 @@ func (a *Technology) TopicDetail(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Detail(form.Convert()) api.APIResponse(err, data)(c) } @@ -472,7 +472,7 @@ func (a *Technology) TopicAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.TopicParams{Title: form.Title, Emcee: form.Emcee, Mechanism: form.Mechanism, Code: form.Code, BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Source: form.Source, Kind: form.Kind, Keywords: form.Keywords}) @@ -488,7 +488,7 @@ func (a *Technology) TopicEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.TopicParams{ID: form.Convert(), Title: form.Title, Emcee: form.Emcee, Mechanism: form.Mechanism, Code: form.Code, BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Source: form.Source, Kind: form.Kind, Keywords: form.Keywords}) @@ -502,7 +502,7 @@ func (a *Technology) TopicDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewTopic()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -517,7 +517,7 @@ func (*Technology) Product(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Instance(form.Title, form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -531,7 +531,7 @@ func (*Technology) ProductVisit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Visit(form.Convert(), form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -543,7 +543,7 @@ func (*Technology) ProductAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.ProductParams{ Title: form.Title, Image: form.FilterImageURL(), Video: form.FilterVideo(), Material: form.FilterMaterial(), Introduce: form.Introduce, Industrys: form.Industrys, @@ -562,7 +562,7 @@ func (*Technology) ProductEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.ProductParams{ ID: form.Convert(), Title: form.Title, Image: form.FilterImageURL(), Video: form.FilterVideo(), Material: form.FilterMaterial(), Introduce: form.Introduce, Industrys: form.Industrys, @@ -581,7 +581,7 @@ func (*Technology) ProductShelf(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Shelf(form.Convert(), form.Status) api.APIResponse(err)(c) } @@ -593,7 +593,7 @@ func (*Technology) ProductDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -607,7 +607,7 @@ func (a *Technology) Project(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). List(form.Title, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -619,7 +619,7 @@ func (a *Technology) ProjectAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.ProjectParams{ Title: form.Title, Kind: form.Kind, Source: form.Source, Director: form.Director, BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Role: form.Role, @@ -636,7 +636,7 @@ func (a *Technology) ProjectEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.ProjectParams{ID: form.Convert(), Title: form.Title, Kind: form.Kind, Source: form.Source, Director: form.Director, BeginAt: form.BeginAt, FinishAt: form.FinishAt, Amount: form.Amount, Role: form.Role, @@ -653,7 +653,7 @@ func (*Technology) ProjectShelf(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Shelf(form.Convert(), form.Status) api.APIResponse(err)(c) } @@ -665,7 +665,7 @@ func (a *Technology) ProjectDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewProject()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } @@ -679,7 +679,7 @@ func (*Technology) Achievement(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + data, err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Instance(form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -691,7 +691,7 @@ func (*Technology) AchievementAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.AchievementParams{Mode: form.Mode, Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(), Introduce: form.Introduce, Industrys: form.Industrys, @@ -710,7 +710,7 @@ func (*Technology) AchievementEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Form(&technology2.AchievementParams{ID: form.Convert(), Mode: form.Mode, Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(), Introduce: form.Introduce, Industrys: form.Industrys, @@ -729,7 +729,7 @@ func (*Technology) AchievementShelf(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Shelf(form.Convert(), form.Status) api.APIResponse(err)(c) } @@ -741,7 +741,7 @@ func (*Technology) AchievementDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)). + err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)). Delete(form.Convert()) api.APIResponse(err)(c) } diff --git a/app/api/enterprise/controller/account/login.go b/app/api/enterprise/controller/account/login.go index 7d5939f..5178b81 100644 --- a/app/api/enterprise/controller/account/login.go +++ b/app/api/enterprise/controller/account/login.go @@ -11,10 +11,10 @@ import ( "gorm.io/gorm" ) -type Login struct{ local string } +type Login struct{ tenantID uint64 } type ( - LoginHandle func(local string) *Login + LoginHandle func(tenantID uint64) *Login ) type ( @@ -41,12 +41,12 @@ const ( LoginModeForQQ // QQ登陆 ) -var loginHandle = map[LoginMode]func(*LoginParams, string) (*InstanceLoginParams, error){ +var loginHandle = map[LoginMode]func(*LoginParams, uint64) (*InstanceLoginParams, error){ LoginModeForSmsCaptcha: loginForSmsCaptcha, LoginModeForPassword: loginForPassword, } // loginForSmsCaptcha 短信验证码登陆 -func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams, error) { +func loginForSmsCaptcha(params *LoginParams, tenantID uint64) (*InstanceLoginParams, error) { if !utils.ValidateMobile(params.Captcha.Mobile) { return nil, errors.New("操作错误,手机号码格式异常") } @@ -107,7 +107,7 @@ RETURNS: } // loginForPassword 密码登陆 -func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams, error) { +func loginForPassword(params *LoginParams, tenantID uint64) (*InstanceLoginParams, error) { if !utils.ValidateMobile(params.Password.Account) { return nil, errors.New("操作错误,手机号码格式异常") } @@ -156,7 +156,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur if !has { return nil, errors.New("操作错误,未知的登陆模式") } - ret, err := _handle(params, c.local) + ret, err := _handle(params, c.tenantID) if err != nil { return nil, err @@ -168,7 +168,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur } func NewLogin() LoginHandle { - return func(local string) *Login { - return &Login{local: local} + return func(tenantID uint64) *Login { + return &Login{tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/account/register.go b/app/api/enterprise/controller/account/register.go index 1c6fe5f..c518f0e 100644 --- a/app/api/enterprise/controller/account/register.go +++ b/app/api/enterprise/controller/account/register.go @@ -10,9 +10,9 @@ import ( "gorm.io/gorm" ) -type Register struct{ local string } +type Register struct{ tenantID uint64 } -type RegisterHandle func(local string) *Register +type RegisterHandle func(tenantID uint64) *Register type ( RegisterParams struct { @@ -28,7 +28,7 @@ func (c *RegisterParams) checkCaptcha() (bool, error) { return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile}) } -func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, local string) (bool, error) { +func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, tenantID uint64) (bool, error) { var count int64 if err := model2.Count(mUserInstance, &count, model2.NewWhere("mobile", c.Mobile)); //model2.NewWhere("local", local) @@ -55,7 +55,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) // 验证账号信息 mUserInstance := model3.NewUserInstance() - if pass, err = params.checkUserExist(mUserInstance.UserInstance, c.local); err != nil { + if pass, err = params.checkUserExist(mUserInstance.UserInstance, c.tenantID); err != nil { return nil, err } else if !pass { return nil, errors.New("当前手机号码已注册") @@ -84,7 +84,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) } func NewRegister() RegisterHandle { - return func(local string) *Register { - return &Register{local: local} + return func(tenantID uint64) *Register { + return &Register{tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/home/instance.go b/app/api/enterprise/controller/home/instance.go index 8a05d5b..76e14dc 100644 --- a/app/api/enterprise/controller/home/instance.go +++ b/app/api/enterprise/controller/home/instance.go @@ -4,10 +4,10 @@ import "SciencesServer/app/session" type Instance struct { *session.Enterprise - local string + tenantID uint64 } -type InstanceHandle func(session *session.Enterprise, local string) *Instance +type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance type InstanceInfo struct { Currency float64 `json:"currency"` @@ -18,7 +18,7 @@ func (c *Instance) Instance() (*InstanceInfo, error) { } func NewInstance() InstanceHandle { - return func(session *session.Enterprise, local string) *Instance { - return &Instance{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Instance { + return &Instance{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/manage/enterprise.go b/app/api/enterprise/controller/manage/enterprise.go index 0fef0a1..0e849bb 100644 --- a/app/api/enterprise/controller/manage/enterprise.go +++ b/app/api/enterprise/controller/manage/enterprise.go @@ -11,10 +11,10 @@ import ( // Enterprise 企业管理信息 type Enterprise struct { *session.Enterprise - local string + tenantID uint64 } -type EnterpriseHandle func(session *session.Enterprise, local string) *Enterprise +type EnterpriseHandle func(session *session.Enterprise, tenantID uint64) *Enterprise type ( // EnterpriseInfo 企业信息 @@ -40,7 +40,7 @@ func (c *Enterprise) List(mode int, title string, page, pageSize int) (*controll where := []*model2.ModelWhere{ model2.NewWhere("mode", mode), - model2.NewWhere("local", c.local), + //model2.NewWhere("tenant_id", c.tenantID), model2.NewWhere("uid", c.UID), } if title != "" { @@ -98,7 +98,7 @@ func (c *Enterprise) Form(params *EnterpriseParams) error { if mUserCooperateEnterprise.ID > 0 { return model2.Updates(mUserCooperateEnterprise.UserCooperateEnterprise, mUserCooperateEnterprise.UserCooperateEnterprise) } - mUserCooperateEnterprise.Local.Local = c.local + mUserCooperateEnterprise.TenantID = c.tenantID mUserCooperateEnterprise.UID = c.UID return model2.Create(mUserCooperateEnterprise.UserCooperateEnterprise) } @@ -122,7 +122,7 @@ func (c *Enterprise) Delete(id uint64) error { } func NewEnterprise() EnterpriseHandle { - return func(session *session.Enterprise, local string) *Enterprise { - return &Enterprise{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Enterprise { + return &Enterprise{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/service/demand.go b/app/api/enterprise/controller/service/demand.go index 2a2dd4d..e278262 100644 --- a/app/api/enterprise/controller/service/demand.go +++ b/app/api/enterprise/controller/service/demand.go @@ -10,7 +10,7 @@ import ( type Demand struct { *session.Enterprise - local string + tenantID uint64 } type ( @@ -29,7 +29,7 @@ type ( } ) -type DemandHandle func(session *session.Enterprise, local string) *Demand +type DemandHandle func(session *session.Enterprise, tenantID uint64) *Demand // List 列表信息 func (c *Demand) List(title string, status, page, pageSize int) (*controller.ReturnPages, error) { @@ -37,7 +37,7 @@ func (c *Demand) List(title string, status, page, pageSize int) (*controller.Ret where := []*model2.ModelWhereOrder{ &model2.ModelWhereOrder{ - Where: model2.NewWhere("local", c.local), + Where: model2.NewWhere("tenant_id", c.tenantID), Order: model2.NewOrder("id", model2.OrderModeToDesc), }, &model2.ModelWhereOrder{Where: model2.NewWhere("uid", c.UID)}, @@ -116,7 +116,7 @@ func (c *Demand) Form(params *DemandParams) error { return model2.Updates(mServiceDemand.ServiceDemand, mServiceDemand.ServiceDemand) } - mServiceDemand.Local.Local = c.local + mServiceDemand.TenantID = c.tenantID mServiceDemand.UID = c.UID if params.IsSubmit > 0 { @@ -141,10 +141,10 @@ func (c *Demand) Delete(id uint64) error { } func NewDemand() DemandHandle { - return func(session *session.Enterprise, local string) *Demand { + return func(session *session.Enterprise, tenantID uint64) *Demand { return &Demand{ Enterprise: session, - local: local, + tenantID: tenantID, } } } diff --git a/app/api/enterprise/controller/settled/instance.go b/app/api/enterprise/controller/settled/instance.go index 9c35fa0..65ccd1f 100644 --- a/app/api/enterprise/controller/settled/instance.go +++ b/app/api/enterprise/controller/settled/instance.go @@ -10,10 +10,10 @@ import ( // Instance 首页信息 type Instance struct { *session.Enterprise - local string + tenantID uint64 } -type InstanceHandle func(session *session.Enterprise, local string) *Instance +type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance type InstanceInfo struct { Identity int `json:"identity"` // 所有身份 @@ -97,7 +97,7 @@ func (c *Instance) Index() (*InstanceInfo, error) { } func NewInstance() InstanceHandle { - return func(session *session.Enterprise, local string) *Instance { - return &Instance{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Instance { + return &Instance{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/achievement.go b/app/api/enterprise/controller/technology/achievement.go index 476af11..01ec7de 100644 --- a/app/api/enterprise/controller/technology/achievement.go +++ b/app/api/enterprise/controller/technology/achievement.go @@ -15,10 +15,10 @@ import ( // Achievement 成果信息 type Achievement struct { *session.Enterprise - local string + tenantID uint64 } -type AchievementHandle func(session *session.Enterprise, local string) *Achievement +type AchievementHandle func(session *session.Enterprise, tenantID uint64) *Achievement type ( // AchievementInfo 成果信息 @@ -183,7 +183,7 @@ func (c *Achievement) Form(params *AchievementParams) error { mTechnologyAchievement.Status = model2.TechnologyAchievementStatusForExamining return model2.Updates(mTechnologyAchievement.TechnologyAchievement, mTechnologyAchievement.TechnologyAchievement) } - mTechnologyAchievement.Local.Local = c.local + mTechnologyAchievement.TenantID = c.tenantID mTechnologyAchievement.UID = c.UID if params.IsSubmit > 0 { @@ -231,10 +231,10 @@ func (c *Achievement) Delete(id uint64) error { } func NewAchievement() AchievementHandle { - return func(session *session.Enterprise, local string) *Achievement { + return func(session *session.Enterprise, tenantID uint64) *Achievement { return &Achievement{ Enterprise: session, - local: local, + tenantID: tenantID, } } } diff --git a/app/api/enterprise/controller/technology/demand.go b/app/api/enterprise/controller/technology/demand.go index d319ba2..961827f 100644 --- a/app/api/enterprise/controller/technology/demand.go +++ b/app/api/enterprise/controller/technology/demand.go @@ -13,10 +13,10 @@ import ( // Demand 技术需求管理 type Demand struct { *session.Enterprise - local string + tenantID uint64 } -type DemandHandle func(session *session.Enterprise, local string) *Demand +type DemandHandle func(session *session.Enterprise, tenantID uint64) *Demand type ( // DemandInfo 需求信息 @@ -149,7 +149,7 @@ func (c *Demand) Form(params *DemandParams) error { return model2.Updates(mTechnologyDemand.TechnologyDemand, mTechnologyDemand.TechnologyDemand) } mTechnologyDemand.UID = c.UID - mTechnologyDemand.Local.Local = c.local + mTechnologyDemand.TenantID = c.tenantID if params.IsSubmit > 0 { mTechnologyDemand.Status = model2.TechnologyDemandStatusForExamining @@ -178,7 +178,7 @@ func (c *Demand) Delete(id uint64) error { } func NewDemand() DemandHandle { - return func(session *session.Enterprise, local string) *Demand { - return &Demand{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Demand { + return &Demand{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/instance.go b/app/api/enterprise/controller/technology/instance.go index caec401..17d1f21 100644 --- a/app/api/enterprise/controller/technology/instance.go +++ b/app/api/enterprise/controller/technology/instance.go @@ -13,10 +13,10 @@ import ( // Instance 技术管理 type Instance struct { *session.Enterprise - local string + tenantID uint64 } -type InstanceHandle func(session *session.Enterprise, local string) *Instance +type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance type ( // InstanceInfo 详细信息 @@ -108,7 +108,7 @@ func (c *Instance) Form(params *InstanceParams) error { return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance) } mTechnologyInstance.UID = c.UID - mTechnologyInstance.Local.Local = c.local + mTechnologyInstance.TenantID = c.tenantID if params.IsSubmit > 0 { mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining @@ -161,7 +161,7 @@ func (c *Instance) Delete(id uint64) error { } func NewInstance() InstanceHandle { - return func(session *session.Enterprise, local string) *Instance { - return &Instance{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Instance { + return &Instance{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/paper.go b/app/api/enterprise/controller/technology/paper.go index ecd791d..7eaf8b0 100644 --- a/app/api/enterprise/controller/technology/paper.go +++ b/app/api/enterprise/controller/technology/paper.go @@ -13,10 +13,10 @@ import ( // Paper 论文管理 type Paper struct { *session.Enterprise - local string + tenantID uint64 } -type PaperHandle func(session *session.Enterprise, local string) *Paper +type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper type ( PaperInfo struct { @@ -38,7 +38,7 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages, where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{ Order: model2.NewOrder("id", model2.OrderModeToDesc), }, &model2.ModelWhereOrder{ - Where: model2.NewWhere("local", c.local), + Where: model2.NewWhere("tenant_id", c.tenantID), }} if title != "" { where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)}) @@ -83,7 +83,7 @@ func (c *Paper) Form(params *PaperParams) error { if params.ID <= 0 { mTechnologyPaper.UID = c.UID - mTechnologyPaper.Local.Local = c.local + mTechnologyPaper.TenantID = c.tenantID return model2.Create(mTechnologyPaper.TechnologyPaper) } mTechnologyPaper.UpdatedAt = time.Now() @@ -111,7 +111,7 @@ func (c *Paper) Delete(id uint64) error { } func NewPaper() PaperHandle { - return func(session *session.Enterprise, local string) *Paper { - return &Paper{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Paper { + return &Paper{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/patent.go b/app/api/enterprise/controller/technology/patent.go index 2e46eff..caa942f 100644 --- a/app/api/enterprise/controller/technology/patent.go +++ b/app/api/enterprise/controller/technology/patent.go @@ -17,10 +17,10 @@ import ( // Patent 专利管理 type Patent struct { *session.Enterprise - local string + tenantID uint64 } -type PatentHandle func(session *session.Enterprise, local string) *Patent +type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent type ( // PatentInfo 专利信息 @@ -55,7 +55,7 @@ type ( ) // add 新增专利信息 -func (c *PatentParams) add(uid uint64) error { +func (c *PatentParams) add(tenantID, uid uint64) error { mSysPatent := model.NewSysPatent() isExist, err := mSysPatent.IsExistParams(map[string]interface{}{ "apply_code": c.ApplyCode, "open_code": c.OpenCode, @@ -67,6 +67,7 @@ func (c *PatentParams) add(uid uint64) error { } return orm.GetDB().Transaction(func(tx *gorm.DB) error { mSysPatent.Kind = model2.SysParentKind(c.Kind) + mSysPatent.TenantID = tenantID mSysPatent.Title = c.Title mSysPatent.FileUrl = c.FileUrl mSysPatent.ApplyCode = c.ApplyCode @@ -258,7 +259,7 @@ func (c *Patent) Form(params *PatentParams) error { if params.ID > 0 { return params.edit(c.UID) } - return params.add(c.UID) + return params.add(c.tenantID, c.UID) } @@ -310,7 +311,7 @@ func (c *Patent) Delete(id uint64) error { } func NewPatent() PatentHandle { - return func(session *session.Enterprise, local string) *Patent { - return &Patent{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Patent { + return &Patent{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/product.go b/app/api/enterprise/controller/technology/product.go index 1faaf98..4e98347 100644 --- a/app/api/enterprise/controller/technology/product.go +++ b/app/api/enterprise/controller/technology/product.go @@ -15,10 +15,10 @@ import ( // Product 产品信息 type Product struct { *session.Enterprise - local string + tenantID uint64 } -type ProductHandle func(session *session.Enterprise, local string) *Product +type ProductHandle func(session *session.Enterprise, tenantID uint64) *Product type ( // ProductInfo 产品信息 @@ -205,7 +205,7 @@ func (c *Product) Form(params *ProductParams) error { mTechnologyProduct.Status = model2.TechnologyProductStatusForExamining return model2.Updates(mTechnologyProduct.TechnologyProduct, mTechnologyProduct.TechnologyProduct) } - mTechnologyProduct.Local.Local = c.local + mTechnologyProduct.TenantID = c.tenantID mTechnologyProduct.UID = c.UID if params.IsSubmit > 0 { @@ -253,10 +253,10 @@ func (c *Product) Delete(id uint64) error { } func NewProduct() ProductHandle { - return func(session *session.Enterprise, local string) *Product { + return func(session *session.Enterprise, tenantID uint64) *Product { return &Product{ Enterprise: session, - local: local, + tenantID: tenantID, } } } diff --git a/app/api/enterprise/controller/technology/project.go b/app/api/enterprise/controller/technology/project.go index 4434b48..bd92799 100644 --- a/app/api/enterprise/controller/technology/project.go +++ b/app/api/enterprise/controller/technology/project.go @@ -13,10 +13,10 @@ import ( // Project 项目列表 type Project struct { *session.Enterprise - local string + tenantID uint64 } -type ProjectHandle func(session *session.Enterprise, local string) *Project +type ProjectHandle func(session *session.Enterprise, tenantID uint64) *Project type ( // ProjectInfo 产品信息 @@ -90,7 +90,7 @@ func (c *Project) Form(params *ProjectParams) error { if mTechnologyProject.ID > 0 { return model2.Updates(mTechnologyProject.TechnologyProject, mTechnologyProject.TechnologyProject) } - mTechnologyProject.Local.Local = c.local + mTechnologyProject.TenantID = c.tenantID mTechnologyProject.UID = c.UID return model2.Create(mTechnologyProject.TechnologyProject) } @@ -135,7 +135,7 @@ func (c *Project) Delete(id uint64) error { } func NewProject() ProjectHandle { - return func(session *session.Enterprise, local string) *Project { - return &Project{Enterprise: session, local: local} + return func(session *session.Enterprise, tenantID uint64) *Project { + return &Project{Enterprise: session, tenantID: tenantID} } } diff --git a/app/api/enterprise/controller/technology/topic.go b/app/api/enterprise/controller/technology/topic.go index addc66c..87168de 100644 --- a/app/api/enterprise/controller/technology/topic.go +++ b/app/api/enterprise/controller/technology/topic.go @@ -12,10 +12,10 @@ import ( type Topic struct { *session.Enterprise - local string + tenantID uint64 } -type TopicHandle func(session *session.Enterprise, local string) *Topic +type TopicHandle func(session *session.Enterprise, tenantID uint64) *Topic type ( // TopicInfo 课题信息 @@ -122,7 +122,7 @@ func (c *Topic) Form(params *TopicParams) error { mTechnologyTopic.UpdatedAt = time.Now() return model2.Updates(mTechnologyTopic.TechnologyTopic, mTechnologyTopic.TechnologyTopic) } - mTechnologyTopic.Local.Local = c.local + mTechnologyTopic.TenantID = c.tenantID mTechnologyTopic.UID = c.UID return model2.Create(mTechnologyTopic.TechnologyTopic) } @@ -145,10 +145,10 @@ func (c *Topic) Delete(id uint64) error { } func NewTopic() TopicHandle { - return func(session *session.Enterprise, local string) *Topic { + return func(session *session.Enterprise, tenantID uint64) *Topic { return &Topic{ Enterprise: session, - local: local, + tenantID: tenantID, } } } diff --git a/app/common/model/common.go b/app/common/model/common.go index 87ca493..365345f 100644 --- a/app/common/model/common.go +++ b/app/common/model/common.go @@ -54,10 +54,6 @@ func (m *Images) AnalysisSlice(domain string) string { return strings.Join(images, ",") } -type Local struct { - Local string `gorm:"column:local;type:varchar(8);default:'';comment:数据位置来源" json:"-"` -} - // AccountStatus 账号状态 type AccountStatus struct { Status AccountStatusKind `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:启用,2:禁用)" json:"-"` diff --git a/app/common/model/service_demand.go b/app/common/model/service_demand.go index 15be18f..ed95303 100644 --- a/app/common/model/service_demand.go +++ b/app/common/model/service_demand.go @@ -5,7 +5,7 @@ import "encoding/json" // ServiceDemand 服务需求数据模型 type ServiceDemand struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Kind string `gorm:"column:kind;type:varchar(50);default:'';comment:需求类型" json:"kind"` Title string `gorm:"column:title;type:varchar(50);default:'';comment:需求名称" json:"title"` diff --git a/app/common/model/technology_achievement.go b/app/common/model/technology_achievement.go index a8ed695..c3e53f3 100644 --- a/app/common/model/technology_achievement.go +++ b/app/common/model/technology_achievement.go @@ -8,7 +8,7 @@ import ( // TechnologyAchievement 技术成果数据模型 type TechnologyAchievement struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Mode TechnologyAchievementMode `gorm:"column:mode;type:tinyint(1);default:1;comment:成果模式" json:"mode"` Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"` diff --git a/app/common/model/technology_demand.go b/app/common/model/technology_demand.go index 9e1c0cf..9d2ac43 100644 --- a/app/common/model/technology_demand.go +++ b/app/common/model/technology_demand.go @@ -9,7 +9,7 @@ import ( // TechnologyDemand 技术需求数据模型 type TechnologyDemand struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Title string `gorm:"column:title;type:varchar(50);default:'';comment:需求名称" json:"title"` Kind string `gorm:"column:kind;type:varchar(50);default:'';comment:需求类别" json:"-"` diff --git a/app/common/model/technology_instance.go b/app/common/model/technology_instance.go index 6f88ba5..c1484c0 100644 --- a/app/common/model/technology_instance.go +++ b/app/common/model/technology_instance.go @@ -8,7 +8,7 @@ import ( // TechnologyInstance 技术文档数据模型 type TechnologyInstance struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` PatentID uint64 `gorm:"column:patent_id;type:int;default:0;comment:代表专利" json:"patent_id"` Title string `gorm:"column:title;type:varchar(30);default:'';comment:名称" json:"title"` diff --git a/app/common/model/technology_prodcut.go b/app/common/model/technology_prodcut.go index 58d5741..f45508e 100644 --- a/app/common/model/technology_prodcut.go +++ b/app/common/model/technology_prodcut.go @@ -8,7 +8,7 @@ import ( // TechnologyProduct 技术产品数据模型 type TechnologyProduct struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Title string `gorm:"column:title;type:varchar(100);default:'';comment:产品名称" json:"title"` Image diff --git a/app/common/model/technology_project.go b/app/common/model/technology_project.go index 76a7d63..c3c9ad4 100644 --- a/app/common/model/technology_project.go +++ b/app/common/model/technology_project.go @@ -5,7 +5,7 @@ import "time" // TechnologyProject 技术科研项目数据模型 type TechnologyProject struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Kind string `gorm:"column:kind;type:varchar(100);default:'';comment:类型" json:"kind"` Role TechnologyProjectRole `gorm:"column:role;type:tinyint(1);default:1;comment:课题角色(1:承担单位,2:参与单位)" json:"role"` diff --git a/app/common/model/technology_topic.go b/app/common/model/technology_topic.go index 09cd6d8..bd6390a 100644 --- a/app/common/model/technology_topic.go +++ b/app/common/model/technology_topic.go @@ -8,7 +8,7 @@ import ( // TechnologyTopic 技术课题数据模型 type TechnologyTopic struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Title string `gorm:"column:title;type:varchar(100);default:'';comment:名称" json:"title"` Code string `gorm:"column:code;type:varchar(30);default:'';comment:编号" json:"code"` diff --git a/app/common/model/user_cooperate_enterprise.go b/app/common/model/user_cooperate_enterprise.go index c3c8af5..a7b1961 100644 --- a/app/common/model/user_cooperate_enterprise.go +++ b/app/common/model/user_cooperate_enterprise.go @@ -9,7 +9,7 @@ import ( // UserCooperateEnterprise 用户企业数据模型管理 type UserCooperateEnterprise struct { Model - Local + ModelTenant UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` Mode UserCooperateEnterpriseMode `gorm:"column:mode;type:int;default:0;comment:合作模式(1:已合作,2:想合作)" json:"mode"` Title string `gorm:"column:title;type:varchar(30);default:'';comment:企业名称" json:"title"`