71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package pubdef
|
|
|
|
type UserStatus int32
|
|
|
|
const (
|
|
UserStatusNormal UserStatus = 0 // 正常
|
|
UserStatusDisable UserStatus = 1 // 封禁
|
|
UserStatusSlient UserStatus = 2 // 禁言
|
|
)
|
|
|
|
var UserStatusMap = map[UserStatus]string{
|
|
UserStatusNormal: "正常",
|
|
UserStatusDisable: "封禁",
|
|
UserStatusSlient: "禁止登陆",
|
|
}
|
|
|
|
type LoginType int32
|
|
|
|
const (
|
|
LoginTypeDevice LoginType = 0 + iota // 设备登陆
|
|
LoginTypeMobile // 手机登陆
|
|
LoginTypeQrCode // 二维码登陆
|
|
LoginTypeAccount // 账号登陆
|
|
)
|
|
|
|
// SysType 客户端系统/平台类型
|
|
type SysType string
|
|
|
|
const (
|
|
ST_None SysType = ""
|
|
ST_IOS SysType = "ios"
|
|
ST_Android SysType = "android"
|
|
ST_H5 SysType = "h5"
|
|
ST_PC SysType = "pc"
|
|
ST_H5IOS SysType = "h5_ios"
|
|
ST_H5Android SysType = "h5_android"
|
|
ST_H5PC SysType = "h5_pc"
|
|
ST_Light SysType = "light"
|
|
ST_TG SysType = "tg"
|
|
ST_Web SysType = "web"
|
|
)
|
|
|
|
func (s SysType) String() string { return string(s) }
|
|
|
|
// IsH5 判断是否为 H5/Web 端
|
|
func (s SysType) IsH5() bool {
|
|
return s == ST_H5IOS || s == ST_H5Android || s == ST_H5PC ||
|
|
s == ST_H5 || s == ST_Light || s == ST_TG || s == ST_Web
|
|
}
|
|
|
|
// IsIOS 判断是否为 iOS 原生
|
|
func (s SysType) IsIOS() bool { return s == ST_IOS }
|
|
|
|
// IsAndroid 判断是否为 Android 原生
|
|
func (s SysType) IsAndroid() bool { return s == ST_Android }
|
|
|
|
// IsWeb 判断是否为 Web 端
|
|
func (s SysType) IsWeb() bool { return s == ST_Web }
|
|
|
|
// SysTypeFromString 将字符串转换为 SysType
|
|
func SysTypeFromString(s string) SysType {
|
|
switch SysType(s) {
|
|
case ST_IOS, ST_Android, ST_H5, ST_PC,
|
|
ST_H5IOS, ST_H5Android, ST_H5PC,
|
|
ST_Light, ST_TG, ST_Web:
|
|
return SysType(s)
|
|
default:
|
|
return ST_None
|
|
}
|
|
}
|