mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
34 lines
906 B
Go
34 lines
906 B
Go
package apis
|
|
|
|
import (
|
|
"mayfly-go/base/biz"
|
|
"mayfly-go/base/ctx"
|
|
"mayfly-go/base/ginx"
|
|
"mayfly-go/devops/apis/form"
|
|
"mayfly-go/devops/application"
|
|
"mayfly-go/devops/domain/entity"
|
|
)
|
|
|
|
type Account struct {
|
|
AccountApp application.IAccount
|
|
}
|
|
|
|
// @router /accounts/login [post]
|
|
func (a *Account) Login(rc *ctx.ReqCtx) {
|
|
loginForm := &form.LoginForm{}
|
|
ginx.BindJsonAndValid(rc.GinCtx, loginForm)
|
|
rc.ReqParam = loginForm.Username
|
|
|
|
account := &entity.Account{Username: loginForm.Username, Password: loginForm.Password}
|
|
biz.ErrIsNil(a.AccountApp.GetAccount(account, "Id", "Username", "Password"), "用户名或密码错误")
|
|
rc.ResData = map[string]interface{}{
|
|
"token": ctx.CreateToken(account.Id, account.Username),
|
|
"username": account.Username,
|
|
}
|
|
}
|
|
|
|
// @router /accounts [get]
|
|
func (a *Account) Accounts(rc *ctx.ReqCtx) {
|
|
// rc.ResData = models.ListAccount(ginx.GetPageParam(rc.GinCtx))
|
|
}
|