Files

107 lines
3.2 KiB
Go
Raw Normal View History

2021-09-29 16:25:56 +08:00
package api
2021-10-08 17:33:19 +08:00
import (
"SciencesServer/app/basic/api"
2021-10-13 17:17:28 +08:00
"SciencesServer/app/basic/config"
2021-10-08 17:33:19 +08:00
"SciencesServer/app/enterprise/controller/user"
"SciencesServer/app/service"
"github.com/gin-gonic/gin"
)
2021-09-29 16:25:56 +08:00
type User struct{}
2021-10-08 17:33:19 +08:00
func (a *User) Info(c *gin.Context) {
data := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Info()
api.APISuccess(data)
}
2021-10-12 17:27:41 +08:00
func (a *User) Detail(c *gin.Context) {
data, err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Detail()
2021-10-13 14:35:24 +08:00
api.APIResponse(err, data)(c)
2021-10-12 17:27:41 +08:00
}
2021-10-13 17:17:28 +08:00
type SettledBasic 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"`
}
func (a *Tenant) SettledCompany(c *gin.Context) {
form := &struct {
SettledBasic
}{}
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 {
SettledBasic
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 {
SettledBasic
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 {
SettledBasic
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)
}
2021-10-12 17:27:41 +08:00
func (a *User) SwitchIdentity(c *gin.Context) {
2021-10-08 17:33:19 +08:00
form := &struct {
2021-10-12 17:27:41 +08:00
Identity int `json:"identity" form:"identity" binding:"required"`
2021-10-08 17:33:19 +08:00
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
2021-10-12 17:27:41 +08:00
err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).SwitchIdentity(form.Identity)
2021-10-13 14:35:24 +08:00
api.APIResponse(err)(c)
2021-10-08 17:33:19 +08:00
}