172 lines
5.1 KiB
Go
172 lines
5.1 KiB
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/api/enterprise/controller/user"
|
|
"SciencesServer/app/basic/api"
|
|
"SciencesServer/app/basic/config"
|
|
"SciencesServer/app/session"
|
|
"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 string `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 (*User) Info(c *gin.Context) {
|
|
data := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Info()
|
|
api.APISuccess(data)
|
|
}
|
|
|
|
func (*User) Detail(c *gin.Context) {
|
|
data, err := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Detail()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) BindMobile(c *gin.Context) {
|
|
form := &struct {
|
|
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
|
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).BindMobile(form.Mobile, form.Captcha)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) 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).(*session.Enterprise)).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 (*User) 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).(*session.Enterprise)).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 (*User) 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).(*session.Enterprise)).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 (*User) 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).(*session.Enterprise)).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 (*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).(*session.Enterprise)).SwitchIdentity(form.Identity)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) Back(c *gin.Context) {
|
|
data, err := user.NewBank()(api.GetSession()(c).(*session.Enterprise)).List()
|
|
api.APIResponse(err, data)
|
|
}
|
|
|
|
func (*User) BackBind(c *gin.Context) {
|
|
form := new(userBankForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewBank()(api.GetSession()(c).(*session.Enterprise)).Bind(&user.BankParams{
|
|
Name: form.Name, IDCard: form.IDCard, BankCard: form.BackCard, BankName: form.BackName,
|
|
}, form.Captcha)
|
|
api.APIResponse(err)
|
|
}
|
|
|
|
func (*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.NewBank()(api.GetSession()(c).(*session.Enterprise)).Unbind(form.Convert())
|
|
api.APIResponse(err)
|
|
}
|
|
|
|
func (*User) Patent(c *gin.Context) {
|
|
form := &struct {
|
|
Title string `json:"title" form:"title"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
}
|