app-cloudep-member-server/pkg/domain/redis.go

47 lines
977 B
Go
Raw Permalink Normal View History

2024-12-30 03:58:14 +00:00
package domain
import (
"fmt"
"strings"
)
type RedisKey string
const (
AccountRedisKey RedisKey = "account"
AccountUIDRedisKey RedisKey = "account_uid"
UserRedisKey RedisKey = "user"
MemberPrefixRedisKey = "member"
)
func (key RedisKey) ToString() string {
return "member:" + string(key)
}
func (key RedisKey) With(s ...string) RedisKey {
parts := append([]string{string(key)}, s...)
return RedisKey(strings.Join(parts, ":"))
}
func GetAccountRedisKey(id string) string {
return AccountRedisKey.With(id).ToString()
}
func GetAccountUIDRedisKey(id string) string {
return AccountUIDRedisKey.With(id).ToString()
}
func GetUserRedisKey(id string) string {
return UserRedisKey.With(id).ToString()
}
var (
// checkVerifyKey 驗證碼驗證
checkVerifyKey = fmt.Sprintf("%s:verify:", MemberPrefixRedisKey)
)
func GetCheckVerifyKey(codeType, account string) string {
return fmt.Sprintf("%s%s:%s", checkVerifyKey, codeType, account)
}