| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.dromara.common.core.constant.CacheConstants; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.context.ThreadLocalHolder; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.service.DictService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | |
| | | import org.dromara.system.mapper.SysDictDataMapper; |
| | | import org.dromara.system.mapper.SysDictTypeMapper; |
| | | import org.dromara.system.service.ISysDictTypeService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.cache.annotation.CachePut; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @param separator 分隔符 |
| | | * @return 字典标签 |
| | | */ |
| | | @SuppressWarnings("unchecked cast") |
| | | @Override |
| | | public String getDictLabel(String dictType, String dictValue, String separator) { |
| | | // 优先从本地缓存获取 |
| | | List<SysDictDataVo> datas = ThreadLocalHolder.get(CacheConstants.SYS_DICT_KEY + dictType); |
| | | if (ObjectUtil.isNull(datas)) { |
| | | datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType); |
| | | ThreadLocalHolder.set(CacheConstants.SYS_DICT_KEY + dictType, datas); |
| | | } |
| | | |
| | | List<SysDictDataVo> datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType); |
| | | Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel); |
| | | if (StringUtils.containsAny(dictValue, separator)) { |
| | | return Arrays.stream(dictValue.split(separator)) |
| | |
| | | * @param separator 分隔符 |
| | | * @return 字典值 |
| | | */ |
| | | @SuppressWarnings("unchecked cast") |
| | | @Override |
| | | public String getDictValue(String dictType, String dictLabel, String separator) { |
| | | // 优先从本地缓存获取 |
| | | List<SysDictDataVo> datas = ThreadLocalHolder.get(CacheConstants.SYS_DICT_KEY + dictType); |
| | | if (ObjectUtil.isNull(datas)) { |
| | | datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType); |
| | | ThreadLocalHolder.set(CacheConstants.SYS_DICT_KEY + dictType, datas); |
| | | } |
| | | |
| | | List<SysDictDataVo> datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType); |
| | | Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictLabel, SysDictDataVo::getDictValue); |
| | | if (StringUtils.containsAny(dictLabel, separator)) { |
| | | return Arrays.stream(dictLabel.split(separator)) |