优化mongo,封装count逻辑,处理objectId
This commit is contained in:
52
consts/auth_type.go
Normal file
52
consts/auth_type.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package consts
|
||||
|
||||
// AuthType 认证类型枚举
|
||||
type AuthType string
|
||||
|
||||
const (
|
||||
AuthTypeAPIKey AuthType = "api_key" // API密钥
|
||||
AuthTypeOAuth AuthType = "oauth" // OAuth
|
||||
AuthTypeBasic AuthType = "basic" // Basic认证
|
||||
)
|
||||
|
||||
// GetAllAuthTypes 获取所有认证类型
|
||||
func GetAllAuthTypes() []AuthType {
|
||||
return []AuthType{
|
||||
AuthTypeAPIKey,
|
||||
AuthTypeOAuth,
|
||||
AuthTypeBasic,
|
||||
}
|
||||
}
|
||||
|
||||
type AuthTypeKeyValue struct {
|
||||
Key AuthType
|
||||
Value string
|
||||
}
|
||||
|
||||
var (
|
||||
AuthTypeAPIKeyKeyValue = AuthTypeKeyValue{Key: AuthTypeAPIKey, Value: "API密钥"}
|
||||
AuthTypeOAuthKeyValue = AuthTypeKeyValue{Key: AuthTypeOAuth, Value: "OAuth"}
|
||||
AuthTypeBasicKeyValue = AuthTypeKeyValue{Key: AuthTypeBasic, Value: "Basic认证"}
|
||||
)
|
||||
|
||||
func GetAllAuthTypeKeyValue() []AuthTypeKeyValue {
|
||||
return []AuthTypeKeyValue{
|
||||
AuthTypeAPIKeyKeyValue,
|
||||
AuthTypeOAuthKeyValue,
|
||||
AuthTypeBasicKeyValue,
|
||||
}
|
||||
}
|
||||
|
||||
var authTypeValueMap = map[AuthType]string{
|
||||
AuthTypeAPIKey: AuthTypeAPIKeyKeyValue.Value,
|
||||
AuthTypeOAuth: AuthTypeOAuthKeyValue.Value,
|
||||
AuthTypeBasic: AuthTypeBasicKeyValue.Value,
|
||||
}
|
||||
|
||||
func GetAuthTypeValueByKey(key AuthType) (value string) {
|
||||
value, exists := authTypeValueMap[key]
|
||||
if !exists {
|
||||
value = "未知认证类型"
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user