138 lines
4.1 KiB
Go
138 lines
4.1 KiB
Go
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) {
|
|
data, err := settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).Index()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
// Company 公司入驻信息
|
|
func (*Settled) Company(c *gin.Context) {
|
|
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.GetTenantID()(c).(uint64)).
|
|
Launch(form.settledForm.bind(), (&api.IDStringForm{ID: form.InviterCode}).Convert(), &form.IdentityForCompany)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
// CompanyGet 公司入驻信息
|
|
func (*Settled) CompanyGet(c *gin.Context) {
|
|
form := &struct {
|
|
Code string `json:"code" form:"code" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).Get(form.Code)
|
|
api.APIResponse(err, data)(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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
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
|
|
}
|
|
credentialImages := make([]string, 0)
|
|
|
|
for _, image := range form.CredentialImages {
|
|
credentialImages = append(credentialImages, (&api.ImageForm{Image: image}).FilterImageURL())
|
|
}
|
|
|
|
form.CredentialImages = credentialImages
|
|
form.IDImage.Front = (&api.ImageForm{Image: form.IDImage.Front}).FilterImageURL()
|
|
form.IDImage.Behind = (&api.ImageForm{Image: form.IDImage.Behind}).FilterImageURL()
|
|
form.IDImage.Hold = (&api.ImageForm{Image: form.IDImage.Hold}).FilterImageURL()
|
|
|
|
err := settled.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
|
Launch(form.settledForm.bind(), &form.IdentityForAgent)
|
|
api.APIResponse(err)(c)
|
|
}
|