feat:完善入驻信息管理

This commit is contained in:
henry
2021-12-02 18:05:53 +08:00
parent 5c4d883c97
commit 199e6f0669
23 changed files with 626 additions and 55 deletions

View File

@ -3,21 +3,110 @@ package api
import (
"SciencesServer/app/api/enterprise/controller/settled"
"SciencesServer/app/basic/api"
"SciencesServer/app/basic/config"
"SciencesServer/app/session"
"github.com/gin-gonic/gin"
)
type Settled struct{}
type (
// settledForm 入驻平台参数
settledForm struct {
api.ImageForm
Name string `json:"name" form:"name"`
Code string `json:"code" form:"code"`
Mobile string `json:"mobile" form:"mobile"`
config.Area
Industrys []string `json:"industrys" form:"industrys"`
Keywords []string `json:"keywords" form:"keywords"`
Introduce string `json:"introduce" form:"introduce"`
}
)
func (c *settledForm) bind() *settled.BasicParams {
return &settled.BasicParams{Name: c.Name, Image: c.FilterImageURL(), Code: c.Code, Mobile: c.Mobile,
Introduce: c.Introduce, Area: c.Area, Industrys: c.Industrys, Keywords: c.Keywords,
}
}
// Index 入驻信息
func (*Settled) Index(c *gin.Context) {
settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).Index()
}
// Company 公司入驻信息
func (*Settled) Company(c *gin.Context) {
settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(nil, 0, nil)
form := &struct {
settledForm
InviterCode string `json:"inviter_code" form:"inviter_code"`
config.IdentityForCompany
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), (&api.IDStringForm{ID: form.InviterCode}).Convert(), &form.IdentityForCompany)
api.APIResponse(err)(c)
}
// Expert 专家入驻信息
func (*Settled) Expert(c *gin.Context) {
form := &struct {
settledForm
config.IdentityForExpert
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := settled.NewExpert()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), &form.IdentityForExpert)
api.APIResponse(err)(c)
}
// Research 研究机构入驻信息
func (*Settled) Research(c *gin.Context) {
form := &struct {
settledForm
config.IdentityForResearch
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := settled.NewResearch()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), &form.IdentityForResearch)
api.APIResponse(err)(c)
}
// Laboratory 实验室入驻信息
func (*Settled) Laboratory(c *gin.Context) {
form := &struct {
settledForm
config.IdentityForLaboratory
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := settled.NewLaboratory()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), &form.IdentityForLaboratory)
api.APIResponse(err)(c)
}
// Agent 经纪人入驻信息
func (*Settled) Agent(c *gin.Context) {
form := &struct {
settledForm
config.IdentityForAgent
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := settled.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), &form.IdentityForAgent)
api.APIResponse(err)(c)
}