feat:完善项目信息

This commit is contained in:
henry
2022-01-19 14:22:44 +08:00
parent 61d345b571
commit 417d7961ec
9 changed files with 128 additions and 25 deletions

View File

@ -71,6 +71,19 @@ func (*Manage) CompanyDetail(c *gin.Context) {
api.APIResponse(err, data)(c) api.APIResponse(err, data)(c)
} }
func (*Manage) CompanyForm(c *gin.Context) {
form := &struct {
manageForm
config.IdentityForCompany
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := manage.NewCompany()(api.GetSession()(c).(*session.Admin)).Form(form.bind(), &form.IdentityForCompany)
api.APIResponse(err)(c)
}
func (*Manage) CompanyExamine(c *gin.Context) { func (*Manage) CompanyExamine(c *gin.Context) {
form := &struct { form := &struct {
manageExamineForm manageExamineForm

View File

@ -1,6 +1,9 @@
package manage package manage
import "SciencesServer/app/basic/config" import (
"SciencesServer/app/basic/config"
model2 "SciencesServer/app/common/model"
)
// BasicParams 基本信息 // BasicParams 基本信息
type BasicParams struct { type BasicParams struct {
@ -9,3 +12,11 @@ type BasicParams struct {
config.Area config.Area
Industrys, Keywords []string Industrys, Keywords []string
} }
func (c *BasicParams) isExist(iModel model2.IModel, where ...*model2.ModelWhere) (bool, error) {
var count int64
err := model2.Count(iModel, &count, where...)
return count > 0, err
}

View File

@ -2,6 +2,7 @@ package manage
import ( import (
"SciencesServer/app/api/admin/model" "SciencesServer/app/api/admin/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller" "SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model" model2 "SciencesServer/app/common/model"
"SciencesServer/app/session" "SciencesServer/app/session"
@ -75,8 +76,64 @@ func (c *Company) Instance(tenantID uint64, name string, status int, page, pageS
} }
// Form 数据操作 // Form 数据操作
func (c *Company) Form(params *CompanyParams) error { func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) error {
return nil mManageCompany := model.NewManageCompany()
// 查询相应的企业入驻信息
if params.ID > 0 {
mManageCompany.ID = params.ID
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "name", "code", "tenant_id", "created_at"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,公司企业信息不存在或已被删除")
}
if c.TenantID > 0 {
if mManageCompany.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
}
} else {
if mManageCompany.TenantID != params.TenantID {
if isExist, err = params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("code", params.Code)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
}
}
}
}
mManageCompany.TenantID = c.TenantID
mManageCompany.Image = model2.Image{Image: params.Image}
mManageCompany.Area = model2.Area{
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
}
mManageCompany.Product = other.Product
mManageCompany.Url = other.Url
mManageCompany.License = other.License
mManageCompany.SetIndustryAttribute(params.Industrys)
mManageCompany.SetKeywordAttribute(params.Keywords)
mManageCompany.SetDirectionAttribute(other.Directions)
mManageCompany.Introduce = params.Introduce
if c.TenantID <= 0 {
mManageCompany.TenantID = params.TenantID
}
if mManageCompany.ID > 0 {
return model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany)
}
// 查询手机号码是否在当前租户下是否已经注册了
mManageCompany.Name = params.Name
mManageCompany.Code = params.Code
if isExist, err := params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("code", params.Code)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
}
return model2.Create(mManageCompany.ManageCompany)
} }
// Detail 详细信息 // Detail 详细信息

View File

@ -40,10 +40,6 @@ type (
Researchs []string `json:"researchs"` Researchs []string `json:"researchs"`
Area string `json:"area"` Area string `json:"area"`
} }
// ExpertParams 专家参数信息
ExpertParams struct {
ID, TenantID uint64
}
) )
// Instance 首页信息 // Instance 首页信息
@ -89,7 +85,7 @@ func (c *Expert) Instance(tenantID uint64, name string, examineStatus int, page,
} }
// Detail 详细信息 // Detail 详细信息
func (*Expert) Detail(id uint64) (*ExpertDetail, error) { func (c *Expert) Detail(id uint64) (*ExpertDetail, error) {
mManageExpert := model.NewManageExpert() mManageExpert := model.NewManageExpert()
out, err := mManageExpert.Expert(id) out, err := mManageExpert.Expert(id)
@ -110,27 +106,42 @@ func (*Expert) Detail(id uint64) (*ExpertDetail, error) {
} }
// Form 数据操作 // Form 数据操作
func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error { func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) error {
mManageExpert := model.NewManageExpert() mManageExpert := model.NewManageExpert()
if params.ID > 0 { if params.ID > 0 {
mManageExpert.ID = params.ID mManageExpert.ID = params.ID
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "examine_status", "created_at"}) isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "name", "mobile", "tenant_id", "created_at"})
if err != nil { if err != nil {
return err return err
} else if !isExist { } else if !isExist {
return errors.New("操作错误,专家信息不存在或已被删除") return errors.New("操作错误,专家信息不存在或已被删除")
} }
if c.TenantID > 0 {
if mManageExpert.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
} }
mManageExpert.TenantID = params.TenantID } else {
if mManageExpert.TenantID != params.TenantID {
if isExist, err = params.isExist(mManageExpert.ManageExpert, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("mobile", params.Mobile)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在相同手机号码")
}
}
}
}
mManageExpert.TenantID = c.TenantID
mManageExpert.ResearchID = other.ConvertResearch() mManageExpert.ResearchID = other.ConvertResearch()
mManageExpert.LaboratoryID = other.ConvertLaboratory() mManageExpert.LaboratoryID = other.ConvertLaboratory()
mManageExpert.Image.Image = params.Image mManageExpert.Image.Image = params.Image
mManageExpert.Area = model2.Area{ mManageExpert.Area = model2.Area{
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
} }
mManageExpert.Education = other.Education
mManageExpert.School = other.School mManageExpert.School = other.School
mManageExpert.Major = other.Major mManageExpert.Major = other.Major
mManageExpert.Job = other.Job mManageExpert.Job = other.Job
@ -142,12 +153,22 @@ func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error
mManageExpert.SetResearchAttribute(other.Researchs) mManageExpert.SetResearchAttribute(other.Researchs)
mManageExpert.Introduce = params.Introduce mManageExpert.Introduce = params.Introduce
if c.TenantID <= 0 {
mManageExpert.TenantID = params.TenantID
}
if mManageExpert.ID > 0 { if mManageExpert.ID > 0 {
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert) return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
} }
// 查询手机号码是否在当前租户下是否已经注册了
mManageExpert.Name = params.Name mManageExpert.Name = params.Name
mManageExpert.Mobile = params.Mobile mManageExpert.Mobile = params.Mobile
if isExist, err := params.isExist(mManageExpert.ManageExpert, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("mobile", params.Mobile)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在相同手机号码")
}
return model2.Create(mManageExpert.ManageExpert) return model2.Create(mManageExpert.ManageExpert)
} }

