This commit is contained in:
2025-05-16 23:42:23 +08:00
commit 0deca45d06
19 changed files with 5274 additions and 0 deletions

30
response/response.go Executable file
View File

@@ -0,0 +1,30 @@
package response
import (
"github.com/gin-gonic/gin"
"net/http"
"video/utils/code"
)
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Msg string `json:"msg"`
}
// Result ... 正常业务获得结果
func Result(code int, data interface{}, msg string, c *gin.Context) {
c.JSON(http.StatusOK, Response{code, data, msg})
}
func Success(c *gin.Context) {
SuccessMsg("操作成功", c)
}
func SuccessMsg(message string, c *gin.Context) {
Result(code.SUCCESS, map[string]interface{}{}, message, c)
}
func SuccessData(data interface{}, c *gin.Context) {
Result(code.SUCCESS, data, "操作成功", c)
}