package controller import ( "electricity_bill_calc/logger" "electricity_bill_calc/repository" "electricity_bill_calc/response" "github.com/gofiber/fiber/v2" "go.uber.org/zap" "net/http" ) var withdrawLog = logger.Named("Handler", "Withdraw") func InitializeWithdrawHandlers(router *fiber.App) { router.Get("/withdraw", withdraw) } //用于检索用户的核算报表 func withdraw(c *fiber.Ctx) error { //记录日志 withdrawLog.Info("带分页的待审核的核算撤回申请列表") //获取请求参数 result := response.NewResult(c) keyword := c.Query("keyword", "") page := c.QueryInt("page", 1) withdrawLog.Info("参数为: ", zap.String("keyword", keyword), zap.Int("page", page)) //中间数据库操作暂且省略。。。。 //首先进行核算报表的分页查询 withdraws, total, err := repository.WithdrawRepository.FindWithdraw(page, &keyword) if err != nil { withdrawLog.Error("检索用户核算报表失败。", zap.Error(err)) return result.Error(http.StatusInternalServerError, err.Error()) } //TODO: 2023-07-18 此处返回值是个示例,具体返回值需要查询数据库 return result.Success( "withdraw请求成功", response.NewPagedResponse(page, total).ToMap(), fiber.Map{"records": withdraws}, ) }