refactor: 移除冗余错误日志并优化缓存获取逻辑
This commit is contained in:
@@ -42,7 +42,6 @@ func (r *UDMAuthUser) SelectPage(query map[string]string) (int64, []model.UDMAut
|
|||||||
|
|
||||||
// 查询数量 长度为0直接返回
|
// 查询数量 长度为0直接返回
|
||||||
if err := tx.Count(&total).Error; err != nil || total <= 0 {
|
if err := tx.Count(&total).Error; err != nil || total <= 0 {
|
||||||
logger.Errorf("total err => %v", err)
|
|
||||||
return total, rows
|
return total, rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ func (r *UDMSubUser) SelectPage(query map[string]string) (int64, []model.UDMSubU
|
|||||||
|
|
||||||
// 查询数量 长度为0直接返回
|
// 查询数量 长度为0直接返回
|
||||||
if err := tx.Count(&total).Error; err != nil || total <= 0 {
|
if err := tx.Count(&total).Error; err != nil || total <= 0 {
|
||||||
logger.Errorf("total err => %v", err)
|
|
||||||
return total, rows
|
return total, rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,12 +86,17 @@ func (r NeInfo) ClearNeCacheByNeType(neType string) bool {
|
|||||||
func (r NeInfo) FindByNeType(neType string) []model.NeInfo {
|
func (r NeInfo) FindByNeType(neType string) []model.NeInfo {
|
||||||
neInfo := make([]model.NeInfo, 0)
|
neInfo := make([]model.NeInfo, 0)
|
||||||
key := fmt.Sprintf("%s:%s:*", constants.CACHE_NE_INFO, strings.ToUpper(neType))
|
key := fmt.Sprintf("%s:%s:*", constants.CACHE_NE_INFO, strings.ToUpper(neType))
|
||||||
|
cacheKeys, _ := redis.GetKeys("", key)
|
||||||
|
if len(cacheKeys) > 0 {
|
||||||
|
for _, key := range cacheKeys {
|
||||||
|
var v model.NeInfo
|
||||||
jsonStr, _ := redis.Get("", key)
|
jsonStr, _ := redis.Get("", key)
|
||||||
if len(jsonStr) > 7 {
|
if len(jsonStr) > 7 {
|
||||||
err := json.Unmarshal([]byte(jsonStr), &neInfo)
|
json.Unmarshal([]byte(jsonStr), &v)
|
||||||
if err != nil {
|
|
||||||
return neInfo
|
|
||||||
}
|
}
|
||||||
|
neInfo = append(neInfo, v)
|
||||||
|
}
|
||||||
|
return neInfo
|
||||||
} else {
|
} else {
|
||||||
neInfo = r.neInfoRepository.SelectList(model.NeInfo{NeType: neType})
|
neInfo = r.neInfoRepository.SelectList(model.NeInfo{NeType: neType})
|
||||||
for _, v := range neInfo {
|
for _, v := range neInfo {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (r SysMenu) SelectByIds(menuIds []int64) []model.SysMenu {
|
|||||||
// Insert 新增信息
|
// Insert 新增信息
|
||||||
func (r SysMenu) Insert(sysMenu model.SysMenu) int64 {
|
func (r SysMenu) Insert(sysMenu model.SysMenu) int64 {
|
||||||
sysMenu.DelFlag = "0"
|
sysMenu.DelFlag = "0"
|
||||||
if sysMenu.MenuId <= 0 {
|
if sysMenu.MenuId > 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if sysMenu.Icon == "" {
|
if sysMenu.Icon == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user