package game

import (
	"common/remark"
	"common/resultStatus"
	"common/webServer"
	"usercenter/internal/user"
)

func init() {

	//注册接口
	webServer.RegisterFunction(new(GameApi))
}

func init() {
	moduleName := "GameApi"
	desc := "用户接口"
	author := "tangping"
	mendor := ""
	date := "2025年1月7日14:38:22"
	remark.RegisterModuleRemark(moduleName, desc, author, mendor, date)
}

// 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
}
