feat:完善信息
This commit is contained in:
77
app/api/enterprise/api/account.go
Normal file
77
app/api/enterprise/api/account.go
Normal file
@ -0,0 +1,77 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
account2 "SciencesServer/app/api/enterprise/controller/account"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Account struct{}
|
||||
|
||||
type (
|
||||
accountLoginForm struct {
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Mobile string `json:"mobile" form:"mobile"`
|
||||
Captcha string `json:"captcha" form:"captcha"`
|
||||
Password string `json:"password" form:"password"`
|
||||
}
|
||||
accountRegisterForm struct {
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
RepeatPass string `json:"repeat_pass" form:"repeat_pass" binding:"required"`
|
||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||
}
|
||||
)
|
||||
|
||||
func (a *Account) Login(c *gin.Context) {
|
||||
form := new(accountLoginForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := account2.NewLogin()(api.GetLocal()(c).(string)).Launch(account2.LoginMode(form.Mode), &account2.LoginParams{
|
||||
Captcha: struct {
|
||||
Mobile string
|
||||
Captcha string
|
||||
}{Mobile: form.Mobile, Captcha: form.Captcha},
|
||||
Password: struct {
|
||||
Mobile string
|
||||
Password string
|
||||
}{Mobile: form.Mobile, Password: form.Password},
|
||||
})
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Account) Register(c *gin.Context) {
|
||||
form := new(accountRegisterForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := account2.NewRegister()(api.GetLocal()(c).(string)).Launch(&account2.RegisterParams{
|
||||
Name: form.Name, Mobile: form.Mobile, Captcha: form.Captcha,
|
||||
Password: form.Password, RepeatPass: form.RepeatPass, Identity: form.Identity,
|
||||
})
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Account) BindMobile() {
|
||||
//account.NewOther()().BindMobile()
|
||||
}
|
||||
|
||||
func (a *Account) Logout(c *gin.Context) {
|
||||
handle := api.GetSession()(c)
|
||||
|
||||
session := new(service.SessionEnterprise)
|
||||
|
||||
if handle != nil {
|
||||
session = handle.(*service.SessionEnterprise)
|
||||
}
|
||||
err := account2.NewLogout()(session, api.GetLocal()(c).(uint64)).Launch()
|
||||
api.APIResponse(err)(c)
|
||||
}
|
Reference in New Issue
Block a user