33 lines
854 B
Go
33 lines
854 B
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/basic/api"
|
|
"SciencesServer/app/enterprise/controller/user"
|
|
"SciencesServer/app/service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type User struct{}
|
|
|
|
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)
|
|
}
|
|
|
|
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)
|
|
}
|