修复错误购买报错的问题,修复接口返回虚流量启动错误的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m48s

This commit is contained in:
Break
2026-06-11 14:51:26 +08:00
parent 134021c91e
commit c437593a8c
9 changed files with 145 additions and 196 deletions

View File

@@ -39,6 +39,22 @@ func SuccessWithMessage(c *fiber.Ctx, data any, message string) error {
return err
}
// Business 返回带业务码的统一响应,并保留业务数据。
// 适用于批量接口需要返回失败明细但外层 code 不能为 0 的场景。
func Business(c *fiber.Ctx, code int, data any, message string) error {
if message == "" {
message = errors.GetMessage(code, "zh-CN")
}
err := c.JSON(Response{
Code: code,
Data: data,
Message: message,
Timestamp: time.Now().Format(time.RFC3339),
})
c.Set(fiber.HeaderContentType, "application/json; charset=utf-8")
return err
}
// PaginationData 分页数据结构
type PaginationData struct {
Items any `json:"items"` // 数据列表