peiyanni 3 years ago
parent a147a8ec0e
commit 658ff06176

@ -0,0 +1,99 @@
package com.anjiplus.template.gaea.business.modules.dict.controller;
import com.anji.plus.gaea.bean.KeyValue;
import com.anji.plus.gaea.bean.ResponseBean;
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.dict.controller.dto.GaeaDictDTO;
import com.anjiplus.template.gaea.business.modules.dict.controller.param.GaeaDictParam;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictItemService;
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* (GaeaDict)
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@RestController
@RequestMapping("/gaeaDict")
@Api(value = "/gaeaDict", tags = "")
public class GaeaDictController extends GaeaBaseController<GaeaDictParam, GaeaDict, GaeaDictDTO> {
@Autowired
private GaeaDictService gaeaDictService;
@Autowired
private GaeaDictItemService gaeaDictItemService;
@Override
public GaeaBaseService<GaeaDictParam, GaeaDict> getService() {
return gaeaDictService;
}
@Override
public GaeaDict getEntity() {
return new GaeaDict();
}
@Override
public GaeaDictDTO getDTO() {
return new GaeaDictDTO();
}
/**
*
* @return
*/
@PostMapping("/freshDict")
public ResponseBean refreshDict(@RequestBody List<String> dictCodes) {
//刷新
gaeaDictService.refreshCache(dictCodes);
return responseSuccess();
}
/**
*
* @return
*/
@GetMapping("/select/{dictCode}")
public ResponseBean select(@PathVariable("dictCode") String dictName){
Locale locale = LocaleContextHolder.getLocale();
//语言
String language = locale.getLanguage();
List<KeyValue> keyValues = gaeaDictService.select(dictName,language);
return responseSuccessWithData(keyValues);
}
/**
*
* @return
*/
@GetMapping("/map/{dictCode}")
public ResponseBean dictItemByLang(@PathVariable("dictCode") String dictCode){
return responseSuccessWithData(gaeaDictItemService.getItemMap(dictCode));
}
/**
*
* @return
*/
@GetMapping("/selectAll/{project}")
public ResponseBean selectTypecodes(@PathVariable String project){
Locale locale = LocaleContextHolder.getLocale();
//语言
String language = locale.getLanguage();
Collection<KeyValue> keyValues = gaeaDictService.selectTypeCode(project,language);
return responseSuccessWithData(keyValues);
}
}

@ -0,0 +1,41 @@
package com.anjiplus.template.gaea.business.modules.dict.controller;
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import com.anjiplus.template.gaea.business.modules.dict.controller.dto.GaeaDictItemDTO;
import com.anjiplus.template.gaea.business.modules.dict.controller.param.GaeaDictItemParam;
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictItemService;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
/**
* (GaeaDictItem)
*
* @author lirui
* @since 2021-03-10 13:05:59
*/
@RestController
@RequestMapping("/gaeaDictItem")
@Api(value = "/gaeaDictItem", tags = "数据字典项")
public class GaeaDictItemController extends GaeaBaseController<GaeaDictItemParam, GaeaDictItem, GaeaDictItemDTO> {
@Autowired
private GaeaDictItemService gaeaDictItemService;
@Override
public GaeaBaseService<GaeaDictItemParam, GaeaDictItem> getService() {
return gaeaDictItemService;
}
@Override
public GaeaDictItem getEntity() {
return new GaeaDictItem();
}
@Override
public GaeaDictItemDTO getDTO() {
return new GaeaDictItemDTO();
}
}

