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 PoolAddrFeeHistoryApi struct {
}

var poolAddrFeeHistoryService = service.ServiceGroupApp.EntrustPoolServiceGroup.PoolAddrFeeHistoryService


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

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

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

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

// FindPoolAddrFeeHistory 用id查询PoolAddrFeeHistory
// @Tags PoolAddrFeeHistory
// @Summary 用id查询PoolAddrFeeHistory
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query entrustPool.PoolAddrFeeHistory true "用id查询PoolAddrFeeHistory"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /poolAddrFeeHistory/findPoolAddrFeeHistory [get]
func (poolAddrFeeHistoryApi *PoolAddrFeeHistoryApi) FindPoolAddrFeeHistory(c *gin.Context) {
	var poolAddrFeeHistory entrustPool.PoolAddrFeeHistory
	err := c.ShouldBindQuery(&poolAddrFeeHistory)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if repoolAddrFeeHistory, err := poolAddrFeeHistoryService.GetPoolAddrFeeHistory(poolAddrFeeHistory.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"repoolAddrFeeHistory": repoolAddrFeeHistory}, c)
	}
}

// GetPoolAddrFeeHistoryList 分页获取PoolAddrFeeHistory列表
// @Tags PoolAddrFeeHistory
// @Summary 分页获取PoolAddrFeeHistory列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query entrustPoolReq.PoolAddrFeeHistorySearch true "分页获取PoolAddrFeeHistory列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /poolAddrFeeHistory/getPoolAddrFeeHistoryList [get]
func (poolAddrFeeHistoryApi *PoolAddrFeeHistoryApi) GetPoolAddrFeeHistoryList(c *gin.Context) {
	var pageInfo entrustPoolReq.PoolAddrFeeHistorySearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	if list, total, err := poolAddrFeeHistoryService.GetPoolAddrFeeHistoryInfoList(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)
    }
}
