改变路由层级,模块化

This commit is contained in:
2023-01-18 15:40:27 +08:00
parent bd25f041a2
commit 0f8c1f989b
102 changed files with 335 additions and 322 deletions
+30
View File
@@ -0,0 +1,30 @@
package cache
import (
models2 "cutego/modules/core/entity"
"cutego/pkg/cache"
"cutego/pkg/common"
"cutego/pkg/constant"
)
// GetRedisConfig 根据key从缓存中获取配置数据
// @Param key 键
// @Return *models2.SysConfig
func GetRedisConfig(key string) *models2.SysConfig {
val := cache.GetCache(constant.RedisConst{}.GetRedisConfigKey() + key)
s := new(models2.SysConfig)
return common.JsonToStruct(val, s).(*models2.SysConfig)
}
// SetRedisConfig 将配置存入缓存
// @Param config models2.SysConfig
func SetRedisConfig(config models2.SysConfig) {
cache.SetCache(config.ConfigKey, common.StructToJson(config))
}
// RemoveRedisConfig 从缓存中删除配置
// @Param configKey string 配置键
// @Return 影响的行数
func RemoveRedisConfig(configKey string) int {
return cache.RemoveCache(constant.RedisConst{}.GetRedisConfigKey() + configKey)
}
+35
View File
@@ -0,0 +1,35 @@
package cache
import (
models2 "cutego/modules/core/entity"
"cutego/pkg/cache"
"cutego/pkg/common"
"cutego/pkg/constant"
)
// GetRedisDict 根据key获取缓存中的字典数据
// @Param key string 键
// @Return interface {}
func GetRedisDict(key string) interface{} {
val := cache.GetCache(key)
s := make([]interface{}, 0)
return common.JsonToStruct(val, s)
}
// SetRedisDict 保存字典数据
// @Param dictType string 字典类型
// @Param list []models2.SysDictData
func SetRedisDict(dictType string, list []models2.SysDictData) {
cache.SetCache(constant.RedisConst{}.GetRedisDictKey()+dictType, list)
}
// RemoveRedisDictList 批量删除字典数据
// @Param dictType []string 字典类型集合
func RemoveRedisDictList(dictType []string) {
includeKey := make([]string, 0)
header := constant.RedisConst{}.GetRedisDictKey()
for _, e := range dictType {
includeKey = append(includeKey, header+e)
}
cache.RemoveList(includeKey)
}
+24
View File
@@ -0,0 +1,24 @@
package cache
import (
"cutego/pkg/cache"
"cutego/pkg/config"
"cutego/pkg/constant"
)
// SetRedisToken 将token存入到redis
// @Param username string 用户名
// @Param token string token令牌
func SetRedisToken(username string, token string) {
if config.AppEnvConfig.Login.Single {
cache.SetCacheTTL(constant.RedisOnlineUserKey+username, token, 3600)
}
}
// RemoveRedisToken 将token从redis中删除
// @Param username string 用户名
// @Return 删除的行数
func RemoveRedisToken(username string) int {
// 不管是不是单点登录, 直接踢
return cache.RemoveCache(constant.RedisOnlineUserKey + username)
}