View File

@ -130,6 +130,7 @@ func (c *Innovate) Form(params *InnovateParams) error {
return errors.New("操作错误,无权限操作") return errors.New("操作错误,无权限操作")
} }
} }
mServiceInnovate.TenantID = c.TenantID
mServiceInnovate.KindID = params.KindID mServiceInnovate.KindID = params.KindID
mServiceInnovate.Title = params.Title mServiceInnovate.Title = params.Title
mServiceInnovate.Description = params.Description mServiceInnovate.Description = params.Description
@ -137,17 +138,12 @@ func (c *Innovate) Form(params *InnovateParams) error {
mServiceInnovate.SetTagAttribute(params.Tags) mServiceInnovate.SetTagAttribute(params.Tags)
mServiceInnovate.Sort = params.Sort mServiceInnovate.Sort = params.Sort
if mServiceInnovate.ID > 0 {
if c.TenantID <= 0 { if c.TenantID <= 0 {
mServiceInnovate.TenantID = params.TenantID mServiceInnovate.TenantID = params.TenantID
} }
if mServiceInnovate.ID > 0 {
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate) return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
} }
mServiceInnovate.TenantID = params.TenantID
if c.TenantID > 0 {
mServiceInnovate.TenantID = c.TenantID
}
return model2.Create(mServiceInnovate.ServiceInnovate) return model2.Create(mServiceInnovate.ServiceInnovate)
} }

View File

@ -59,6 +59,7 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address, Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
} }
//mManageExpert.Position = params.Mobile //mManageExpert.Position = params.Mobile
mManageExpert.Education = other.Education
mManageExpert.School = other.School mManageExpert.School = other.School
mManageExpert.Major = other.Major mManageExpert.Major = other.Major
mManageExpert.Job = other.Job mManageExpert.Job = other.Job

View File

@ -23,6 +23,7 @@ type (
IdentityForExpert struct { IdentityForExpert struct {
ResearchID string `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID ResearchID string `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID
LaboratoryID string `json:"laboratory_id" form:"laboratory_id"` // 实验室ID LaboratoryID string `json:"laboratory_id" form:"laboratory_id"` // 实验室ID
Education string `json:"education" form:"education"` // 学历
School string `json:"school" form:"school"` // 毕业院校 School string `json:"school" form:"school"` // 毕业院校
Major string `json:"major" form:"major"` // 专业 Major string `json:"major" form:"major"` // 专业
Job string `json:"job" form:"job"` // 职务 Job string `json:"job" form:"job"` // 职务

View File

@ -16,6 +16,7 @@ type ManageExpert struct {
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:专家联系方式" json:"mobile"` Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:专家联系方式" json:"mobile"`
Area Area
Position string `gorm:"column:position;type:varchar(50);default:'';comment:坐标" json:"-"` Position string `gorm:"column:position;type:varchar(50);default:'';comment:坐标" json:"-"`
Education string `gorm:"column:education;type:varchar(50);default:'';comment:学历" json:"education"`
School string `gorm:"column:school;type:varchar(50);default:'';comment:院校" json:"school"` School string `gorm:"column:school;type:varchar(50);default:'';comment:院校" json:"school"`
Major string `gorm:"column:major;type:varchar(50);default:'';comment:专业" json:"major"` Major string `gorm:"column:major;type:varchar(50);default:'';comment:专业" json:"major"`
Job string `gorm:"column:job;type:varchar(50);default:'';comment:职务" json:"job"` Job string `gorm:"column:job;type:varchar(50);default:'';comment:职务" json:"job"`

View File

@ -286,6 +286,8 @@ func registerAdminAPI(app *gin.Engine) {
{ {
_api := new(api1.Manage) _api := new(api1.Manage)
manage.POST("/company", _api.Company) manage.POST("/company", _api.Company)
manage.POST("/company/add", _api.CompanyForm)
manage.POST("/company/edit", _api.CompanyForm)
manage.POST("/company/detail", _api.CompanyDetail) manage.POST("/company/detail", _api.CompanyDetail)
manage.POST("/company/examine", _api.CompanyExamine) manage.POST("/company/examine", _api.CompanyExamine)
manage.POST("/expert", _api.Expert) manage.POST("/expert", _api.Expert)