This commit is contained in:
2024-08-26 17:20:13 +08:00
commit 51090658a2
39 changed files with 2231 additions and 0 deletions

30
response/response.go Normal file
View File

@@ -0,0 +1,30 @@
package response
import (
"energy-management-system/utils/exception"
"github.com/gin-gonic/gin"
"net/http"
)
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(exception.SUCCESS, map[string]interface{}{}, message, c)
}
func SuccessData(data interface{}, c *gin.Context) {
Result(exception.SUCCESS, data, "操作成功", c)
}