feat:完善信息

This commit is contained in:
henry
2021-09-29 16:25:56 +08:00
parent b876eab301
commit c556053feb
16 changed files with 382 additions and 84 deletions

View File

@ -3,6 +3,7 @@ package api
import (
"SciencesServer/app/common/api"
"SciencesServer/app/enterprise/controller/account"
"SciencesServer/app/service"
"github.com/gin-gonic/gin"
)
@ -10,10 +11,17 @@ type Account struct{}
type (
accountLoginForm struct {
Mode int `json:"mode" form:"mode" binding:"required"`
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"`
}
)
@ -24,22 +32,45 @@ func (a *Account) Login(c *gin.Context) {
api.APIFailure(err.(error))(c)
return
}
data, err := account.NewLogin().Login()(account.LoginMode(form.Mode), nil)
data, err := account.NewLogin()().Launch(account.LoginMode(form.Mode), &account.LoginRequest{
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)
}
func (a *Account) Register() {
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 := account.NewRegister()().Launch(&account.RegisterRequest{
Name: form.Name, Mobile: form.Mobile, Captcha: form.Captcha,
Password: form.Password, RepeatPass: form.RepeatPass,
})
api.APIResponse(err, data)
}
func (c *Account) BindName() {
func (a *Account) BindMobile() {
account.NewOther()().BindMobile()
}
func (c *Account) BindMobile() {
}
func (a *Account) Logout() {
func (a *Account) Logout(c *gin.Context) {
handle := api.GetSession()(c)
session := new(service.SessionEnterprise)
if handle != nil {
session = handle.(*service.SessionEnterprise)
}
err := account.NewLogout()(session).Launch()
api.APIResponse(err)(c)
}

View File

@ -0,0 +1,14 @@
package api
import (
"SciencesServer/app/common/api"
"SciencesServer/app/enterprise/controller"
"github.com/gin-gonic/gin"
)
type Config struct{}
func (a *Config) Identity(c *gin.Context) {
data := controller.NewConfig().Identity()
api.APISuccess(data)
}

View File

@ -0,0 +1,3 @@
package api
type User struct{}