54 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
package domain
 | 
						|
 | 
						|
import "strings"
 | 
						|
 | 
						|
type RedisKey string
 | 
						|
 | 
						|
const (
 | 
						|
	AccessTokenRedisKey  RedisKey = "access_token"
 | 
						|
	RefreshTokenRedisKey RedisKey = "refresh_token"
 | 
						|
	UIDTokenRedisKey     RedisKey = "uid_token"
 | 
						|
	TicketRedisKey       RedisKey = "ticket"
 | 
						|
	DeviceTokenRedisKey  RedisKey = "device_token"
 | 
						|
)
 | 
						|
 | 
						|
func (key RedisKey) ToString() string {
 | 
						|
	return "permission:" + string(key)
 | 
						|
}
 | 
						|
 | 
						|
func (key RedisKey) With(s ...string) RedisKey {
 | 
						|
	parts := append([]string{string(key)}, s...)
 | 
						|
 | 
						|
	return RedisKey(strings.Join(parts, ":"))
 | 
						|
}
 | 
						|
 | 
						|
func GetAccessTokenRedisKey(id string) string {
 | 
						|
	return AccessTokenRedisKey.With(id).ToString()
 | 
						|
}
 | 
						|
 | 
						|
func GetRefreshTokenRedisKey(id string) string {
 | 
						|
	return RefreshTokenRedisKey.With(id).ToString()
 | 
						|
}
 | 
						|
 | 
						|
func GetUIDTokenRedisKey(uid string) string {
 | 
						|
	return UIDTokenRedisKey.With(uid).ToString()
 | 
						|
}
 | 
						|
 | 
						|
func GetDeviceTokenRedisKey(device string) string {
 | 
						|
	return DeviceTokenRedisKey.With(device).ToString()
 | 
						|
}
 | 
						|
 | 
						|
func GetTicketRedisKey(ticket string) string {
 | 
						|
	return TicketRedisKey.With(ticket).ToString()
 | 
						|
}
 | 
						|
 | 
						|
// ===================
 | 
						|
 | 
						|
const (
 | 
						|
	CasbinRuleRedisKey RedisKey = "casbin_rule"
 | 
						|
)
 | 
						|
 | 
						|
func GetCasbinRuleRedisKey() string {
 | 
						|
	return CasbinRuleRedisKey.ToString()
 | 
						|
}
 |