查询任务排行,新增游戏基本接口

This commit is contained in:
chy
2025-06-09 16:30:26 +08:00
parent 5ead851b99
commit a598a253a9
17 changed files with 409 additions and 0 deletions

View File

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package game

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package game
import (
"server/api/game"
)
type ControllerV1 struct{}
func NewV1() game.IGameV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,26 @@
package game
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/game/v1"
)
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
out, err := service.Game().CreateGame(ctx, &model.AddGameIn{
Avatar: req.Avatar,
GameCode: req.GameCode,
GameId: req.GameID,
GameName: req.GameName,
})
if err != nil {
return nil, err
}
return &v1.CreateRes{
Success: out.Success,
}, nil
}

View File

@ -0,0 +1,18 @@
package game
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/game/v1"
)
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
out, err := service.Game().DeleteGame(ctx, &model.DeleteGameIn{GameId: req.GameID})
if err != nil {
return nil, err
}
return &v1.DeleteRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,21 @@
package game
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/game/v1"
)
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
out, err := service.Game().GameList(ctx, &model.GameListIn{})
if err != nil {
return nil, err
}
return &v1.ListRes{
List: out.List,
Total: out.Total,
}, nil
}

View File

@ -0,0 +1,22 @@
package game
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/game/v1"
)
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
out, err := service.Game().UpdateGame(ctx, &model.UpdateGameIn{
GameId: req.GameID,
GameName: req.GameName,
GameCode: req.GameCode,
Avatar: req.Avatar,
})
if err != nil {
return nil, err
}
return &v1.UpdateRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package task

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package task
import (
"server/api/task"
)
type ControllerV1 struct{}
func NewV1() task.ITaskV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,27 @@
package task
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/task/v1"
)
func (c *ControllerV1) Ranking(ctx context.Context, req *v1.RankingReq) (res *v1.RankingRes, err error) {
out, err := service.Task().UserTaskRankingList(ctx, &model.UserTaskRankingIn{
Page: req.Page,
Size: req.Size,
StoreId: req.StoreId,
Type: req.Type,
})
if err != nil {
return nil, err
}
return &v1.RankingRes{
List: out.List,
Total: out.Total,
}, nil
}

22
internal/dao/games.go Normal file
View File

@ -0,0 +1,22 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// gamesDao is the data access object for the table games.
// You can define custom methods on it to extend its functionality as needed.
type gamesDao struct {
*internal.GamesDao
}
var (
// Games is a globally accessible object for table games operations.
Games = gamesDao{internal.NewGamesDao()}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,91 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GamesDao is the data access object for the table games.
type GamesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// GamesColumns defines and stores column names for the table games.
type GamesColumns struct {
GameId string // 腾讯游戏 id
GameName string // 游戏名称
GameaCode string // 游戏代号
Avatar string // 图标
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 删除时间
}
// gamesColumns holds the columns for the table games.
var gamesColumns = GamesColumns{
GameId: "game_id",
GameName: "game_name",
GameaCode: "gamea_code",
Avatar: "avatar",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
return &GamesDao{
group: "default",
table: "games",
columns: gamesColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *GamesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *GamesDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *GamesDao) Columns() GamesColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *GamesDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *GamesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,22 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// Games is the golang structure of table games for DAO operations like Where/Data.
type Games struct {
g.Meta `orm:"table:games, do:true"`
GameId interface{} // 腾讯游戏 id
GameName interface{} // 游戏名称
GameaCode interface{} // 游戏代号
Avatar interface{} // 图标
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 删除时间
}

View File

@ -0,0 +1,20 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// Games is the golang structure for table games.
type Games struct {
GameId int64 `json:"gameId" orm:"game_id" description:"腾讯游戏 id"` // 腾讯游戏 id
GameName string `json:"gameName" orm:"game_name" description:"游戏名称"` // 游戏名称
GameaCode string `json:"gameaCode" orm:"gamea_code" description:"游戏代号"` // 游戏代号
Avatar string `json:"avatar" orm:"avatar" description:"图标"` // 图标
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间"` // 删除时间
}

35
internal/service/game.go Normal file
View File

@ -0,0 +1,35 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"server/internal/model"
)
type (
IGame interface {
GameList(ctx context.Context, in *model.GameListIn) (out *model.GameListOut, err error)
CreateGame(ctx context.Context, in *model.AddGameIn) (out *model.AddGameOut, err error)
UpdateGame(ctx context.Context, in *model.UpdateGameIn) (out *model.UpdateGameOut, err error)
DeleteGame(ctx context.Context, in *model.DeleteGameIn) (out *model.DeleteGameOut, err error)
}
)
var (
localGame IGame
)
func Game() IGame {
if localGame == nil {
panic("implement not found for interface IGame, forgot register?")
}
return localGame
}
func RegisterGame(i IGame) {
localGame = i
}

32
internal/service/task.go Normal file
View File

@ -0,0 +1,32 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"server/internal/model"
)
type (
ITask interface {
UserTaskRankingList(ctx context.Context, in *model.UserTaskRankingIn) (out *model.UserTaskRankingOut, err error)
}
)
var (
localTask ITask
)
func Task() ITask {
if localTask == nil {
panic("implement not found for interface ITask, forgot register?")
}
return localTask
}
func RegisterTask(i ITask) {
localTask = i
}