|
|
@@ -1,6 +1,5 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
-import cn.dev33.satoken.context.SaHolder;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -8,13 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.dromara.common.core.constant.CacheConstants;
|
|
|
import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
-import org.dromara.common.core.service.DictService;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
-import org.dromara.common.core.utils.SpringUtils;
|
|
|
-import org.dromara.common.core.utils.StreamUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -36,7 +31,6 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 字典 业务层处理
|
|
|
@@ -45,7 +39,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService {
|
|
|
+public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|
|
|
|
|
private final SysDictTypeMapper baseMapper;
|
|
|
private final SysDictDataMapper dictDataMapper;
|
|
|
@@ -209,60 +203,4 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
|
|
return !exist;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据字典类型和字典值获取字典标签
|
|
|
- *
|
|
|
- * @param dictType 字典类型
|
|
|
- * @param dictValue 字典值
|
|
|
- * @param separator 分隔符
|
|
|
- * @return 字典标签
|
|
|
- */
|
|
|
- @SuppressWarnings("unchecked cast")
|
|
|
- @Override
|
|
|
- public String getDictLabel(String dictType, String dictValue, String separator) {
|
|
|
- // 优先从本地缓存获取
|
|
|
- List<SysDictDataVo> datas = (List<SysDictDataVo>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
|
|
- if (ObjectUtil.isNull(datas)) {
|
|
|
- datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
|
|
- SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, datas);
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel);
|
|
|
- if (StringUtils.containsAny(dictValue, separator)) {
|
|
|
- return Arrays.stream(dictValue.split(separator))
|
|
|
- .map(v -> map.getOrDefault(v, StringUtils.EMPTY))
|
|
|
- .collect(Collectors.joining(separator));
|
|
|
- } else {
|
|
|
- return map.getOrDefault(dictValue, StringUtils.EMPTY);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据字典类型和字典标签获取字典值
|
|
|
- *
|
|
|
- * @param dictType 字典类型
|
|
|
- * @param dictLabel 字典标签
|
|
|
- * @param separator 分隔符
|
|
|
- * @return 字典值
|
|
|
- */
|
|
|
- @SuppressWarnings("unchecked cast")
|
|
|
- @Override
|
|
|
- public String getDictValue(String dictType, String dictLabel, String separator) {
|
|
|
- // 优先从本地缓存获取
|
|
|
- List<SysDictDataVo> datas = (List<SysDictDataVo>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
|
|
- if (ObjectUtil.isNull(datas)) {
|
|
|
- datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
|
|
- SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, datas);
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictLabel, SysDictDataVo::getDictValue);
|
|
|
- if (StringUtils.containsAny(dictLabel, separator)) {
|
|
|
- return Arrays.stream(dictLabel.split(separator))
|
|
|
- .map(l -> map.getOrDefault(l, StringUtils.EMPTY))
|
|
|
- .collect(Collectors.joining(separator));
|
|
|
- } else {
|
|
|
- return map.getOrDefault(dictLabel, StringUtils.EMPTY);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|