一些框架优化

This commit is contained in:
tangping
2025-01-07 16:43:33 +08:00
parent d562558a3e
commit b107b88800
9 changed files with 120 additions and 24 deletions

View File

@@ -2,7 +2,9 @@ package game
import (
"common/remark"
"common/resultStatus"
"common/webServer"
"logincenter/internal/user"
)
func init() {
@@ -12,7 +14,7 @@ func init() {
}
func init() {
moduleName := "UserApi"
moduleName := "GameApi"
desc := "用户接口"
author := "tangping"
mendor := ""
@@ -23,3 +25,45 @@ func init() {
// GameApi 游戏接口
type GameApi struct {
}
func init() {
moduleName := "GameApi"
methodName := "Add"
skipVerifyTokenPage := false
methodDesc := "添加游戏"
methodAuthor := "tangping"
methodMendor := ""
methodDate := "2024-12-25 15:55:00"
methodInParam := []string{"string 账号,int 游戏id"}
methodOutParam := `
{
"Code '类型:int'": "响应结果的状态值",
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
"Data '类型:interface{}'": "响应结果的数据"
{
}
}`
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
}
func (this *GameApi) Add(userData *user.User, account string, gameId int64) (responseObj *webServer.ResponseObject) {
responseObj = webServer.GetInitResponseObj()
//用户登录用户数据
//参数验证
//添加游戏
game := &Game{
Account: account,
GameID: int64(gameId),
}
gameId, err := AddGame(userData, game)
if err != nil {
return responseObj.SetResultStatus(resultStatus.DataError)
}
return
}

View File

@@ -33,6 +33,7 @@ type UserApi struct {
func init() {
moduleName := "UserApi"
methodName := "Register"
skipVerifyTokenPage := true
methodDesc := "注册用户"
methodAuthor := "tangping"
methodMendor := ""
@@ -47,7 +48,7 @@ func init() {
"id '类型:int'": "用户id",
}
}`
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam)
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
}
func (a *UserApi) Register(account string, name string, password string, sex int32, birthday string, phone int64, email string, wechatGroup string, describe string) (responseObj *webServer.ResponseObject) {
responseObj = webServer.GetInitResponseObj()
@@ -86,6 +87,7 @@ func (a *UserApi) Register(account string, name string, password string, sex int
func init() {
moduleName := "UserApi"
methodName := "Login"
skipVerifyTokenPage := true
methodDesc := "用户登录"
methodAuthor := "tangping"
methodMendor := ""
@@ -101,7 +103,7 @@ func init() {
}
}`
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam)
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
}
func (a *UserApi) Login(account string, password string) (responseObj *webServer.ResponseObject) {
@@ -128,7 +130,7 @@ func (a *UserApi) Login(account string, password string) (responseObj *webServer
}
//添加登录用户
webServer.AddLoginUserToken(token, &webServer.TokenInfo{Id: userData.ID, Account: account})
webServer.AddLoginUserToken(token, &webServer.TokenInfo{Id: userData.ID, Account: account, UserInfo: userData})
//UserData映射成map
resultMap := make(map[string]any)