12345678910111213141516171819202122232425 |
- package controller
- import "github.com/gin-gonic/gin"
- type JsonStruct struct {
- Code int `json:"code"`
- Msg interface{} `json:"msg"`
- Data interface{} `json:"data"`
- //Count int64 `json:"count"`
- }
- type JsonErrStruct struct {
- Code int `json:"code"`
- Msg interface{} `json:"msg"`
- }
- func returnSuccess(c *gin.Context, code int, data interface{}) {
- json := &JsonStruct{Code: code, Msg: "ok", Data: data}
- c.JSON(200, json)
- }
- func returnError(c *gin.Context, code int) {
- json := &JsonErrStruct{Code: code, Msg: "error"}
- c.JSON(400, json)
- }
|