Files
bl/modules/player/controller/app/login.go

73 lines
1.5 KiB
Go
Raw Normal View History

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"`
}