Files
bl/modules/blazing/controller/app/login.go
昔念 caa5fc37b9 ```
refactor(common/rpc): 修改服务引用从blazing到config模块

将RPC服务中的blservice引用替换为config服务,
统一使用config.NewServerService()进行服务器信息获取。

feat(blazing): 实现新的会话生成机制

- 添加Gensession方法,基于accountID、UUID生成唯一会话标识
- 会话ID由accountID(4字节) + UUID(16字节)组成,编码为十六进制字符串
- 更新登录控制器使用新的会话生成方式

fix(pet_info): 添加宠物信息空值检查

在切换宠物背包仓库时,当宠物信息查询结果为空时,
返回系统错误避免空指针异常。
2026-01-09 19:58:12 +08:00

73 lines
1.5 KiB
Go

package app
import (
"blazing/cool"
baseservice "blazing/modules/base/service"
blazing "blazing/modules/blazing/service"
"blazing/modules/config/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"`
}