refactor: 移除冗余错误日志并优化缓存获取逻辑

This commit is contained in:
TsMask
2025-03-03 18:06:30 +08:00
parent c286e68845
commit 2829361748
4 changed files with 11 additions and 8 deletions

View File

@@ -42,7 +42,6 @@ func (r *UDMAuthUser) SelectPage(query map[string]string) (int64, []model.UDMAut
// 查询数量 长度为0直接返回
if err := tx.Count(&total).Error; err != nil || total <= 0 {
logger.Errorf("total err => %v", err)
return total, rows
}

View File

@@ -45,7 +45,6 @@ func (r *UDMSubUser) SelectPage(query map[string]string) (int64, []model.UDMSubU
// 查询数量 长度为0直接返回
if err := tx.Count(&total).Error; err != nil || total <= 0 {
logger.Errorf("total err => %v", err)
return total, rows
}

View File

@@ -86,12 +86,17 @@ func (r NeInfo) ClearNeCacheByNeType(neType string) bool {
func (r NeInfo) FindByNeType(neType string) []model.NeInfo {
neInfo := make([]model.NeInfo, 0)
key := fmt.Sprintf("%s:%s:*", constants.CACHE_NE_INFO, strings.ToUpper(neType))
jsonStr, _ := redis.Get("", key)
if len(jsonStr) > 7 {
err := json.Unmarshal([]byte(jsonStr), &neInfo)
if err != nil {
return neInfo
cacheKeys, _ := redis.GetKeys("", key)
if len(cacheKeys) > 0 {
for _, key := range cacheKeys {
var v model.NeInfo
jsonStr, _ := redis.Get("", key)
if len(jsonStr) > 7 {
json.Unmarshal([]byte(jsonStr), &v)
}
neInfo = append(neInfo, v)
}
return neInfo
} else {
neInfo = r.neInfoRepository.SelectList(model.NeInfo{NeType: neType})
for _, v := range neInfo {

View File

@@ -68,7 +68,7 @@ func (r SysMenu) SelectByIds(menuIds []int64) []model.SysMenu {
// Insert 新增信息
func (r SysMenu) Insert(sysMenu model.SysMenu) int64 {
sysMenu.DelFlag = "0"
if sysMenu.MenuId <= 0 {
if sysMenu.MenuId > 0 {
return 0
}
if sysMenu.Icon == "" {