51 lines
1.7 KiB
Go
51 lines
1.7 KiB
Go
package public
|
|
|
|
import (
|
|
"gitea.party/public-messag-service/common/response"
|
|
"net/http"
|
|
)
|
|
|
|
const (
|
|
UnknownCode = -1
|
|
RespCodeErrorAuthInvalid = -4
|
|
RespCodeErrorAuthTimeout = -2
|
|
RespCodeErrorAuthOtherLogin = -3
|
|
RespCodeErrorAuthRedisNoFind = -5
|
|
RespCodeSuccess = 0 // success
|
|
CustomErrCode = UnknownCode
|
|
RespCodeErrorParam = 1
|
|
RespCodeErrorCustom = 2
|
|
RespCodeErrorUnknown = 3
|
|
RespCodeErrorAuthTokenCheckFail = 4
|
|
RespCodeErrorAuthNoPermission = 5
|
|
RespCodeErrorBadRequest = http.StatusBadRequest
|
|
|
|
RespCodeErrorSave = 10000 // 10002
|
|
RespCodeErrorAdd = 10001
|
|
RespCodeErrorDel = 10003
|
|
RespCodeErrorDataNoFind = 10004
|
|
RespCodeErrorDecodeFail = 10005 // 10006
|
|
RespCodeErrorFind = 10008
|
|
RespCodeErrorNoPermission = 11000 // 50001
|
|
RespCodeErrorBusiness = RespCodeErrorCustom
|
|
RespCodeErrorAccountInvalid = 20001
|
|
)
|
|
|
|
func init() {
|
|
response.CodeMsgMap[RespCodeSuccess] = "success"
|
|
response.CodeMsgMap[RespCodeErrorParam] = "参数错误"
|
|
response.CodeMsgMap[RespCodeErrorUnknown] = "fail"
|
|
|
|
// 401 token 错误占位
|
|
response.CodeMsgMap[RespCodeErrorBadRequest] = "token error."
|
|
|
|
// 10000+
|
|
response.CodeMsgMap[RespCodeErrorSave] = "保存失败"
|
|
response.CodeMsgMap[RespCodeErrorAdd] = "新增失败"
|
|
response.CodeMsgMap[RespCodeErrorDel] = "删除失败"
|
|
response.CodeMsgMap[RespCodeErrorFind] = "查询失败"
|
|
response.CodeMsgMap[RespCodeErrorDataNoFind] = "无数据"
|
|
response.CodeMsgMap[RespCodeErrorDecodeFail] = "数据解析失败"
|
|
response.CodeMsgMap[RespCodeErrorNoPermission] = "无权限"
|
|
}
|