5b2092033b5f2d039b9bba95f0974323534602db.svn-base 511 B

12345678910111213141516171819202122232425262728293031
  1. package app
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "../../pkg/e"
  5. )
  6. type Gin struct {
  7. C *gin.Context
  8. }
  9. func (g *Gin) Response(httpCode, errCode int, data interface{}) {
  10. g.C.JSON(httpCode, gin.H{
  11. "code": httpCode,
  12. "msg": e.GetMsg(errCode),
  13. "data": data,
  14. })
  15. return
  16. }
  17. func (g *Gin) ResponseEq(httpCode, errCode int, errorNo int, data interface{}) {
  18. g.C.JSON(httpCode, gin.H{
  19. "code": httpCode,
  20. "message": e.GetMsg(errCode),
  21. "results": data,
  22. "errorNo": errorNo,
  23. "success": 1,
  24. })
  25. return
  26. }