zrj
2024-06-05 4ac064d42140a32169745e2498387a9413b105b6
blade-auth/src/main/java/org/springblade/common/cache/DictCache.java
File was renamed from blade-auth/src/main/java/org/springblade/system/cache/DictCache.java
@@ -14,14 +14,13 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.system.cache;
package org.springblade.common.cache;
import org.springblade.common.enums.DictEnum;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.system.entity.Dict;
import org.springblade.system.enums.DictEnum;
import org.springblade.system.service.IDictService;
import java.util.List;
@@ -43,13 +42,10 @@
   private static final Boolean TENANT_MODE = Boolean.FALSE;
   private static IDictService dictClient;
   private static final IDictService dictService;
   private static IDictService getDictClient() {
      if (dictClient == null) {
         dictClient = SpringUtil.getBean(IDictService.class);
      }
      return dictClient;
   static {
      dictService = SpringUtil.getBean(IDictService.class);
   }
   /**
@@ -59,10 +55,7 @@
    * @return Dict
    */
   public static Dict getById(Long id) {
      return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> {
         Dict result = getDictClient().getById(id);
         return result;
      }, TENANT_MODE);
      return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> dictService.getById(id), TENANT_MODE);
   }
   /**
@@ -104,7 +97,6 @@
      return getValue(code.getName(), dictKey);
   }
   /**
    * 获取字典值
    *
@@ -113,10 +105,7 @@
    * @return String
    */
   public static String getValue(String code, Integer dictKey) {
      return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> {
         String result = getDictClient().getValue(code, String.valueOf(dictKey));
         return result;
      }, TENANT_MODE);
      return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> dictService.getValue(code, String.valueOf(dictKey)), TENANT_MODE);
   }
   /**
@@ -138,10 +127,7 @@
    * @return String
    */
   public static String getValue(String code, String dictKey) {
      return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> {
         String result = getDictClient().getValue(code, dictKey);
         return result;
      }, TENANT_MODE);
      return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> dictService.getValue(code, dictKey), TENANT_MODE);
   }
   /**
@@ -151,10 +137,7 @@
    * @return List<Dict>
    */
   public static List<Dict> getList(String code) {
      return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> {
         List<Dict> result = getDictClient().getList(code);
         return result;
      }, TENANT_MODE);
      return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> dictService.getList(code), TENANT_MODE);
   }
}