ETCD后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1020 B

3 years ago
  1. /*
  2. * @Author: your name
  3. * @Date: 2020-11-20 10:50:43
  4. * @LastEditTime: 2020-11-20 10:50:54
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /ckp_admin_gin/app/util/response/response.go
  8. */
  9. package response
  10. import "github.com/gin-gonic/gin"
  11. type Gin struct {
  12. Ctx *gin.Context
  13. }
  14. type Response struct {
  15. Code int `json:"code"`
  16. Message string `json:"msg"`
  17. Data interface{} `json:"data"`
  18. }
  19. type Total struct {
  20. Code int `json:"code"`
  21. Message string `json:"msg"`
  22. Data interface{} `json:"data"`
  23. Count int64 `json:"count"`
  24. }
  25. //返回带总条数结构体
  26. func (g *Gin) ResponseTotal(code int, msg string, data interface{},Count int64) {
  27. g.Ctx.JSON(200, Total{
  28. Code: code,
  29. Message: msg,
  30. Data: data,
  31. Count: Count,
  32. })
  33. return
  34. }
  35. func (g *Gin) Response(code int, msg string, data interface{}) {
  36. g.Ctx.JSON(200, Response{
  37. Code: code,
  38. Message: msg,
  39. Data: data,
  40. })
  41. if code != 200{
  42. println(msg)
  43. }
  44. return
  45. }