1、response修改 2、负数扣款
This commit is contained in:
@@ -2,8 +2,13 @@ package errs
|
||||
|
||||
// 常见错误
|
||||
var (
|
||||
ErrSystem = NewAppError(1001, "业务失败")
|
||||
ErrParamDecryption = NewAppError(1002, "参数解密失败")
|
||||
ErrParamValidation = NewAppError(1003, "校验参数不正确")
|
||||
ErrDataSource = NewAppError(1004, "数据源异常")
|
||||
ErrSystem = NewAppError(1001, "接口异常")
|
||||
ErrParamDecryption = NewAppError(1002, "参数解密失败")
|
||||
ErrParamValidation = NewAppError(1003, "基础参数校验不正确")
|
||||
ErrUnauthorizedIP = NewAppError(1004, "未经授权的IP")
|
||||
ErrMissingAccessID = NewAppError(1005, "缺少Access-Id")
|
||||
ErrUnauthorizedAccessID = NewAppError(1006, "未经授权的AccessId")
|
||||
ErrInsufficientBalance = NewAppError(1007, "账户余额不足,无法请求")
|
||||
ErrProductNotAvailable = NewAppError(1008, "未开通此产品")
|
||||
ErrDataSource = NewAppError(2001, "业务失败")
|
||||
)
|
||||
|
||||
@@ -44,10 +44,10 @@ func sendResponse(ctx context.Context, w http.ResponseWriter, code int, message
|
||||
|
||||
// 响应成功
|
||||
func Success(ctx context.Context, w http.ResponseWriter, data interface{}) {
|
||||
sendResponse(ctx, w, 0, "success", data)
|
||||
sendResponse(ctx, w, 0, "业务成功", data)
|
||||
}
|
||||
|
||||
// 响应失败
|
||||
func Fail(ctx context.Context, w http.ResponseWriter, err *errs.AppError) {
|
||||
sendResponse(ctx, w, err.Code, err.Message, nil)
|
||||
func Fail(ctx context.Context, w http.ResponseWriter, err *errs.AppError, data interface{}) {
|
||||
sendResponse(ctx, w, err.Code, err.Message, data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user