structure: 确定基本结构(保持基本形式, 采用组合)

This commit is contained in:
loveuer
2024-11-01 17:47:33 +08:00
parent 9e8a47a7c6
commit 56cfd42bb9
52 changed files with 1003 additions and 176 deletions

View File

@@ -9,10 +9,10 @@ import (
"gorm.io/gorm"
"net/http"
"time"
"uauth/internal/store/cache"
"uauth/internal/store/db"
"uauth/internal/tool"
"uauth/model"
"uauth/pkg/cache"
"uauth/pkg/store"
"uauth/tool"
)
var (
@@ -43,7 +43,8 @@ func LoginPage(c *nf.Ctx) error {
return resp.Resp400(c, req)
}
if err = db.Default.Session().Model(&model.Client{}).
if err = store.Default.Session(tool.TimeoutCtx(c.Context(), 3)).
Model(&model.Client{}).
Where("client_id = ?", req.ClientId).
Take(client).
Error; err != nil {
@@ -96,7 +97,8 @@ func LoginAction(c *nf.Ctx) error {
return c.Status(http.StatusBadRequest).SendString("Bad Request: username, password is required")
}
if err = db.Default.Session().Model(&model.User{}).
if err = store.Default.Session(tool.TimeoutCtx(c.Context(), 3)).
Model(&model.User{}).
Where("username = ?", req.Username).
Take(op).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {