feat:完善项目信息
This commit is contained in:
@ -71,6 +71,19 @@ func (*Manage) CompanyDetail(c *gin.Context) {
|
||||
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) {
|
||||
form := &struct {
|
||||
manageExamineForm
|
||||
|
@ -1,6 +1,9 @@
|
||||
package manage
|
||||
|
||||
import "SciencesServer/app/basic/config"
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
)
|
||||
|
||||
// BasicParams 基本信息
|
||||
type BasicParams struct {
|
||||
@ -9,3 +12,11 @@ type BasicParams struct {
|
||||
config.Area
|
||||
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
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
@ -75,8 +76,64 @@ func (c *Company) Instance(tenantID uint64, name string, status int, page, pageS
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Company) Form(params *CompanyParams) error {
|
||||
return nil
|
||||
func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) error {
|
||||
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 详细信息
|
||||
|
@ -40,10 +40,6 @@ type (
|
||||
Researchs []string `json:"researchs"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// ExpertParams 专家参数信息
|
||||
ExpertParams struct {
|
||||
ID, TenantID uint64
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
@ -89,7 +85,7 @@ func (c *Expert) Instance(tenantID uint64, name string, examineStatus int, page,
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (*Expert) Detail(id uint64) (*ExpertDetail, error) {
|
||||
func (c *Expert) Detail(id uint64) (*ExpertDetail, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
out, err := mManageExpert.Expert(id)
|
||||
@ -110,27 +106,42 @@ func (*Expert) Detail(id uint64) (*ExpertDetail, error) {
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error {
|
||||
func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
if params.ID > 0 {
|
||||
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 {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专家信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 {
|
||||
if mManageExpert.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} 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 = params.TenantID
|
||||
mManageExpert.TenantID = c.TenantID
|
||||
mManageExpert.ResearchID = other.ConvertResearch()
|
||||
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
||||
mManageExpert.Image.Image = params.Image
|
||||
mManageExpert.Area = model2.Area{
|
||||
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.Major = other.Major
|
||||
mManageExpert.Job = other.Job
|
||||
@ -142,12 +153,22 @@ func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error
|
||||
mManageExpert.SetResearchAttribute(other.Researchs)
|
||||
mManageExpert.Introduce = params.Introduce
|
||||
|
||||
if c.TenantID <= 0 {
|
||||
mManageExpert.TenantID = params.TenantID
|
||||
}
|
||||
if mManageExpert.ID > 0 {
|
||||
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
|
||||
}
|
||||
// 查询手机号码是否在当前租户下是否已经注册了
|
||||
mManageExpert.Name = params.Name
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,7 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mServiceInnovate.TenantID = c.TenantID
|
||||
mServiceInnovate.KindID = params.KindID
|
||||
mServiceInnovate.Title = params.Title
|
||||
mServiceInnovate.Description = params.Description
|
||||
@ -137,16 +138,11 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
||||
mServiceInnovate.SetTagAttribute(params.Tags)
|
||||
mServiceInnovate.Sort = params.Sort
|
||||
|
||||
if mServiceInnovate.ID > 0 {
|
||||
if c.TenantID <= 0 {
|
||||
mServiceInnovate.TenantID = params.TenantID
|
||||
}
|
||||
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
||||
if c.TenantID <= 0 {
|
||||
mServiceInnovate.TenantID = params.TenantID
|
||||
}
|
||||
mServiceInnovate.TenantID = params.TenantID
|
||||
|
||||
if c.TenantID > 0 {
|
||||
mServiceInnovate.TenantID = c.TenantID
|
||||
if mServiceInnovate.ID > 0 {
|
||||
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
return model2.Create(mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
//mManageExpert.Position = params.Mobile
|
||||
mManageExpert.Education = other.Education
|
||||
mManageExpert.School = other.School
|
||||
mManageExpert.Major = other.Major
|
||||
mManageExpert.Job = other.Job
|
||||
|
@ -23,6 +23,7 @@ type (
|
||||
IdentityForExpert struct {
|
||||
ResearchID string `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID
|
||||
LaboratoryID string `json:"laboratory_id" form:"laboratory_id"` // 实验室ID
|
||||
Education string `json:"education" form:"education"` // 学历
|
||||
School string `json:"school" form:"school"` // 毕业院校
|
||||
Major string `json:"major" form:"major"` // 专业
|
||||
Job string `json:"job" form:"job"` // 职务
|
||||
|
@ -15,11 +15,12 @@ type ManageExpert struct {
|
||||
Name string `gorm:"column:name;type:varchar(30);default:'';comment:专家名称" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:专家联系方式" json:"mobile"`
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:'';comment:坐标" json:"-"`
|
||||
School string `gorm:"column:school;type:varchar(50);default:'';comment:院校" json:"school"`
|
||||
Major string `gorm:"column:major;type:varchar(50);default:'';comment:专业" json:"major"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:'';comment:职务" json:"job"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:'';comment:职称" json:"title"`
|
||||
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"`
|
||||
Major string `gorm:"column:major;type:varchar(50);default:'';comment:专业" json:"major"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:'';comment:职务" json:"job"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:'';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(255);default:'';comment:行业领域" json:"-"`
|
||||
|
@ -286,6 +286,8 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
{
|
||||
_api := new(api1.Manage)
|
||||
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/examine", _api.CompanyExamine)
|
||||
manage.POST("/expert", _api.Expert)
|
||||
|
Reference in New Issue
Block a user