diff --git a/api/game/game.go b/api/game/game.go new file mode 100644 index 0000000..83308bd --- /dev/null +++ b/api/game/game.go @@ -0,0 +1,18 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package game + +import ( + "context" + + "server/api/game/v1" +) + +type IGameV1 interface { + List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) + Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) + Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) + Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) +} diff --git a/api/task/task.go b/api/task/task.go new file mode 100644 index 0000000..61b625b --- /dev/null +++ b/api/task/task.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package task + +import ( + "context" + + "server/api/task/v1" +) + +type ITaskV1 interface { + Ranking(ctx context.Context, req *v1.RankingReq) (res *v1.RankingRes, err error) +} diff --git a/internal/controller/game/game.go b/internal/controller/game/game.go new file mode 100644 index 0000000..d219cf9 --- /dev/null +++ b/internal/controller/game/game.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package game diff --git a/internal/controller/game/game_new.go b/internal/controller/game/game_new.go new file mode 100644 index 0000000..c5d05f6 --- /dev/null +++ b/internal/controller/game/game_new.go @@ -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{} +} diff --git a/internal/controller/game/game_v1_create.go b/internal/controller/game/game_v1_create.go new file mode 100644 index 0000000..b7d2eb8 --- /dev/null +++ b/internal/controller/game/game_v1_create.go @@ -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 +} diff --git a/internal/controller/game/game_v1_delete.go b/internal/controller/game/game_v1_delete.go new file mode 100644 index 0000000..475f855 --- /dev/null +++ b/internal/controller/game/game_v1_delete.go @@ -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 +} diff --git a/internal/controller/game/game_v1_list.go b/internal/controller/game/game_v1_list.go new file mode 100644 index 0000000..96926e5 --- /dev/null +++ b/internal/controller/game/game_v1_list.go @@ -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 +} diff --git a/internal/controller/game/game_v1_update.go b/internal/controller/game/game_v1_update.go new file mode 100644 index 0000000..bc96be6 --- /dev/null +++ b/internal/controller/game/game_v1_update.go @@ -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 +} diff --git a/internal/controller/task/task.go b/internal/controller/task/task.go new file mode 100644 index 0000000..4399401 --- /dev/null +++ b/internal/controller/task/task.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package task diff --git a/internal/controller/task/task_new.go b/internal/controller/task/task_new.go new file mode 100644 index 0000000..be0124d --- /dev/null +++ b/internal/controller/task/task_new.go @@ -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{} +} diff --git a/internal/controller/task/task_v1_ranking.go b/internal/controller/task/task_v1_ranking.go new file mode 100644 index 0000000..3522b48 --- /dev/null +++ b/internal/controller/task/task_v1_ranking.go @@ -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 +} diff --git a/internal/dao/games.go b/internal/dao/games.go new file mode 100644 index 0000000..cd51e28 --- /dev/null +++ b/internal/dao/games.go @@ -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. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go new file mode 100644 index 0000000..2d4ca9d --- /dev/null +++ b/internal/dao/internal/games.go @@ -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) +} diff --git a/internal/model/do/games.go b/internal/model/do/games.go new file mode 100644 index 0000000..5f5856b --- /dev/null +++ b/internal/model/do/games.go @@ -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 // 删除时间 +} diff --git a/internal/model/entity/games.go b/internal/model/entity/games.go new file mode 100644 index 0000000..aa927ac --- /dev/null +++ b/internal/model/entity/games.go @@ -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:"删除时间"` // 删除时间 +} diff --git a/internal/service/game.go b/internal/service/game.go new file mode 100644 index 0000000..ba767cd --- /dev/null +++ b/internal/service/game.go @@ -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 +} diff --git a/internal/service/task.go b/internal/service/task.go new file mode 100644 index 0000000..bed5518 --- /dev/null +++ b/internal/service/task.go @@ -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 +}