Commit 36d6fcac authored by fangxinjiang's avatar fangxinjiang

减少原因调整

parent 73789ba3
......@@ -102,6 +102,13 @@ public class SysDictItem extends BaseEntity {
@Schema(description = "删除标记,1:已删除,0:正常")
private String delFlag;
/**
* 启用禁用 0 启用 1禁用
*/
@TableField
@Schema(description = "启用禁用 0 启用 1禁用")
private String disable;
/**
* 上级字典项标签
*/
......
......@@ -189,6 +189,17 @@ public class DictController {
public R<Map<String, Object>> getParentDictItemByTypes(String itemTypes) {
return sysDictItemService.getParentDictItemByTypes(itemTypes);
}
/**
* 通过id查询父级字典的字典值
* @param itemTypes
* @return R
*/
@SysLog("通过id查询父级字典的字典值")
@GetMapping("/getDictItemsByTypes")
public R<Map<String, List>> getDictItemsByTypes(String itemTypes) {
return sysDictItemService.getDictItemsByTypes(itemTypes);
}
/**
* 通过id查询字典项
* @param id id
......@@ -222,7 +233,8 @@ public class DictController {
if (Common.isNotNull(dict.getParentItemType())){
return R.ok(sysDictItemService.list(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getType,dict.getParentItemType())
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING)));
}
return R.ok();
}
......@@ -345,7 +357,8 @@ public class DictController {
@PostMapping("/inner/getDictList")
public R<List<SysDictItem>> getDictList(@RequestParam(value = "itemType", required = false) String itemType) {
List<SysDictItem> allList = sysDictItemService.list(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
return new R<>(allList);
}
}
......@@ -38,6 +38,7 @@ public class DictItemRedisInit {
@PostConstruct
public void init(){
log.info("字典数据加入缓存初始化开始...");
//不含禁用状态的字段
Map<String, Object> dictItem = dictItemService.getAllDictItemSub();
if (Common.isNotNull(dictItem)){
for (Map.Entry<String,Object> entry:dictItem.entrySet()){
......@@ -48,6 +49,7 @@ public class DictItemRedisInit {
}
log.info("字典数据加入缓存初始化结束...");
log.info("转义字典数据加入缓存初始化开始...");
// 包含禁用状态的字段数据
List<DictRedisVo> lables = dictItemService.getDictRedisVo();
if (Common.isNotNull(lables)){
Map<String,String> lableMap = new HashMap<>();
......
......@@ -89,4 +89,6 @@ public interface SysDictItemService extends IService<SysDictItem> {
R<String> getLableFronValue(String value,String type);
List<DictRedisVo> getDictRedisVo();
R<Map<String, List>> getDictItemsByTypes(String itemTypes);
}
......@@ -47,6 +47,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -132,7 +133,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
public R<String> getLableFronValue(String value, String type) {
SysDictItem sysDictItem = baseMapper.selectOne(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getType,type).eq(SysDictItem::getValue,value)
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
if (Common.isNotNull(sysDictItem)) {
return R.ok(sysDictItem.getLabel());
}
......@@ -147,7 +149,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
private void updateDictItem(String type, Map<String,Object> resultMap){
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.in(SysDictItem::getType,type)
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
extractedCache(allList, resultMap);
}
......@@ -208,7 +211,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
Map<String, Object> resultMap = new HashMap<>();
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.in(SysDictItem::getType,Common.initStrToList(itemTypes,CommonConstants.COMMA_STRING))
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
extracted(allList, resultMap);
return R.ok(resultMap);
}
......@@ -228,7 +232,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@Override
public Map<String, Object> getAllDictItemSub(){
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
Map<String, Object> resultMap = new HashMap<>();
extracted(allList, resultMap);
return resultMap;
......@@ -289,7 +294,7 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
private Map<String, Map<String, String>> getStringMapMap(boolean type) {
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.STATUS_NORMAL));
.eq(SysDictItem::getDelFlag,CommonConstants.STATUS_NORMAL).eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
Map<String, Map<String, String>> resultMap = new HashMap<>();
doAssemble(allList, resultMap, type);
return resultMap;
......@@ -354,5 +359,31 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
return node;
};
}
@Override
public R<Map<String, List>> getDictItemsByTypes(String itemTypes) {
if (Common.isEmpty(itemTypes)){
return R.failed(CommonConstants.RESULT_EMPTY);
}
Map<String, List> resultMap = new HashMap<>();
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.in(SysDictItem::getType,Common.initStrToList(itemTypes,CommonConstants.COMMA_STRING))
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)
.eq(SysDictItem::getDisable,CommonConstants.ZERO_STRING));
if (Common.isNotNull(allList)){
List temp;
for (SysDictItem item : allList) {
String dictCode = item.getType();
if (resultMap.get(dictCode) == null) {
List list = new ArrayList<>();
list.add(item);
resultMap.put(dictCode, list);
} else {
temp = resultMap.get(dictCode);
temp.add(item);
resultMap.put(dictCode, temp);
}
}
}
return R.ok(resultMap);
}
}
......@@ -54,6 +54,7 @@
WHERE
a.type = #{type}
AND i.`value` = a.parent_id
AND a.disable ='0'
AND a.`value` = #{value}
AND i.del_flag='0' limit 1
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment