| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- package task
- import (
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- "log-server/global"
- "log-server/model/common/response"
- "log-server/model/task/request"
- "log-server/utils"
- )
- type GameTaskApi struct {
- }
- // @Tags gameTask
- // @Summary 创建游戏任务
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "创建游戏任务"
- // @Router /gameTask/create [post]
- func (s *GameTaskApi) CreateGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.GameTaskVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.CreateGameTask(api); err != nil {
- global.GVA_LOG.Error("创建失败!", zap.Error(err))
- response.FailWithMessage("创建失败", c)
- } else {
- response.OkWithMessage("创建成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 游戏任务列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetCardListRequest true "游戏任务列表"
- // @Success 200 {object} response.Response{data=response.GetGameTaskListReply,msg=string} "分页游戏任务列表,返回包括列表,总数,页码,每页数量"
- // @Router /gameTask/getGameTaskList [post]
- func (s *GameTaskApi) GetGameTaskList(c *gin.Context) {
- var paramsInfo request.GetGameTaskListRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if list, total, err := taskService.GetGameTaskInfoList(paramsInfo.GameTask, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败", c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: paramsInfo.Page,
- PageSize: paramsInfo.PageSize,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 根据id获取游戏任务信息
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetById true "根据id获取游戏任务信息"
- // @Success 200 {object} response.Response{data=systemRes.GameTaskRequest} "根据id获取游戏任务信息,返回包括游戏任务信息详情"
- // @Router /gameTask/getGameTaskById [post]
- func (s *GameTaskApi) GetGameTaskById(c *gin.Context) {
- var idInfo request.GetById
- _ = c.ShouldBindJSON(&idInfo)
- if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- api, err := taskService.GetGameTaskById(idInfo.ID)
- if err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败", c)
- } else {
- response.OkWithDetailed(api, "获取成功", c)
- }
- }
- // @Tags GameTask
- // @Summary 游戏任务信息状态
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.UpdateGameTaskStatusRequest true "id, 状态"
- // @Success 200 {object} response.Response{msg=string} "修改游戏任务信息状态"
- // @Router /gameTask/statusOperation [post]
- func (s *GameTaskApi) StatusOperation(c *gin.Context) {
- var paramsInfo request.UpdateGameTaskStatusRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if paramsInfo.TaskId == 0 {
- response.FailWithMessage("Id不能为空", c)
- return
- }
- if paramsInfo.Status == 0 {
- response.FailWithMessage("状态值不能为空", c)
- return
- }
- if err := taskService.UpdateGameTaskStatus(paramsInfo); err != nil {
- global.GVA_LOG.Error("修改失败!", zap.Error(err))
- response.FailWithMessage(err.Error(), c)
- } else {
- response.OkWithMessage("修改成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 更新游戏任务
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "更新游戏任务"
- // @Router /gameTask/update [post]
- func (s *GameTaskApi) UpdateGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.GameTaskVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.UpdateGameTask(api); err != nil {
- global.GVA_LOG.Error("更新失败!", zap.Error(err))
- response.FailWithMessage("更新失败", c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 删除gameTask
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body task.GameTask true "ID"
- // @Success 200 {object} response.Response{msg=string} "删除gameTask"
- // @Router /gameTask/delete [post]
- func (s *GameTaskApi) DeleteGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.TaskIdVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.DeleteGameTask(api); err != nil {
- global.GVA_LOG.Error("删除失败!", zap.Error(err))
- response.FailWithMessage("删除失败", c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
|