zhangqian
2024-04-25 2d6875c93b25d0b7336c7fa11e066d213259fe2e
pkg/contextx/contextx.go
@@ -47,6 +47,7 @@
   // validate params
   if params != nil {
      if err := r.ctx.ShouldBind(params); err != nil {
         logx.Errorf("validate params error:%v", err)
         r.Fail(ecode.ParamsErr)
         return
      }
@@ -81,6 +82,7 @@
   slf.ctx.JSON(http.StatusOK, ResponseList{
      Data:  data,
      Total: total,
      Code:  ecode.OK,
   })
}
@@ -96,6 +98,10 @@
   slf.Result(errCode, map[string]interface{}{}, ecode.GetMsg(errCode))
}
func (slf *Context) FailWithMsg(errCode int, msg string) {
   slf.Result(errCode, map[string]interface{}{}, msg)
}
func (slf *Context) FailWithDetailed(errCode int, data interface{}) {
   slf.Result(errCode, data, ecode.GetMsg(errCode))
}