| | |
| | | Data interface{} `json:"data"` |
| | | Msg string `json:"msg"` |
| | | } |
| | | ResponseList struct { |
| | | Code int `json:"code"` |
| | | Data interface{} `json:"data"` |
| | | Msg string `json:"msg"` |
| | | Total int64 `json:"total"` |
| | | } |
| | | ) |
| | | |
| | | func NewContext(ctx *gin.Context, params interface{}) (r *Context, isAllow bool) { |
| | |
| | | }) |
| | | } |
| | | |
| | | func (slf *Context) ResultList(data interface{}, total int64) { |
| | | slf.ctx.JSON(http.StatusOK, ResponseList{ |
| | | Data: data, |
| | | Total: total, |
| | | Code: ecode.OK, |
| | | }) |
| | | } |
| | | |
| | | func (slf *Context) Ok() { |
| | | slf.Result(ecode.OK, map[string]interface{}{}, "") |
| | | } |
| | |
| | | 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)) |
| | | } |