微调
This commit is contained in:
@@ -10,7 +10,7 @@ import com.njcn.gather.system.dictionary.pojo.param.DictTreeParam;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
import com.njcn.gather.system.pojo.constant.DictState;
|
import com.njcn.gather.system.pojo.constant.DictConst;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -34,7 +34,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
// @Override
|
// @Override
|
||||||
// public void refreshDictTreeCache () {
|
// public void refreshDictTreeCache () {
|
||||||
// LambdaQueryWrapper<DictTree> queryWrapper = new LambdaQueryWrapper<>();
|
// LambdaQueryWrapper<DictTree> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
// queryWrapper.eq(DictTree::getState, DictState.ENABLE);
|
// queryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||||
// List<DictTree> list = this.list(queryWrapper);
|
// List<DictTree> list = this.list(queryWrapper);
|
||||||
// redisUtil.saveByKey(AppRedisKey.DICT_TREE, list);
|
// redisUtil.saveByKey(AppRedisKey.DICT_TREE, list);
|
||||||
// }
|
// }
|
||||||
@@ -45,7 +45,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
boolean result;
|
boolean result;
|
||||||
DictTree dictTree = new DictTree();
|
DictTree dictTree = new DictTree();
|
||||||
BeanUtils.copyProperties(dictTreeParam, dictTree);
|
BeanUtils.copyProperties(dictTreeParam, dictTree);
|
||||||
if (!Objects.equals(dictTree.getPid(), DictState.PARENT_ID)) {
|
if (!Objects.equals(dictTree.getPid(), DictConst.FATHER_ID)) {
|
||||||
QueryWrapper<DictTree> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<DictTree> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
queryWrapper.eq("id", dictTree.getPid());
|
queryWrapper.eq("id", dictTree.getPid());
|
||||||
@@ -55,9 +55,9 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
dictTree.setPids(instance.getPids() + StrPool.COMMA + instance.getId());
|
dictTree.setPids(instance.getPids() + StrPool.COMMA + instance.getId());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dictTree.setPids(DictState.PARENT_ID);
|
dictTree.setPids(DictConst.FATHER_ID);
|
||||||
}
|
}
|
||||||
dictTree.setState(DictState.ENABLE);
|
dictTree.setState(DictConst.ENABLE);
|
||||||
result = this.save(dictTree);
|
result = this.save(dictTree);
|
||||||
// if (result) {
|
// if (result) {
|
||||||
// refreshDictTreeCache();
|
// refreshDictTreeCache();
|
||||||
@@ -79,7 +79,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteDictTree(String id) {
|
public boolean deleteDictTree(String id) {
|
||||||
boolean result = this.lambdaUpdate().set(DictTree::getState, DictState.DELETE).in(DictTree::getId, id).update();
|
boolean result = this.lambdaUpdate().set(DictTree::getState, DictConst.DELETE).in(DictTree::getId, id).update();
|
||||||
// if (result) {
|
// if (result) {
|
||||||
// refreshDictTreeCache();
|
// refreshDictTreeCache();
|
||||||
// }
|
// }
|
||||||
@@ -90,7 +90,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
public List<DictTreeVO> queryByPid(String pid) {
|
public List<DictTreeVO> queryByPid(String pid) {
|
||||||
List<DictTreeVO> collect = new ArrayList<>();
|
List<DictTreeVO> collect = new ArrayList<>();
|
||||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(DictTree::getPid, pid).eq(DictTree::getState, DictState.ENABLE).orderByDesc(DictTree::getSort);
|
query.eq(DictTree::getPid, pid).eq(DictTree::getState, DictConst.ENABLE).orderByDesc(DictTree::getSort);
|
||||||
List<DictTree> resultList = this.list(query);
|
List<DictTree> resultList = this.list(query);
|
||||||
|
|
||||||
DictTree byId = this.getById(pid);
|
DictTree byId = this.getById(pid);
|
||||||
@@ -110,7 +110,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
public DictTreeVO queryByCode(String code) {
|
public DictTreeVO queryByCode(String code) {
|
||||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||||
query.clear();
|
query.clear();
|
||||||
query.eq(DictTree::getCode, code).eq(DictTree::getState, DictState.ENABLE);
|
query.eq(DictTree::getCode, code).eq(DictTree::getState, DictConst.ENABLE);
|
||||||
DictTree result = this.getOne(query);
|
DictTree result = this.getOne(query);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
@@ -129,29 +129,29 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DictTree queryById(String id) {
|
public DictTree queryById(String id) {
|
||||||
return this.lambdaQuery().eq(DictTree::getId, id).eq(DictTree::getState, DictState.ENABLE).one();
|
return this.lambdaQuery().eq(DictTree::getId, id).eq(DictTree::getState, DictConst.ENABLE).one();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DictTree> queryAll() {
|
public List<DictTree> queryAll() {
|
||||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(DictTree::getState, DictState.ENABLE);
|
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||||
return this.list(lambdaQueryWrapper);
|
return this.list(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DictTree> queryAllByType(Integer type) {
|
public List<DictTree> queryAllByType(Integer type) {
|
||||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(DictTree::getState, DictState.ENABLE).eq(DictTree::getType, type);
|
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getType, type);
|
||||||
return this.list(lambdaQueryWrapper);
|
return this.list(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DictTree> queryTree() {
|
public List<DictTree> queryTree() {
|
||||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(DictTree::getState, DictState.ENABLE);
|
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||||
List<DictTree> dictTreeList = this.list(lambdaQueryWrapper);
|
List<DictTree> dictTreeList = this.list(lambdaQueryWrapper);
|
||||||
return dictTreeList.stream().filter(item -> DictState.PARENT_ID.equals(item.getPid())).peek(item -> {
|
return dictTreeList.stream().filter(item -> DictConst.FATHER_ID.equals(item.getPid())).peek(item -> {
|
||||||
item.setLevel(0);
|
item.setLevel(0);
|
||||||
item.setChildren(getChildren(item, dictTreeList));
|
item.setChildren(getChildren(item, dictTreeList));
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package com.njcn.gather.system.pojo.constant;
|
|||||||
* @author caozehui
|
* @author caozehui
|
||||||
* @data 2024/11/8
|
* @data 2024/11/8
|
||||||
*/
|
*/
|
||||||
public interface DictState {
|
public interface DictConst {
|
||||||
/**
|
/**
|
||||||
* 状态 0-正常;1-停用;2-删除 默认正常
|
* 状态 0-正常;1-停用;2-删除 默认正常
|
||||||
*/
|
*/
|
||||||
@@ -17,5 +17,5 @@ public interface DictState {
|
|||||||
/**
|
/**
|
||||||
* 顶层父类的pid
|
* 顶层父类的pid
|
||||||
*/
|
*/
|
||||||
String PARENT_ID = "0";
|
String FATHER_ID = "0";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user