31 lines
653 B
Go
Executable File
31 lines
653 B
Go
Executable File
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)
|
|
}
|