enhance(response):调整基础响应构建功能。

This commit is contained in:
徐涛
2022-08-12 13:39:58 +08:00
parent a09629ee2b
commit b9b9a9c738
2 changed files with 15 additions and 5 deletions

View File

@@ -15,6 +15,12 @@ type BaseResponse struct {
Message string `json:"message"`
}
type PagedResponse struct {
Page int `json:"page"`
Size int `json:"pageSize"`
Total int `json:"total"`
}
func NewResult(ctx *gin.Context) *Result {
return &Result{Ctx: ctx}
}
@@ -77,7 +83,7 @@ func (r *Result) NotFound(msg string) {
// 快速自由JSON格式响应
// ! 注意给定的map中同名的键会被覆盖。
func (r *Result) QuickJson(status, code int, msg string, payloads ...map[string]interface{}) {
func (r *Result) Json(status, code int, msg string, payloads ...map[string]interface{}) {
var finalPayload = make(map[string]interface{}, 0)
finalPayload["code"] = code
finalPayload["message"] = &msg