mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
增加webssh及数据库查询
This commit is contained in:
@@ -2,6 +2,9 @@ package controllers
|
||||
|
||||
import (
|
||||
"mayfly-go/base"
|
||||
"mayfly-go/base/ctx"
|
||||
"mayfly-go/base/model"
|
||||
"mayfly-go/base/token"
|
||||
"mayfly-go/controllers/form"
|
||||
"mayfly-go/models"
|
||||
)
|
||||
@@ -17,14 +20,14 @@ type AccountController struct {
|
||||
|
||||
// @router /accounts/login [post]
|
||||
func (c *AccountController) Login() {
|
||||
c.ReturnData(false, func(la *base.LoginAccount) interface{} {
|
||||
c.ReturnData(false, func(la *ctx.LoginAccount) interface{} {
|
||||
loginForm := &form.LoginForm{}
|
||||
c.UnmarshalBodyAndValid(loginForm)
|
||||
|
||||
a := &models.Account{Username: loginForm.Username, Password: loginForm.Password}
|
||||
base.BizErrIsNil(base.GetBy(a, "Username", "Password"), "用户名或密码错误")
|
||||
model.BizErrIsNil(model.GetBy(a, "Username", "Password"), "用户名或密码错误")
|
||||
return map[string]interface{}{
|
||||
"token": base.CreateToken(a.Id, a.Username),
|
||||
"token": token.CreateToken(a.Id, a.Username),
|
||||
"username": a.Username,
|
||||
}
|
||||
})
|
||||
@@ -32,7 +35,7 @@ func (c *AccountController) Login() {
|
||||
|
||||
// @router /accounts [get]
|
||||
func (c *AccountController) Accounts() {
|
||||
c.ReturnData(true, func(account *base.LoginAccount) interface{} {
|
||||
c.ReturnData(true, func(account *ctx.LoginAccount) interface{} {
|
||||
//s := c.GetString("username")
|
||||
//query := models.QuerySetter(new(models.Account)).OrderBy("-Id").RelatedSel()
|
||||
//return models.GetPage(query, c.GetPageParam(), new([]models.Account), new([]vo.AccountVO))
|
||||
|
||||
Reference in New Issue
Block a user