Documentation ¶
Index ¶
- Constants
- func Bad(w http.ResponseWriter, params ...any)
- func BadError(w http.ResponseWriter, status int, data any, params ...any)
- func BadW(w http.ResponseWriter, msg string) error
- func Forbidden(w http.ResponseWriter, err any)
- func GetClientIP(r *http.Request) string
- func GetOrigin(r *http.Request) string
- func GetUserAgent(r *http.Request) useragent.UserAgent
- func IsEmail(email string) bool
- func IsGroupName(nickname string) bool
- func IsHash(s string) bool
- func IsIncludeForbiddenChar(value string) bool
- func IsLessEndTime(fl validator.FieldLevel) bool
- func IsLessThanNow(fl validator.FieldLevel) bool
- func IsMobile(mobile string) bool
- func IsMoreThanNow(fl validator.FieldLevel) bool
- func IsNickname(nickname string) bool
- func IsPassword(password string, chains ...func(string) bool) bool
- func IsPasswordSpecialLetter(r rune) bool
- func IsUserName(username string) bool
- func MapStructDecode(input interface{}, output interface{}) error
- func Ok(w http.ResponseWriter, params ...any)
- func OkList(w http.ResponseWriter, list any, total int64)
- func SetContext(r *http.Request, key string, value any) *http.Request
- func SetFieldMap(t map[string]string)
- func SetTagMap(t map[string]string)
- func ShouldJson(r *http.Request, obj any) error
- func UidGet(r *http.Request) int64
- func UidSet(r *http.Request, uid int64) *http.Request
- func ValidateStruct(obj any) error
- type JsonDataBody
- type JsonListBody
- type JsonRawBody
- type SliceValidationError
Constants ¶
const ( MaxUsernameLength = 20 MinUsernameLength = 3 MaxNicknameLength = 20 MinNicknameLength = 2 MaxGroupnameLength = 20 MinGroupnameLength = 2 MaxPasswordLength = 20 MinPasswordLength = 6 )
const ( PasswordUpper int = 1 << iota PasswordLower PasswordDigit PasswordSpecial )
1大写,2小写,4数字,8符号
const PasswordSpecialLetter = "!@#$%^&."
Variables ¶
This section is empty.
Functions ¶
func BadError ¶
func BadError(w http.ResponseWriter, status int, data any, params ...any)
BadError 返回错误信息
func GetClientIP ¶
func IsGroupName ¶
IsGroupName 部门名称 长度2-20个UTF-8字符 可使用除了禁止输入字符之外的任意字符
func IsIncludeForbiddenChar ¶
IsIncludeForbiddenChar 是否包含禁用字符,空格 ; 分号 -- 连续的减号 " " 引号 { } 大括号 [ ] 中括号 ( ) 小括号
func IsLessEndTime ¶
func IsLessEndTime(fl validator.FieldLevel) bool
func IsNickname ¶
IsNickname 姓名 长度2-20个UTF-8字符 可使用除了禁止输入字符之外的任意字符
func IsPassword ¶
IsPassword 1. 设置密码规则有,最小长度默认最小长度6个字符,字符不能小于6个,默认最大密码长度(20) 2. 设置包含:大写字母、小写字母、数字和字符(默认都不开启) 3. 开启限制后,用户注册必须按照规范注册用户 4. 已经注册过的用户,登录时不按照密码规则校验 5. 密码特殊字符包括: !@#$%^&. 6. 默认密码不开启验证时,密码必须属于写字母、小写字母、数字和字符中一种或多种组合
func IsPasswordSpecialLetter ¶
func MapStructDecode ¶
func MapStructDecode(input interface{}, output interface{}) error
MapStructDecode takes an input structure and uses reflection to translate it to the output structure. output must be a pointer to a map or struct.
func SetFieldMap ¶
func ValidateStruct ¶
ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.
Types ¶
type JsonDataBody ¶
type JsonDataBody struct { Code int `json:"code"` Msg string `json:"msg"` Data any `json:"data,omitempty"` }
JsonDataBody json响应体
type JsonListBody ¶
type JsonListBody struct { List any `json:"list"` Total int64 `json:"total"` Code int `json:"code,omitempty"` Msg string `json:"msg,omitempty"` }
JsonListBody 分页响应体
type JsonRawBody ¶
type SliceValidationError ¶
type SliceValidationError []error
func (SliceValidationError) Error ¶
func (err SliceValidationError) Error() string
Error concatenates all error elements in SliceValidationError into a single string separated by \n.