新增:完善withdraw的返回值

This commit is contained in:
2023-07-20 16:13:19 +08:00
parent 648fc0f370
commit 61edef5c92
8 changed files with 294 additions and 43 deletions

View File

@@ -23,7 +23,8 @@ func InitializeReportHandlers(router *fiber.App) {
router.Get("/reports", security.MustAuthenticated, reportComprehensiveSearch)
router.Post("/report", security.EnterpriseAuthorize, initNewReportCalculateTask)
router.Get("/report/draft", security.EnterpriseAuthorize, listDraftReportIndicies)
router.Post("/report/calcualte", security.EnterpriseAuthorize, testCalculateReportSummary)
//TODO: 2023-07-20将calcualte错误请求改为正确的calculate请求
router.Post("/report/calculate", security.EnterpriseAuthorize, testCalculateReportSummary)
router.Get("/report/calculate/status", security.EnterpriseAuthorize, listCalculateTaskStatus)
router.Get("/report/:rid", security.EnterpriseAuthorize, getReportDetail)
router.Put("/report/:rid", security.EnterpriseAuthorize, updateReportCalculateTask)

View File

@@ -25,9 +25,11 @@ func InitializeTenementHandler(router *fiber.App) {
router.Put("/tenement/:pid/:tid", security.EnterpriseAuthorize, updateTenement)
router.Get("/tenement/:pid/:tid", security.EnterpriseAuthorize, getTenementDetail)
router.Get("/tenement/:pid/:tid/meter", security.EnterpriseAuthorize, listMeters)
//TODO: 2023-07-19再apiFox上该请求是个PUT请求后端接收是个POST请求不知道是否有误或是缺少对应请求apiFox测试请求返回值为405
router.Post("/tenement/:pid/:tid/move/out", security.EnterpriseAuthorize, moveOutTenement)
router.Post("/tenement/:pid", security.EnterpriseAuthorize, addTenement)
router.Post("/tenement/:pid/:tid/binding", security.EnterpriseAuthorize, bindMeterToTenement)
//TODO: 2023-07-19再apiFox上该请求是个PUT请求后端接收是个POST请求不知道是否有误或是缺少对应请求apiFox测试请求返回值为405
router.Post("/tenement/:pid/:tid/binding/:code/unbind", security.EnterpriseAuthorize, unbindMeterFromTenement)
}

View File

@@ -2,9 +2,11 @@ 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")
@@ -24,51 +26,15 @@ func withdraw(c *fiber.Ctx) error {
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",
},
withdraws, total, err := repository.WithdrawRepository.FindWithdraw(page, &keyword)
if err != nil {
withdrawLog.Error("检索用户核算报表失败。", zap.Error(err))
return result.Error(http.StatusInternalServerError, err.Error())
}
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},
response.NewPagedResponse(page, total).ToMap(),
fiber.Map{"records": withdraws},
)
}