| | |
| | | // validate params |
| | | if params != nil { |
| | | if err := r.ctx.ShouldBind(params); err != nil { |
| | | r.Fail(ecode.ParamsErr) |
| | | logx.Errorf("bind param error: %v", err.Error()) |
| | | r.FailWithMsg(ecode.ParamsErr, err.Error()) |
| | | return |
| | | } |
| | | } |
| | |
| | | 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)) |
| | | } |