@ -0,0 +1,56 @@
package com.anjiplus.template.gaea.business.modules.dict.controller.dto;
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* (GaeaDict)
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@ApiModel(value = "")
public class GaeaDictDTO extends GaeaBaseDTO implements Serializable {
/**
*
*/
@ApiModelProperty(value = "字典名称")
private String dictName;
/**
*
*/
@ApiModelProperty(value = "字典编号")
private String dictCode;
/**
*
*/
@ApiModelProperty(value = "字典描述")
private String remark;
public String getDictName() {
return dictName;
}
public void setDictName(String dictName) {
this.dictName = dictName;
}
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

@ -0,0 +1,119 @@
package com.anjiplus.template.gaea.business.modules.dict.controller.dto;
import com.anji.plus.gaea.annotation.Formatter;
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* (GaeaDictItem)
*
* @author lirui
* @since 2021-03-10 13:05:59
*/
@ApiModel(value = "数据字典项")
public class GaeaDictItemDTO extends GaeaBaseDTO implements Serializable {
/**
*
*/
@ApiModelProperty(value = "数据字典编码")
private String dictCode;
/**
*
*/
@ApiModelProperty(value = "字典项名称")
private String itemName;
/**
*
*/
@ApiModelProperty(value = "字典项值")
private String itemValue;
/**
*
*/
@ApiModelProperty(value = "字典项扩展")
private String itemExtend;
/**
*
*/
@ApiModelProperty(value = "语言标识")
@Formatter(dictCode = "LOCALE", targetField = "localeView")
private String locale;
private String localeView;
/**
*
*/
@ApiModelProperty(value = "描述")
private String remark;
/**
*
*/
@ApiModelProperty(value = "排序")
private Integer sort;
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getItemValue() {
return itemValue;
}
public void setItemValue(String itemValue) {
this.itemValue = itemValue;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getItemExtend() {
return itemExtend;
}
public void setItemExtend(String itemExtend) {
this.itemExtend = itemExtend;
}
public String getLocaleView() {
return localeView;
}
public void setLocaleView(String localeView) {
this.localeView = localeView;
}
}

@ -0,0 +1,39 @@
package com.anjiplus.template.gaea.business.modules.dict.controller.param;
import com.anji.plus.gaea.annotation.Query;
import com.anji.plus.gaea.constant.QueryEnum;
import com.anji.plus.gaea.curd.params.PageParam;
import lombok.Data;
import java.io.Serializable;
/**
* (GaeaDictItem)param
*
* @author lirui
* @since 2021-03-10 13:05:59
*/
@Data
public class GaeaDictItemParam extends PageParam implements Serializable {
/**
*
*/
private String dictCode;
/**
*
*/
@Query(QueryEnum.LIKE)
private String itemName;
/**
*
*/
private String locale;
/**
* 10:
*/
private Integer enabled;
}

@ -0,0 +1,29 @@
package com.anjiplus.template.gaea.business.modules.dict.controller.param;
import com.anji.plus.gaea.annotation.Query;
import com.anji.plus.gaea.constant.QueryEnum;
import com.anji.plus.gaea.curd.params.PageParam;
import lombok.Data;
import java.io.Serializable;
/**
* (GaeaDict)param
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@Data
public class GaeaDictParam extends PageParam implements Serializable {
/**
*
*/
@Query(QueryEnum.LIKE)
private String dictName;
/**
*
*/
@Query(QueryEnum.LIKE)
private String dictCode;
}

@ -0,0 +1,17 @@
package com.anjiplus.template.gaea.business.modules.dict.dao;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* (GaeaDictItem)Mapper
*
* @author lirui
* @since 2021-03-09 15:52:41
*/
@Mapper
public interface GaeaDictItemMapper extends GaeaBaseMapper<GaeaDictItem> {
}

@ -0,0 +1,17 @@
package com.anjiplus.template.gaea.business.modules.dict.dao;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* (GaeaDict)Mapper
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@Mapper
public interface GaeaDictMapper extends GaeaBaseMapper<GaeaDict> {
}

@ -0,0 +1,56 @@
package com.anjiplus.template.gaea.business.modules.dict.dao.entity;
import com.anji.plus.gaea.annotation.Unique;
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
import com.anjiplus.template.gaea.common.RespCommonCode;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
/**
* (GaeaDict)
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@TableName("gaea_dict")
public class GaeaDict extends GaeaBaseEntity implements Serializable {
/**
*
*/
private String dictName;
/**
*
*/
@Unique(code = RespCommonCode.DICCODE_ISEXIST)
private String dictCode;
/**
*
*/
private String remark;
public String getDictName() {
return dictName;
}
public void setDictName(String dictName) {
this.dictName = dictName;
}
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

@ -0,0 +1,123 @@
package com.anjiplus.template.gaea.business.modules.dict.dao.entity;
import com.anji.plus.gaea.annotation.UnionUnique;
import com.anji.plus.gaea.annotation.UnionUniqueCode;
import com.anjiplus.template.gaea.business.code.*;
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
import com.anjiplus.template.gaea.business.constant.BusinessConstant;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
/**
* (GaeaDictItem)
*
* @author lirui
* @since 2021-03-09 15:52:41
*/
@TableName("gaea_dict_item")
@UnionUniqueCode(group = BusinessConstant.DICT_ITEM_EXIST_GROUP, code = ResponseCode.DICT_ITEM_REPEAT)
public class GaeaDictItem extends GaeaBaseEntity implements Serializable {
/**
*
*/
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
private String dictCode;
/**
*
*/
private String itemName;
/**
*
*/
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
private String itemValue;
/**
*
*/
private String itemExtend;
/**
*
*/
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
private String locale;
/**
* 10:
*/
private Integer enabled;
/**
*
*/
private String remark;
/**
*
*/
private Integer sort;
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getItemValue() {
return itemValue;
}
public void setItemValue(String itemValue) {
this.itemValue = itemValue;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getEnabled() {
return enabled;
}
public void setEnabled(Integer enabled) {
this.enabled = enabled;
}
public String getItemExtend() {
return itemExtend;
}
public void setItemExtend(String itemExtend) {
this.itemExtend = itemExtend;
}
}

@ -0,0 +1,23 @@
package com.anjiplus.template.gaea.business.modules.dict.service;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.dict.controller.param.GaeaDictItemParam;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import java.util.Map;
/**
* (GaeaDictItem)Service
*
* @author lirui
* @since 2021-03-10 13:05:59
*/
public interface GaeaDictItemService extends GaeaBaseService<GaeaDictItemParam, GaeaDictItem> {
/**
*
* @param dictCode
* @return
*/
Map<String,String> getItemMap(String dictCode);
}

@ -0,0 +1,47 @@
package com.anjiplus.template.gaea.business.modules.dict.service;
import com.anji.plus.gaea.bean.KeyValue;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.dict.controller.param.GaeaDictParam;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import java.util.Collection;
import java.util.List;
/**
* (GaeaDict)Service
*
* @author lr
* @since 2021-02-23 10:01:02
*/
public interface GaeaDictService extends GaeaBaseService<GaeaDictParam, GaeaDict> {
/**
*
* @param dictCodes
*/
void refreshCache(List<String> dictCodes);
/**
* code
* @param dictCode
* @param language
* @return
*/
List<KeyValue> select(String dictCode, String language);
/**
*
* @return
*/
List<GaeaDictItem> findItems(List<String> dictCodes);
/**
* typecode
* @param system
* @param language
* @return
*/
Collection<KeyValue> selectTypeCode(String system, String language);
}

@ -0,0 +1,97 @@
package com.anjiplus.template.gaea.business.modules.dict.service.impl;
import com.anji.plus.gaea.cache.CacheHelper;
import com.anji.plus.gaea.constant.BaseOperationEnum;
import com.anji.plus.gaea.constant.GaeaConstant;
import com.anji.plus.gaea.constant.GaeaKeyConstant;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessException;
import com.anjiplus.template.gaea.business.modules.dict.dao.GaeaDictItemMapper;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictItemService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* (GaeaDictItem)ServiceImpl
*
* @author lirui
* @since 2021-03-10 13:05:59
*/
@Service
public class GaeaDictItemServiceImpl implements GaeaDictItemService {
@Autowired
private GaeaDictItemMapper gaeaDictItemMapper;
@Autowired
private CacheHelper cacheHelper;
@Override
public GaeaBaseMapper<GaeaDictItem> getMapper() {
return gaeaDictItemMapper;
}
@Override
public void processAfterOperation(GaeaDictItem entity, BaseOperationEnum operationEnum) throws BusinessException {
String dictCode = entity.getDictCode();
String locale = entity.getLocale();
String key = GaeaKeyConstant.DICT_PREFIX + locale + GaeaConstant.REDIS_SPLIT + dictCode;
switch (operationEnum) {
case INSERT:
case UPDATE:
cacheHelper.hashSet(key, entity.getItemValue(), entity.getItemName());
break;
case DELETE:
cacheHelper.hashDel(key, entity.getItemValue());
default:
}
}
@Override
public void processBatchAfterOperation(List<GaeaDictItem> entities, BaseOperationEnum operationEnum) throws BusinessException {
if (CollectionUtils.isEmpty(entities)) {
return;
}
Map<String, Map<String, String>> dictItemMap = entities.stream()
.collect(Collectors.groupingBy(item -> item.getLocale() + GaeaConstant.REDIS_SPLIT +item.getDictCode(),
Collectors.toMap(GaeaDictItem::getItemValue, GaeaDictItem::getItemName,(v1,v2)-> v2)));
switch (operationEnum) {
case DELETE_BATCH:
//遍历并保持到Redis中
dictItemMap.entrySet().stream().forEach(entry -> {
String key = GaeaKeyConstant.DICT_PREFIX + entry.getKey();
Set<String> hashKeys = entry.getValue().keySet();
cacheHelper.hashBatchDel(key, hashKeys);
});
break;
default:
}
}
@Override
public Map<String, String> getItemMap(String dictCode) {
Locale locale = LocaleContextHolder.getLocale();
LambdaQueryWrapper<GaeaDictItem> wrapper = Wrappers.lambdaQuery();
wrapper.eq(GaeaDictItem::getDictCode, dictCode);
wrapper.eq(GaeaDictItem::getLocale, locale.getLanguage());
List<GaeaDictItem> list = list(wrapper);
Map<String, String> data = list.stream().collect(Collectors.toMap(GaeaDictItem::getItemValue, GaeaDictItem::getItemName, (v1, v2) -> v2));
return data;
}
}

@ -0,0 +1,158 @@
package com.anjiplus.template.gaea.business.modules.dict.service.impl;
import com.anji.plus.gaea.bean.KeyValue;
import com.anji.plus.gaea.cache.CacheHelper;
import com.anji.plus.gaea.constant.Enabled;
import com.anji.plus.gaea.constant.GaeaConstant;
import com.anji.plus.gaea.constant.GaeaKeyConstant;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.utils.GaeaUtils;
import com.anjiplus.template.gaea.business.modules.dict.dao.GaeaDictItemMapper;
import com.anjiplus.template.gaea.business.modules.dict.dao.GaeaDictMapper;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* (GaeaDict)ServiceImpl
*
* @author lr
* @since 2021-02-23 10:01:02
*/
@Service
public class GaeaDictServiceImpl implements GaeaDictService {
@Autowired
private GaeaDictMapper gaeaDictMapper;
@Autowired
private GaeaDictItemMapper gaeaDictItemMapper;
@Autowired
private CacheHelper cacheHelper;
@Override
public GaeaBaseMapper<GaeaDict> getMapper() {
return gaeaDictMapper;
}
/**
*
* @param dictCodes
*/
@Override
public void refreshCache(List<String> dictCodes) {
//查询指定字典项
List<GaeaDictItem> gaeaDictItems = findItems(dictCodes);
//对数据字典项进行分组分组key=语言标识:字典编码
Map<String, Map<String, String>> dictItemMap = gaeaDictItems.stream()
.collect(Collectors
.groupingBy(item -> item.getLocale() + GaeaConstant.REDIS_SPLIT +item.getDictCode(),
Collectors.toMap(GaeaDictItem::getItemValue, GaeaDictItem::getItemName,(v1,v2)-> v2)));
//遍历并保持到Redis中
dictItemMap.entrySet().stream().forEach(entry -> {
String key = GaeaKeyConstant.DICT_PREFIX + entry.getKey();
cacheHelper.delete(key);
cacheHelper.hashSet(key, entry.getValue());
});
}
/**
*
* Redis
* @param dictCode
* @param language
* @return
*/
@Override
public List<KeyValue> select(String dictCode, String language) {
//缓存字典Key
String dictKey = GaeaKeyConstant.DICT_PREFIX + language + GaeaConstant.REDIS_SPLIT + dictCode;
Map<String, String> dictMap = cacheHelper.hashGet(dictKey);
//当查询的字典为空时
if (CollectionUtils.isEmpty(dictMap)) {
LambdaQueryWrapper<GaeaDictItem> wrapper = Wrappers.lambdaQuery();
wrapper.eq(GaeaDictItem::getDictCode, dictCode)
.eq(GaeaDictItem::getEnabled, Enabled.YES.getValue())
.eq(GaeaDictItem::getLocale, language)
.orderByAsc(GaeaDictItem::getSort);
List<GaeaDictItem> list = gaeaDictItemMapper.selectList(wrapper);
List<KeyValue> keyValues = list.stream()
.map(dictItemEntity -> new KeyValue(dictItemEntity.getItemValue(), dictItemEntity.getItemName(), dictItemEntity.getItemExtend()))
.collect(Collectors.toList());
//当缓存不存在时,刷新缓存
List<String> dictCodes = new ArrayList<>();
dictCodes.add(dictCode);
refreshCache(dictCodes);
return keyValues;
}
List<KeyValue> keyValues = GaeaUtils.formatKeyValue(dictMap);
//添加扩展字段
LambdaQueryWrapper<GaeaDictItem> gaeaDictItemWrapper = Wrappers.lambdaQuery();
gaeaDictItemWrapper.eq(GaeaDictItem::getDictCode, dictCode);
gaeaDictItemWrapper.isNotNull(GaeaDictItem::getItemExtend);
Map<String, String> extendMap = gaeaDictItemMapper.selectList(gaeaDictItemWrapper).stream()
.filter(gaeaDictItem -> StringUtils.isNotBlank(gaeaDictItem.getItemExtend()))
.collect(Collectors.toMap(GaeaDictItem::getItemValue, GaeaDictItem::getItemExtend, (v1, v2) -> v2));
if (!CollectionUtils.isEmpty(extendMap)) {
keyValues.stream().forEach(keyValue -> keyValue.setExtend(extendMap.get(keyValue.getId())));
}
return keyValues;
}
@Override
public List<GaeaDictItem> findItems(List<String> dictCodes) {
LambdaQueryWrapper<GaeaDictItem> gaeaDictItemQueryWrapper = Wrappers.lambdaQuery();
if (!CollectionUtils.isEmpty(dictCodes)) {
gaeaDictItemQueryWrapper.in(GaeaDictItem::getDictCode, dictCodes);
}
return gaeaDictItemMapper.selectList(gaeaDictItemQueryWrapper);
}
@Override
public Collection<KeyValue> selectTypeCode(String system, String language) {
//缓存字典Key
String dictKey = GaeaKeyConstant.DICT_PREFIX + language + GaeaConstant.REDIS_SPLIT + system;
Map<String, String> dictMap = cacheHelper.hashGet(dictKey);
//当查询的字典为空时
if (CollectionUtils.isEmpty(dictMap)) {
LambdaQueryWrapper<GaeaDict> wrapper = Wrappers.lambdaQuery();
//wrapper.eq(GaeaDict::getLocale, language).orderByAsc(GaeaDict::getSort);
List<GaeaDict> list = getMapper().selectList(wrapper);
Set<KeyValue> keyValues = list.stream()
.map(dictItemEntity -> new KeyValue(dictItemEntity.getDictCode(),
dictItemEntity.getDictName()))
.collect(Collectors.toSet());
return keyValues;
}
return GaeaUtils.formatKeyValue(dictMap);
}
}
Loading…
Cancel
Save