response.go 406 B

1234567891011121314151617181920212223242526
  1. package app
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "lttc-go-adm-znaf/pkg/e"
  5. )
  6. type Gin struct {
  7. C *gin.Context
  8. }
  9. type Response struct {
  10. Code int `json:"code"`
  11. Msg string `json:"msg"`
  12. Data interface{} `json:"data"`
  13. }
  14. func (g *Gin) Response(httpCode, errCode int, data interface{}) {
  15. g.C.JSON(httpCode, Response{
  16. Code: errCode,
  17. Msg: e.GetMsg(errCode),
  18. Data: data,
  19. })
  20. return
  21. }