75 lines
2.1 KiB
Go
75 lines
2.1 KiB
Go
package controller
|
||
|
||
import (
|
||
"electricity_bill_calc/logger"
|
||
"electricity_bill_calc/response"
|
||
"github.com/gofiber/fiber/v2"
|
||
"go.uber.org/zap"
|
||
)
|
||
|
||
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))
|
||
//中间数据库操作暂且省略。。。。
|
||
//首先进行核算报表的分页查询
|
||
|
||
//TODO: 2023-07-18 此处的data需要经过上面数据库查询后进行数据返回,此处只是作于演示
|
||
data := fiber.Map{
|
||
"report": fiber.Map{
|
||
"id": "string",
|
||
"parkId": "string",
|
||
"periodBegin": "string",
|
||
"periodEnd": "string",
|
||
"published": true,
|
||
"publishedAt": "string",
|
||
"withdraw": 0,
|
||
"lastWithdrawAppliedAt": "string",
|
||
"lastWithdrawAuditAt": "string",
|
||
"status": 0,
|
||
"message": "string",
|
||
},
|
||
"park": fiber.Map{
|
||
"id": "string",
|
||
"userId": "string",
|
||
"name": "string",
|
||
"tenement": "string",
|
||
"area": "string",
|
||
"capacity": "string",
|
||
"category": 0,
|
||
"meter04kvType": 0,
|
||
"region": "string",
|
||
"address": "string",
|
||
"contact": "string",
|
||
"phone": "string",
|
||
},
|
||
"user": fiber.Map{
|
||
"id": "string",
|
||
"name": "string",
|
||
"contact": "string",
|
||
"phone": "string",
|
||
"region": "string",
|
||
"address": "string",
|
||
},
|
||
}
|
||
datas := make([]interface{}, 0)
|
||
datas = append(datas, data)
|
||
//TODO: 2023-07-18 此处返回值是个示例,具体返回值需要查询数据库
|
||
return result.Success(
|
||
"withdraw请求成功",
|
||
response.NewPagedResponse(page, 20).ToMap(),
|
||
fiber.Map{"records": datas},
|
||
)
|
||
}
|