feat:优化项目信息
This commit is contained in:
@ -81,7 +81,7 @@ func loginForPassword(params *AccountLoginParams, tenantID uint64) (*loginHandle
|
||||
|
||||
// loginForSmsCaptcha 短信验证码登陆
|
||||
func loginForSmsCaptcha(params *AccountLoginParams, tenantID uint64) (*loginHandleReturn, error) {
|
||||
if params.Password == "" {
|
||||
if params.Captcha == "" {
|
||||
return nil, errors.New("操作错误,验证码不可为空")
|
||||
}
|
||||
// 验证验证码
|
||||
|
@ -151,6 +151,7 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
if mManageCompany.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
_ = manage.Update()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// 查询手机号码是否在当前租户下是否已经注册了
|
||||
mManageCompany.Name = params.Name
|
||||
|
@ -5,9 +5,11 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Laboratory 实验室信息
|
||||
@ -22,7 +24,9 @@ type (
|
||||
LaboratoryInstance struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageLaboratoryInfo
|
||||
Area string `json:"area"`
|
||||
Area string `json:"area"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Researchs []string `json:"researchs"`
|
||||
}
|
||||
// LaboratorySelect 实验室筛选信息
|
||||
LaboratorySelect struct {
|
||||
@ -34,10 +38,10 @@ type (
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ManageLaboratory
|
||||
Industrys []*config.Industry `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
Area string `json:"area"`
|
||||
ResearchID string `json:"research_id"`
|
||||
Industrys []*config.Industry `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -69,13 +73,23 @@ func (c *Laboratory) Instance(tenantID uint64, name string, examineStatus, page,
|
||||
list := make([]*LaboratoryInstance, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mManageLaboratory.Industry = v.Industry
|
||||
mManageLaboratory.Research = v.Research
|
||||
v.Address = v.FormatBasic()
|
||||
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mManageLaboratory.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", ">").Value)
|
||||
}
|
||||
|
||||
list = append(list, &LaboratoryInstance{
|
||||
ID: v.GetEncodeID(), ManageLaboratoryInfo: v, Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
Industrys: _industrys,
|
||||
Researchs: mManageLaboratory.GetResearchAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
@ -158,8 +172,25 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
||||
if c.TenantID <= 0 {
|
||||
mManageLaboratory.TenantID = params.TenantID
|
||||
}
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range params.Industrys {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||
}
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForLaboratory),
|
||||
service.WithManageIndustry(strings.Join(_industrys, ";")),
|
||||
service.WithManageKeyword(strings.Join(params.Keywords, ";")),
|
||||
service.WithManageResearch(strings.Join(other.Researchs, ";")),
|
||||
)
|
||||
if mManageLaboratory.ID > 0 {
|
||||
return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
|
||||
if err := model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory); err != nil {
|
||||
return err
|
||||
}
|
||||
if mManageLaboratory.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
_ = manage.Update()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
mManageLaboratory.Name = params.Name
|
||||
mManageLaboratory.Code = params.Code
|
||||
@ -172,7 +203,13 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在同一实验室机构代码")
|
||||
}
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
if err := model2.Create(mManageLaboratory.ManageLaboratory); err != nil {
|
||||
return err
|
||||
}
|
||||
service.WithManageID(mManageLaboratory.ID)(manage)
|
||||
service.WithManageTitle(params.Name)(manage)
|
||||
|
||||
return manage.Create()
|
||||
|
||||
}
|
||||
|
||||
@ -197,6 +234,7 @@ func (c *Laboratory) Detail(id uint64) (*LaboratoryDetail, error) {
|
||||
return &LaboratoryDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
TenantID: out.GetEncodeTenantID(),
|
||||
ResearchID: (&model2.Model{ID: out.ResearchID}).GetEncodeID(),
|
||||
ManageLaboratory: out.ManageLaboratory,
|
||||
Industrys: _industrys,
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
|
@ -5,9 +5,11 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Research 研究机构
|
||||
@ -165,8 +167,26 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
||||
if c.TenantID <= 0 {
|
||||
mManageResearch.TenantID = params.TenantID
|
||||
}
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range params.Industrys {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||
}
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForResearch),
|
||||
service.WithManageIndustry(strings.Join(_industrys, ";")),
|
||||
service.WithManageKeyword(strings.Join(params.Keywords, ";")),
|
||||
service.WithManageResearch(strings.Join(other.Researchs, ";")),
|
||||
)
|
||||
|
||||
if mManageResearch.ID > 0 {
|
||||
return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
|
||||
if err := model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch); err != nil {
|
||||
return err
|
||||
}
|
||||
if mManageResearch.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
_ = manage.Update()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
mManageResearch.Name = params.Name
|
||||
mManageResearch.Code = params.Code
|
||||
@ -179,7 +199,13 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在同一研究机构代码")
|
||||
}
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
if err := model2.Create(mManageResearch.ManageResearch); err != nil {
|
||||
return err
|
||||
}
|
||||
service.WithManageID(mManageResearch.ID)(manage)
|
||||
service.WithManageTitle(params.Name)(manage)
|
||||
return manage.Create()
|
||||
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
|
@ -17,9 +17,11 @@ type (
|
||||
model.Model
|
||||
Name string `json:"name"`
|
||||
Industry string `json:"industry"`
|
||||
Research string `json:"research"`
|
||||
ResearchName string `json:"research_name"`
|
||||
model.Image
|
||||
model.Area
|
||||
model.Examine
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
TenantProvince string `json:"-"`
|
||||
TenantCity string `json:"-"`
|
||||
@ -27,7 +29,6 @@ type (
|
||||
// ManageLaboratoryDetail 实验室详细信息
|
||||
ManageLaboratoryDetail struct {
|
||||
*model.ManageLaboratory
|
||||
model.Area
|
||||
}
|
||||
)
|
||||
|
||||
@ -48,12 +49,12 @@ func (m *ManageLaboratory) Laboratory(id uint64) (*ManageLaboratoryDetail, error
|
||||
// Laboratorys 实验室信息
|
||||
func (m *ManageLaboratory) Laboratorys(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageLaboratoryInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS l").
|
||||
Select("l.id", "l.name", "l.industry", "l.name AS research_name", "l.image",
|
||||
Select("l.id", "l.name", "l.industry", "l.research", "r.name AS research_name", "l.image", "l.examine_status",
|
||||
"l.province", "l.city", "l.created_at",
|
||||
"t.province AS tenant_province", "t.city AS tenant_city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON l.research_id = r.id", model.NewManageResearch().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON l.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("e.is_deleted = ?", model.DeleteStatusForNot)
|
||||
Where("l.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
|
Reference in New Issue
Block a user