增加webssh及数据库查询

This commit is contained in:
meilin.huang
2021-01-08 15:37:32 +08:00
parent 111612b7f2
commit 4c2e6b6155
60 changed files with 4347 additions and 2222 deletions

View File

@@ -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))