From f399680158c58d49eac78d6fb92cfd09b350c742 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 22 八月 2022 15:27:21 +0800
Subject: [PATCH] 优化代码

---
 src/main/java/com/ruoyi/framework/redis/RedisCache.java                  |   18 +++---------------
 src/main/java/com/ruoyi/project/system/domain/SysDictData.java           |    2 +-
 src/main/java/com/ruoyi/project/system/controller/SysDeptController.java |   12 +-----------
 3 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/src/main/java/com/ruoyi/framework/redis/RedisCache.java b/src/main/java/com/ruoyi/framework/redis/RedisCache.java
index da5329a..121b27b 100644
--- a/src/main/java/com/ruoyi/framework/redis/RedisCache.java
+++ b/src/main/java/com/ruoyi/framework/redis/RedisCache.java
@@ -124,9 +124,9 @@
      * @param collection 澶氫釜瀵硅薄
      * @return
      */
-    public long deleteObject(final Collection collection)
+    public boolean deleteObject(final Collection collection)
     {
-        return redisTemplate.delete(collection);
+        return redisTemplate.delete(collection) > 0;
     }
 
     /**
@@ -232,18 +232,6 @@
     }
 
     /**
-     * 鍒犻櫎Hash涓殑鏁版嵁
-     * 
-     * @param key
-     * @param hKey
-     */
-    public void delCacheMapValue(final String key, final String hKey)
-    {
-        HashOperations hashOperations = redisTemplate.opsForHash();
-        hashOperations.delete(key, hKey);
-    }
-
-    /**
      * 鑾峰彇澶氫釜Hash涓殑鏁版嵁
      *
      * @param key Redis閿�
@@ -264,7 +252,7 @@
      */
     public boolean deleteCacheMapValue(final String key, final String hKey)
     {
-        return Boolean.TRUE.equals(redisTemplate.opsForHash().delete(key, hKey));
+        return redisTemplate.opsForHash().delete(key, hKey) > 0;
     }
 
     /**
diff --git a/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java b/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
index 793b0db..a4a9714 100644
--- a/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
+++ b/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
@@ -1,6 +1,5 @@
 package com.ruoyi.project.system.controller;
 
-import java.util.Iterator;
 import java.util.List;
 import org.apache.commons.lang3.ArrayUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,16 +53,7 @@
     public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
     {
         List<SysDept> depts = deptService.selectDeptList(new SysDept());
-        Iterator<SysDept> it = depts.iterator();
-        while (it.hasNext())
-        {
-            SysDept d = (SysDept) it.next();
-            if (d.getDeptId().intValue() == deptId
-                    || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
-            {
-                it.remove();
-            }
-        }
+        depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
         return AjaxResult.success(depts);
     }
 
diff --git a/src/main/java/com/ruoyi/project/system/domain/SysDictData.java b/src/main/java/com/ruoyi/project/system/domain/SysDictData.java
index 8f7ec61..7d72f89 100644
--- a/src/main/java/com/ruoyi/project/system/domain/SysDictData.java
+++ b/src/main/java/com/ruoyi/project/system/domain/SysDictData.java
@@ -131,7 +131,7 @@
 
     public boolean getDefault()
     {
-        return UserConstants.YES.equals(this.isDefault) ? true : false;
+        return UserConstants.YES.equals(this.isDefault);
     }
 
     public String getIsDefault()

--
Gitblit v1.9.3