feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package app
|
|
|
|
import (
|
|
"blazing/cool"
|
|
baseservice "blazing/modules/base/service"
|
|
"blazing/modules/config/service"
|
|
blazing "blazing/modules/player/service"
|
|
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
type SessionReq struct {
|
|
g.Meta `path:"/getSessionByAuth" method:"GET"`
|
|
Email string `json:"email" v:"required|email"`
|
|
Password string `json:"password" v:"required"`
|
|
}
|
|
type SessionRes struct {
|
|
Msg string `json:"msg"`
|
|
Code int `json:"code"`
|
|
Session string `json:"session"`
|
|
}
|
|
|
|
type BlazingController struct {
|
|
*cool.Controller
|
|
}
|
|
|
|
func init() {
|
|
var blazing_controller = &BlazingController{
|
|
&cool.Controller{
|
|
Prefix: "/seer/game",
|
|
Api: []string{},
|
|
Service: service.NewServerService(),
|
|
},
|
|
}
|
|
// 注册路由
|
|
cool.RegisterController(blazing_controller)
|
|
}
|
|
func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (res *SessionRes, err error) {
|
|
|
|
res = &SessionRes{
|
|
Msg: "success",
|
|
Code: 200,
|
|
Session: ""}
|
|
if err := g.Validator().Data(req).Run(ctx); err != nil {
|
|
fmt.Println(err)
|
|
res.Code = 400
|
|
res.Msg = err.Error()
|
|
|
|
}
|
|
res1, err := baseservice.NewBaseSysUserService().GetSession(req.Email, req.Password)
|
|
|
|
if err != nil || res1 == nil {
|
|
res.Code = 400
|
|
res.Msg = err.Error()
|
|
return
|
|
}
|
|
|
|
accountID := res1.ID
|
|
|
|
res.Session = blazing.NewInfoService(uint32(accountID)).Gensession()
|
|
|
|
return
|
|
}
|
|
|
|
type MockReq struct {
|
|
g.Meta `path:"/mock" method:"GET"`
|
|
Email string `json:"email" v:"required|email"`
|
|
Password string `json:"password" v:"required"`
|
|
}
|