package api import ( "SciencesServer/app/basic/api" "SciencesServer/app/basic/config" "SciencesServer/app/enterprise/controller/user" "SciencesServer/app/service" "github.com/gin-gonic/gin" ) type User struct{} type ( // userSettledForm 入驻平台参数 userSettledForm struct { api.IDStringForm api.ImageForm Name string `json:"name" form:"name"` Code string `json:"code" form:"code"` config.Area Introduce string `json:"introduce" form:"introduce"` Industry uint64 `json:"industry" form:"industry"` Keywords []string `json:"keywords" form:"keywords"` } // userBankForm 银行平台信息参数 userBankForm struct { Name string `json:"name" form:"name" binding:"required"` IDCard string `json:"id_card" form:"id_card" binding:"required"` BackCard string `json:"back_card" form:"back_card" binding:"required"` BackName string `json:"back_name" form:"back_name" binding:"required"` Captcha string `json:"captcha" form:"captcha" binding:"required"` } ) func (a *User) Info(c *gin.Context) { data := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Info() api.APISuccess(data) } func (a *User) Detail(c *gin.Context) { data, err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Detail() api.APIResponse(err, data)(c) } func (a *Tenant) SettledCompany(c *gin.Context) { form := &struct { userSettledForm }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Company(&user.SettledParams{ ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code, Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords, }, nil) api.APIResponse(err)(c) } func (a *Tenant) SettledExpert(c *gin.Context) { form := &struct { userSettledForm config.IdentityForExpert }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Expert(&user.SettledParams{ ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords, }, &form.IdentityForExpert) api.APIResponse(err)(c) } func (a *Tenant) SettledResearch(c *gin.Context) { form := &struct { userSettledForm config.IdentityForResearch }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Research(&user.SettledParams{ ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code, Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords, }, &form.IdentityForResearch) api.APIResponse(err)(c) } func (a *Tenant) SettledLaboratory(c *gin.Context) { form := &struct { userSettledForm config.IdentityForLaboratory }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Laboratory(&user.SettledParams{ ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code, Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords, }, &form.IdentityForLaboratory) api.APIResponse(err)(c) } func (a *User) SwitchIdentity(c *gin.Context) { form := &struct { Identity int `json:"identity" form:"identity" binding:"required"` }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).SwitchIdentity(form.Identity) api.APIResponse(err)(c) } func (a *User) Back(c *gin.Context) { data, err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).List() api.APIResponse(err, data) } func (a *User) BackBind(c *gin.Context) { form := new(userBankForm) if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Bind(&user.BackParams{ Name: form.Name, IDCard: form.IDCard, BackCard: form.BackCard, BackName: form.BackName, }, form.Captcha) api.APIResponse(err) } func (a *User) BackUnbind(c *gin.Context) { form := new(api.IDStringForm) if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Unbind(form.Convert()) api.APIResponse(err) }