feat: 保存字典值.

This commit is contained in:
lijiahangmax
2023-10-21 02:26:36 +08:00
parent bd02ce1dd0
commit eb2c8eb719
13 changed files with 168 additions and 41 deletions

View File

@@ -71,15 +71,15 @@ public class DictValueController {
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/list")
@Operation(summary = "查询字典配置值")
public List<DictValueVO> getDictValueList(@RequestParam("key") String key) {
return dictValueService.getDictValueList(key);
public List<DictValueVO> getDictValueList(@RequestParam("keyName") String keyName) {
return dictValueService.getDictValueList(keyName);
}
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/enum")
@Operation(summary = "查询字典配置值枚举")
public Map<String, Map<String, Object>> getDictValueEnum(@RequestParam("key") String key) {
return dictValueService.getDictValueEnum(key);
public Map<String, Map<String, Object>> getDictValueEnum(@RequestParam("keyName") String keyName) {
return dictValueService.getDictValueEnum(keyName);
}
@IgnoreLog(IgnoreLogMode.RET)

View File

@@ -33,7 +33,7 @@ public class DictValueCreateRequest implements Serializable {
@NotBlank
@Size(max = 32)
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
@Pattern(regexp = ValidConst.CHAR_NUMBER_1_32_PATTERN, message = ValidConst.CHAR_NUMBER_1_32_MESSAGE)
@Schema(description = "配置名称")
private String name;

View File

@@ -37,7 +37,7 @@ public class DictValueUpdateRequest implements Serializable {
@NotBlank
@Size(max = 32)
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
@Pattern(regexp = ValidConst.CHAR_NUMBER_1_32_PATTERN, message = ValidConst.CHAR_NUMBER_1_32_MESSAGE)
@Schema(description = "配置名称")
private String name;

View File

@@ -46,18 +46,18 @@ public interface DictValueService {
/**
* 查询全部字典配置值
*
* @param key key
* @param keyName keyName
* @return rows
*/
List<DictValueVO> getDictValueList(String key);
List<DictValueVO> getDictValueList(String keyName);
/**
* 查询全部字典配置值枚举
*
* @param key key
* @param keyName keyName
* @return enum
*/
Map<String, Map<String, Object>> getDictValueEnum(String key);
Map<String, Map<String, Object>> getDictValueEnum(String keyName);
/**
* 分页查询字典配置值

View File

@@ -140,15 +140,15 @@ public class DictValueServiceImpl implements DictValueService {
@Override
@SuppressWarnings("unchecked")
public List<DictValueVO> getDictValueList(String key) {
public List<DictValueVO> getDictValueList(String keyName) {
// 查询缓存
String cacheKey = DictCacheKeyDefine.DICT_VALUE.format(key);
String cacheKey = DictCacheKeyDefine.DICT_VALUE.format(keyName);
List<DictValueCacheDTO> list = RedisMaps.valuesJson(cacheKey, (Class<DictValueCacheDTO>) DictCacheKeyDefine.DICT_VALUE.getType());
if (list.isEmpty()) {
// 查询数据库
list = dictValueDAO.of()
.createWrapper()
.eq(DictValueDO::getKeyName, key)
.eq(DictValueDO::getKeyName, keyName)
.then()
.list(DictValueConvert.MAPPER::toCache);
// 添加默认值 防止穿透
@@ -170,14 +170,14 @@ public class DictValueServiceImpl implements DictValueService {
}
@Override
public Map<String, Map<String, Object>> getDictValueEnum(String key) {
public Map<String, Map<String, Object>> getDictValueEnum(String keyName) {
// 查询配置值
List<DictValueVO> values = this.getDictValueList(key);
List<DictValueVO> values = this.getDictValueList(keyName);
if (values.isEmpty()) {
return Maps.empty();
}
// 查询配置项
Map<String, String> schema = dictKeyService.getDictSchema(key);
Map<String, String> schema = dictKeyService.getDictSchema(keyName);
// 返回
Map<String, Map<String, Object>> result = Maps.newLinkedMap();
for (DictValueVO value : values) {