controller.go 324 B

123456789101112131415161718192021
  1. package common
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "net/http"
  5. )
  6. type BaseCtl struct {
  7. }
  8. func (ctl *BaseCtl) RespError(c *gin.Context, e error) {
  9. c.JSON(http.StatusOK, gin.H{
  10. "error": e.Error(),
  11. })
  12. }
  13. func (ctl *BaseCtl) RespOk(c *gin.Context, data interface{}) {
  14. c.JSON(http.StatusOK, gin.H{
  15. "data": data,
  16. })
  17. }