2017-04-21 18:20:35 +08:00
|
|
|
|
// Package models 为项目所需的模型对象定义.
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
2017-05-24 20:31:58 +08:00
|
|
|
|
var (
|
2017-04-21 18:20:35 +08:00
|
|
|
|
// ErrMemberNoExist 用户不存在.
|
2018-01-26 17:17:38 +08:00
|
|
|
|
ErrMemberNoExist = errors.New("用户不存在")
|
|
|
|
|
ErrMemberExist = errors.New("用户已存在")
|
|
|
|
|
ErrMemberDisabled = errors.New("用户被禁用")
|
|
|
|
|
ErrMemberEmailEmpty = errors.New("用户邮箱不能为空")
|
|
|
|
|
ErrMemberEmailExist = errors.New("用户邮箱已被使用")
|
|
|
|
|
ErrMemberDescriptionTooLong = errors.New("用户描述必须小于500字")
|
|
|
|
|
ErrMemberEmailFormatError = errors.New("邮箱格式不正确")
|
2017-05-25 18:18:43 +08:00
|
|
|
|
ErrMemberPasswordFormatError = errors.New("密码必须在6-50个字符之间")
|
2018-01-26 17:17:38 +08:00
|
|
|
|
ErrMemberAccountFormatError = errors.New("账号只能由英文字母数字组成,且在3-50个字符")
|
|
|
|
|
ErrMemberRoleError = errors.New("用户权限不正确")
|
2017-04-21 18:20:35 +08:00
|
|
|
|
// ErrorMemberPasswordError 密码错误.
|
|
|
|
|
ErrorMemberPasswordError = errors.New("用户密码错误")
|
2017-05-24 20:31:58 +08:00
|
|
|
|
//ErrorMemberAuthMethodInvalid 不支持此认证方式
|
|
|
|
|
ErrMemberAuthMethodInvalid = errors.New("不支持此认证方式")
|
2021-03-18 15:02:19 +08:00
|
|
|
|
//ErrHTTPServerFail
|
|
|
|
|
ErrHTTPServerFail = errors.New("系统内部异常")
|
2017-05-24 20:31:58 +08:00
|
|
|
|
//ErrLDAPConnect 无法连接到LDAP服务器
|
|
|
|
|
ErrLDAPConnect = errors.New("无法连接到LDAP服务器")
|
|
|
|
|
//ErrLDAPFirstBind 第一次LDAP绑定失败
|
|
|
|
|
ErrLDAPFirstBind = errors.New("第一次LDAP绑定失败")
|
|
|
|
|
//ErrLDAPSearch LDAP搜索失败
|
|
|
|
|
ErrLDAPSearch = errors.New("LDAP搜索失败")
|
|
|
|
|
//ErrLDAPUserNotFoundOrTooMany
|
|
|
|
|
ErrLDAPUserNotFoundOrTooMany = errors.New("LDAP用户不存在或者多于一个")
|
|
|
|
|
|
2017-04-23 20:33:21 +08:00
|
|
|
|
// ErrDataNotExist 指定的服务已存在.
|
|
|
|
|
ErrDataNotExist = errors.New("数据不存在")
|
2017-04-21 18:20:35 +08:00
|
|
|
|
|
|
|
|
|
// ErrInvalidParameter 参数错误.
|
|
|
|
|
ErrInvalidParameter = errors.New("Invalid parameter")
|
2017-04-22 17:24:17 +08:00
|
|
|
|
|
|
|
|
|
ErrPermissionDenied = errors.New("Permission denied")
|
2017-04-23 20:33:21 +08:00
|
|
|
|
|
2017-05-24 20:31:58 +08:00
|
|
|
|
ErrCommentClosed = errors.New("评论已关闭")
|
2017-04-23 20:33:21 +08:00
|
|
|
|
ErrCommentContentNotEmpty = errors.New("评论内容不能为空")
|
2017-04-21 18:20:35 +08:00
|
|
|
|
)
|
2018-11-05 18:50:01 +08:00
|
|
|
|
|
|
|
|
|
type Error struct {
|
|
|
|
|
code int
|
|
|
|
|
message string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Error) Error() string {
|
|
|
|
|
return e.message
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Error) Code() int {
|
|
|
|
|
return e.code
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewError(code int, message string) Error {
|
|
|
|
|
return Error{code: code, message: message}
|
|
|
|
|
}
|