|
|
- /*
- * @Author: your name
- * @Date: 2020-11-20 10:50:43
- * @LastEditTime: 2020-11-20 10:50:54
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: /ckp_admin_gin/app/util/response/response.go
- */
- package response
-
- import "github.com/gin-gonic/gin"
-
- type Gin struct {
- Ctx *gin.Context
- }
-
- type Response struct {
- Code int `json:"code"`
- Message string `json:"msg"`
- Data interface{} `json:"data"`
- }
- type Total struct {
- Code int `json:"code"`
- Message string `json:"msg"`
- Data interface{} `json:"data"`
- Count int64 `json:"count"`
- }
- //返回带总条数结构体
- func (g *Gin) ResponseTotal(code int, msg string, data interface{},Count int64) {
- g.Ctx.JSON(200, Total{
- Code: code,
- Message: msg,
- Data: data,
- Count: Count,
- })
- return
- }
- func (g *Gin) Response(code int, msg string, data interface{}) {
- g.Ctx.JSON(200, Response{
- Code: code,
- Message: msg,
- Data: data,
- })
- if code != 200{
- println(msg)
- }
- return
- }
|