Use utils.HttpResponse/Abort to replace c.JSON/Abort
All checks were successful
Build Backend (NixCN CMS) TeamCity build finished
Build Frontend (NixCN CMS) TeamCity build finished

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-06 12:49:55 +08:00
parent 70846e0d1e
commit 6a9c013799
14 changed files with 203 additions and 116 deletions

30
utils/response.go Normal file
View File

@@ -0,0 +1,30 @@
package utils
import "github.com/gin-gonic/gin"
type RespStatus struct {
Code int `json:"code"`
ErrorId string `json:"error_id"`
Status string `json:"status"`
Data any `json:"data"`
}
func HttpResponse(c *gin.Context, code int, errorId string, status string, data ...any) {
var resp = RespStatus{
Code: code,
ErrorId: errorId,
Status: status,
Data: data,
}
c.JSON(code, resp)
}
func HttpAbort(c *gin.Context, code int, errorId string, status string, data ...any) {
var resp = RespStatus{
Code: code,
ErrorId: errorId,
Status: status,
Data: data,
}
c.AbortWithStatusJSON(code, resp)
}