package entrustPool

import (
	"courseSign/server/global"
    "courseSign/server/model/entrustPool"
    "courseSign/server/model/common/request"
    entrustPoolReq "courseSign/server/model/entrustPool/request"
    "courseSign/server/model/common/response"
    "courseSign/server/service"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type PoolAddrTicketDailyApi struct {
}

var poolAddrTicketDailyService = service.ServiceGroupApp.EntrustPoolServiceGroup.PoolAddrTicketDailyService


// CreatePoolAddrTicketDaily 创建PoolAddrTicketDaily
// @Tags PoolAddrTicketDaily
// @Summary 创建PoolAddrTicketDaily
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body entrustPool.PoolAddrTicketDaily true "创建PoolAddrTicketDaily"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /poolAddrTicketDaily/createPoolAddrTicketDaily [post]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) CreatePoolAddrTicketDaily(c *gin.Context) {
	var poolAddrTicketDaily entrustPool.PoolAddrTicketDaily
	err := c.ShouldBindJSON(&poolAddrTicketDaily)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if err := poolAddrTicketDailyService.CreatePoolAddrTicketDaily(poolAddrTicketDaily); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// DeletePoolAddrTicketDaily 删除PoolAddrTicketDaily
// @Tags PoolAddrTicketDaily
// @Summary 删除PoolAddrTicketDaily
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body entrustPool.PoolAddrTicketDaily true "删除PoolAddrTicketDaily"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /poolAddrTicketDaily/deletePoolAddrTicketDaily [delete]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) DeletePoolAddrTicketDaily(c *gin.Context) {
	var poolAddrTicketDaily entrustPool.PoolAddrTicketDaily
	err := c.ShouldBindJSON(&poolAddrTicketDaily)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if err := poolAddrTicketDailyService.DeletePoolAddrTicketDaily(poolAddrTicketDaily); err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败", c)
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

// DeletePoolAddrTicketDailyByIds 批量删除PoolAddrTicketDaily
// @Tags PoolAddrTicketDaily
// @Summary 批量删除PoolAddrTicketDaily
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除PoolAddrTicketDaily"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /poolAddrTicketDaily/deletePoolAddrTicketDailyByIds [delete]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) DeletePoolAddrTicketDailyByIds(c *gin.Context) {
	var IDS request.IdsReq
    err := c.ShouldBindJSON(&IDS)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if err := poolAddrTicketDailyService.DeletePoolAddrTicketDailyByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}

// UpdatePoolAddrTicketDaily 更新PoolAddrTicketDaily
// @Tags PoolAddrTicketDaily
// @Summary 更新PoolAddrTicketDaily
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body entrustPool.PoolAddrTicketDaily true "更新PoolAddrTicketDaily"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /poolAddrTicketDaily/updatePoolAddrTicketDaily [put]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) UpdatePoolAddrTicketDaily(c *gin.Context) {
	var poolAddrTicketDaily entrustPool.PoolAddrTicketDaily
	err := c.ShouldBindJSON(&poolAddrTicketDaily)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if err := poolAddrTicketDailyService.UpdatePoolAddrTicketDaily(poolAddrTicketDaily); err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败", c)
	} else {
		response.OkWithMessage("更新成功", c)
	}
}

// FindPoolAddrTicketDaily 用id查询PoolAddrTicketDaily
// @Tags PoolAddrTicketDaily
// @Summary 用id查询PoolAddrTicketDaily
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query entrustPool.PoolAddrTicketDaily true "用id查询PoolAddrTicketDaily"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /poolAddrTicketDaily/findPoolAddrTicketDaily [get]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) FindPoolAddrTicketDaily(c *gin.Context) {
	var poolAddrTicketDaily entrustPool.PoolAddrTicketDaily
	err := c.ShouldBindQuery(&poolAddrTicketDaily)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if repoolAddrTicketDaily, err := poolAddrTicketDailyService.GetPoolAddrTicketDaily(poolAddrTicketDaily.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"repoolAddrTicketDaily": repoolAddrTicketDaily}, c)
	}
}

// GetPoolAddrTicketDailyList 分页获取PoolAddrTicketDaily列表
// @Tags PoolAddrTicketDaily
// @Summary 分页获取PoolAddrTicketDaily列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query entrustPoolReq.PoolAddrTicketDailySearch true "分页获取PoolAddrTicketDaily列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /poolAddrTicketDaily/getPoolAddrTicketDailyList [get]
func (poolAddrTicketDailyApi *PoolAddrTicketDailyApi) GetPoolAddrTicketDailyList(c *gin.Context) {
	var pageInfo entrustPoolReq.PoolAddrTicketDailySearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if list, total, err := poolAddrTicketDailyService.GetPoolAddrTicketDailyInfoList(pageInfo); err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败", c)
    } else {
        response.OkWithDetailed(response.PageResult{
            List:     list,
            Total:    total,
            Page:     pageInfo.Page,
            PageSize: pageInfo.PageSize,
        }, "获取成功", c)
    }
}
