Documentation ¶
Index ¶
- Constants
- func CreateParamErrorMsg(filed string, tag string) string
- type Response
- func CreateDBErrorResponse(msg string, err error) Response
- func CreateErrorResponse(errCode int, msg string, err error) Response
- func CreateGeneralParamErrorResponse(msg string, err error) Response
- func CreateInternalErrorResponse(msg string, err error) Response
- func CreateParamErrorResponse(err error) Response
- func CreateSuccessResponse(data interface{}, msg string) Response
- func CreateUserResponse(user *model.User) Response
- func GetUnauthorizedResponse() Response
- type ServiceError
- type UserDTO
Constants ¶
View Source
const ( CodeSuccess = 200 CodeForbidden = 403 // 无权限 CodeInternalError = 1000 // 内部错误 CodeDBError = 1001 // 数据库错误 CodeParamError = 1002 // 参数错误 CodeConditionNotMeet = 1003 // 条件不满足错误 CodeAdminRequired = 2000 // 需要为管理员账号 CodeActiveRequired = 2001 // 需要为激活账号 )
Variables ¶
This section is empty.
Functions ¶
func CreateParamErrorMsg ¶
Types ¶
type Response ¶
type Response struct { Code int `json:"code"` // 响应代码 Data interface{} `json:"data,omitempty"` // 数据 Msg string `json:"msg"` // 消息 Error string `json:"error,omitempty"` // 错误 }
响应体
func CreateDBErrorResponse ¶
func CreateSuccessResponse ¶
func CreateUserResponse ¶
type ServiceError ¶
func NewServiceError ¶
func NewServiceError(code int, msg string, err error) ServiceError
func (*ServiceError) WrapError ¶
func (se *ServiceError) WrapError(err error) ServiceError
Click to show internal directories.
Click to hide internal directories.