feat:完善项目信息
This commit is contained in:
@ -121,7 +121,6 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
}
|
||||
mManageCompany.Product = other.Product
|
||||
mManageCompany.Url = other.Url
|
||||
mManageCompany.License = other.FilterLicense()
|
||||
mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.SetDirectionAttribute(other.Directions)
|
||||
@ -136,6 +135,7 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
// 查询手机号码是否在当前租户下是否已经注册了
|
||||
mManageCompany.Name = params.Name
|
||||
mManageCompany.Code = params.Code
|
||||
mManageCompany.License = other.FilterLicense()
|
||||
|
||||
if isExist, err := params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
|
204
app/api/admin/controller/manage/laboratory.go
Normal file
204
app/api/admin/controller/manage/laboratory.go
Normal file
@ -0,0 +1,204 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Laboratory 实验室信息
|
||||
type Laboratory struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type LaboratoryHandle func(session *session.Admin) *Laboratory
|
||||
|
||||
type (
|
||||
// LaboratoryInstance 实验室信息
|
||||
LaboratoryInstance struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageLaboratoryInfo
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// LaboratorySelect 实验室筛选信息
|
||||
LaboratorySelect struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
// LaboratoryDetail 实验室详细信息
|
||||
LaboratoryDetail struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ManageLaboratory
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Laboratory) Instance(tenantID uint64, name string, examineStatus, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("l.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("l.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("l.name", name))
|
||||
}
|
||||
if examineStatus > 0 {
|
||||
where = append(where, model2.NewWhere("l.examine_status", examineStatus))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageLaboratory.Laboratorys(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*LaboratoryInstance, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Address = v.FormatBasic()
|
||||
|
||||
list = append(list, &LaboratoryInstance{
|
||||
ID: v.GetEncodeID(), ManageLaboratoryInfo: v, Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Laboratory) Select(tenantID, researchID uint64) ([]*LaboratorySelect, error) {
|
||||
if tenantID <= 0 {
|
||||
tenantID = c.TenantID
|
||||
}
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out := make([]*model2.ManageResearch, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", tenantID)},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)},
|
||||
}
|
||||
|
||||
if researchID > 0 {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("research_id", tenantID)})
|
||||
}
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*LaboratorySelect, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &LaboratorySelect{
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
if params.ID > 0 {
|
||||
mManageLaboratory.ID = params.ID
|
||||
isExist, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "name", "code", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,实验室信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 {
|
||||
if mManageLaboratory.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} else {
|
||||
if mManageLaboratory.TenantID != params.TenantID {
|
||||
if isExist, err = params.isExist(mManageLaboratory.ManageLaboratory, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一实验室机构代码")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageLaboratory.TenantID = c.TenantID
|
||||
mManageLaboratory.ResearchID = other.ConvertResearch()
|
||||
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,
|
||||
}
|
||||
mManageLaboratory.Url = other.Url
|
||||
mManageLaboratory.SetIndustryAttribute(params.Industrys)
|
||||
mManageLaboratory.SetKeywordAttribute(params.Keywords)
|
||||
mManageLaboratory.SetResearchAttribute(other.Researchs)
|
||||
mManageLaboratory.Introduce = params.Introduce
|
||||
|
||||
if c.TenantID <= 0 {
|
||||
mManageLaboratory.TenantID = params.TenantID
|
||||
}
|
||||
if mManageLaboratory.ID > 0 {
|
||||
return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
mManageLaboratory.Name = params.Name
|
||||
mManageLaboratory.Code = params.Code
|
||||
|
||||
if isExist, err := params.isExist(mManageLaboratory.ManageLaboratory, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一实验室机构代码")
|
||||
}
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Laboratory) Detail(id uint64) (*LaboratoryDetail, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
out, err := mManageLaboratory.Laboratory(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.ManageLaboratory == nil {
|
||||
return nil, errors.New("操作错误,实验室信息不存在或已被删除")
|
||||
}
|
||||
return &LaboratoryDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
TenantID: out.GetEncodeTenantID(),
|
||||
ManageLaboratory: out.ManageLaboratory,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
Area: out.FormatBasic(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewLaboratory() LaboratoryHandle {
|
||||
return func(session *session.Admin) *Laboratory {
|
||||
return &Laboratory{session}
|
||||
}
|
||||
}
|
@ -2,12 +2,14 @@ package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Research 研究机构
|
||||
type Research struct {
|
||||
*session.Admin
|
||||
}
|
||||
@ -100,8 +102,63 @@ func (c *Research) Select(tenantID uint64) ([]*ResearchSelect, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (c *Research) Form() {
|
||||
// Form 数据操作
|
||||
func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
if params.ID > 0 {
|
||||
mManageResearch.ID = params.ID
|
||||
isExist, err := model2.FirstField(mManageResearch.ManageResearch, []string{"id", "name", "code", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,研究机构信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 {
|
||||
if mManageResearch.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} else {
|
||||
if mManageResearch.TenantID != params.TenantID {
|
||||
if isExist, err = params.isExist(mManageResearch.ManageResearch, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一研究机构代码")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageResearch.TenantID = c.TenantID
|
||||
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,
|
||||
}
|
||||
mManageResearch.SetIndustryAttribute(params.Industrys)
|
||||
mManageResearch.SetKeywordAttribute(params.Keywords)
|
||||
mManageResearch.SetResearchAttribute(other.Researchs)
|
||||
mManageResearch.Introduce = params.Introduce
|
||||
|
||||
if c.TenantID <= 0 {
|
||||
mManageResearch.TenantID = params.TenantID
|
||||
}
|
||||
if mManageResearch.ID > 0 {
|
||||
return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
|
||||
}
|
||||
mManageResearch.Name = params.Name
|
||||
mManageResearch.Code = params.Code
|
||||
mManageResearch.License = other.FilterLicense()
|
||||
|
||||
if isExist, err := params.isExist(mManageResearch.ManageResearch, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一研究机构代码")
|
||||
}
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
|
Reference in New Issue
Block a user