微调
This commit is contained in:
@@ -6,16 +6,15 @@ import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
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.vo.DictTreeVO;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -71,6 +70,7 @@ public class DictTreeController extends BaseController {
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param dicParam 修改参数
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@@ -79,9 +79,9 @@ public class DictTreeController extends BaseController {
|
||||
@ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated DictTreeParam.UpdateParam dicParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe,dicParam);
|
||||
LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe, dicParam);
|
||||
boolean result = dictTreeService.updateDictTree(dicParam);
|
||||
if (result){
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
@@ -90,7 +90,8 @@ public class DictTreeController extends BaseController {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id id
|
||||
*
|
||||
* @param id 字典id
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@@ -98,84 +99,73 @@ public class DictTreeController extends BaseController {
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除的id为:{}", methodDescribe,id);
|
||||
LogUtil.njcnDebug(log, "{},删除的id为:{}", methodDescribe, id);
|
||||
boolean result = dictTreeService.deleteDictTree(id);
|
||||
if (result){
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/query")
|
||||
@ApiOperation("根据pid查询字典树")
|
||||
public HttpResult<List<DictTreeVO>> query(@RequestParam("pid") String pid) {
|
||||
String methodDescribe = getMethodDescribe("query");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, pid);
|
||||
List<DictTreeVO> result = dictTreeService.queryByPid(pid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getById")
|
||||
// @ApiOperation("根据id查询数据")
|
||||
// public HttpResult<DictTree> getById(@RequestParam("id") String id) {
|
||||
// String methodDescribe = getMethodDescribe("getById");
|
||||
// LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
// DictTree result = dictTreeService.queryById(id);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getByCode")
|
||||
// @ApiOperation("根据Code查询字典")
|
||||
// public HttpResult<DictTreeVO> getByCode(@RequestParam("code") String code) {
|
||||
// String methodDescribe = getMethodDescribe("getByCode");
|
||||
// LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, code);
|
||||
// DictTreeVO result = dictTreeService.queryByCode(code);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryByCodeList")
|
||||
@ApiOperation("根据Code查询字典树")
|
||||
public HttpResult<List<DictTree>> queryByCodeList(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("queryByCodeList");
|
||||
List<DictTree> result = dictTreeService.queryByCodeList(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getByPid")
|
||||
// @ApiOperation("根据pid查询字典树")
|
||||
// public HttpResult<List<DictTreeVO>> getByPid(@RequestParam("pid") String pid) {
|
||||
// String methodDescribe = getMethodDescribe("getByPid");
|
||||
// LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, pid);
|
||||
// List<DictTreeVO> result = dictTreeService.queryByPid(pid);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryByCode")
|
||||
@ApiOperation("根据Code查询字典树")
|
||||
public HttpResult<DictTreeVO> queryByCode(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("queryByCode");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, code);
|
||||
DictTreeVO result = dictTreeService.queryByCode(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/queryLastLevelById")
|
||||
// @ApiOperation("根据id查询字典树最底层")
|
||||
// public HttpResult<List<DictTreeVO>> queryLastLevelById(@RequestParam("id") String id) {
|
||||
// String methodDescribe = getMethodDescribe("queryLastLevelById");
|
||||
// LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
// List<DictTreeVO> result = dictTreeService.queryLastLevelById(id);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryLastLevelById")
|
||||
@ApiOperation("根据id查询字典树最底层")
|
||||
public HttpResult<List<DictTreeVO>> queryLastLevelById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("queryLastLevelById");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
List<DictTreeVO> result = dictTreeService.queryLastLevelById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryById")
|
||||
@ApiOperation("根据id查询数据")
|
||||
public HttpResult<DictTree> queryById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("queryById");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
DictTree result = dictTreeService.queryById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryAll")
|
||||
@ApiOperation("查询所有树形字典")
|
||||
public HttpResult<List<DictTree>> queryAll() {
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
List<DictTree> result = dictTreeService.queryAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryAllByType")
|
||||
@ApiOperation("分类查询所有树形字典")
|
||||
public HttpResult<List<DictTree>> queryAllByType(@RequestParam("type")Integer type) {
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
List<DictTree> result = dictTreeService.queryAllByType(type);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/queryAll")
|
||||
// @ApiOperation("查询所有树形字典")
|
||||
// public HttpResult<List<DictTree>> queryAll() {
|
||||
// String methodDescribe = getMethodDescribe("queryAll");
|
||||
// List<DictTree> result = dictTreeService.queryAll();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/queryAllByType")
|
||||
// @ApiOperation("分类查询所有树形字典")
|
||||
// public HttpResult<List<DictTree>> queryAllByType(@RequestParam("type")Integer type) {
|
||||
// String methodDescribe = getMethodDescribe("queryAll");
|
||||
// List<DictTree> result = dictTreeService.queryAllByType(type);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ public class DictDataParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DictPqParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("相别")
|
||||
|
||||
@@ -19,12 +19,12 @@ public class DictTypeParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ALL_CHAR_1_20, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
|
||||
|
||||
|
||||
@@ -80,6 +80,6 @@ public class DictTree extends BaseEntity {
|
||||
@TableField(exist = false)
|
||||
private List<DictTree> children;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer level;
|
||||
// @TableField(exist = false)
|
||||
// private Integer level;
|
||||
}
|
||||
|
||||
@@ -20,18 +20,20 @@ public interface IDictTreeService extends IService<DictTree> {
|
||||
*/
|
||||
//void refreshDictTreeCache();
|
||||
|
||||
/**
|
||||
* 根据关键字查询字典树
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @return 字典树
|
||||
*/
|
||||
List<DictTree> getDictTreeByKeyword(String keyword);
|
||||
|
||||
boolean addDictTree(DictTreeParam dictTreeParam);
|
||||
|
||||
boolean updateDictTree(DictTreeParam.UpdateParam param);
|
||||
|
||||
boolean deleteDictTree(String id);
|
||||
|
||||
List<DictTreeVO> queryByPid(String pid);
|
||||
|
||||
DictTreeVO queryByCode(String code);
|
||||
|
||||
List<DictTreeVO> queryLastLevelById(String id);
|
||||
|
||||
/**
|
||||
* 根据id查询字典数据
|
||||
*
|
||||
@@ -39,13 +41,21 @@ public interface IDictTreeService extends IService<DictTree> {
|
||||
*/
|
||||
DictTree queryById(String id);
|
||||
|
||||
//DictTreeVO queryByCode(String code);
|
||||
|
||||
//List<DictTreeVO> queryByPid(String pid);
|
||||
|
||||
//List<DictTreeVO> queryLastLevelById(String id);
|
||||
|
||||
List<DictTree> queryTree();
|
||||
|
||||
/**
|
||||
* 查询所有树形字典
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/12/18
|
||||
*/
|
||||
List<DictTree> queryAll();
|
||||
//List<DictTree> queryAll();
|
||||
|
||||
/**
|
||||
* 分类查询所有树形字典
|
||||
@@ -53,22 +63,5 @@ public interface IDictTreeService extends IService<DictTree> {
|
||||
* @author cdf
|
||||
* @date 2023/12/18
|
||||
*/
|
||||
List<DictTree> queryAllByType(Integer type);
|
||||
|
||||
List<DictTree> queryTree();
|
||||
|
||||
/**
|
||||
* 根据code查询字典树
|
||||
*
|
||||
* @param code code
|
||||
*/
|
||||
List<DictTree> queryByCodeList(String code);
|
||||
|
||||
/**
|
||||
* 根据关键字查询字典树
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @return 字典树
|
||||
*/
|
||||
List<DictTree> getDictTreeByKeyword(String keyword);
|
||||
//List<DictTree> queryAllByType(Integer type);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.njcn.gather.system.dictionary.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.system.dictionary.mapper.DictTreeMapper;
|
||||
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.vo.DictTreeVO;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.system.pojo.constant.DictConst;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
@@ -21,7 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -44,6 +41,13 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
// redisUtil.saveByKey(AppRedisKey.DICT_TREE, list);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DictTree> getDictTreeByKeyword(String keyword) {
|
||||
List<DictTree> dictTree = this.queryTree();
|
||||
this.filterTreeByName(dictTree, keyword);
|
||||
return dictTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addDictTree(DictTreeParam dictTreeParam) {
|
||||
@@ -81,9 +85,9 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
@Override
|
||||
public boolean deleteDictTree(String id) {
|
||||
boolean result = false;
|
||||
List<DictTree> childrenList = this.lambdaQuery().eq(DictTree::getState, DataStateEnum.ENABLE.getCode()).eq(DictTree::getPid, id).list();
|
||||
List<DictTree> childrenList = this.lambdaQuery().eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getPid, id).list();
|
||||
if (CollectionUtils.isEmpty(childrenList)) {
|
||||
result = this.lambdaUpdate().set(DictTree::getState, DataStateEnum.DELETED.getCode()).in(DictTree::getId, id).update();
|
||||
result = this.lambdaUpdate().set(DictTree::getState, DictConst.DELETE).in(DictTree::getId, id).update();
|
||||
// if (result) {
|
||||
// refreshRolesFunctionsCache();
|
||||
// }
|
||||
@@ -93,61 +97,47 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryByPid(String pid) {
|
||||
List<DictTreeVO> collect = new ArrayList<>();
|
||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
query.eq(DictTree::getPid, pid).eq(DictTree::getState, DictConst.ENABLE).orderByDesc(DictTree::getSort);
|
||||
List<DictTree> resultList = this.list(query);
|
||||
DictTree byId = this.getById(pid);
|
||||
if (CollUtil.isNotEmpty(resultList)) {
|
||||
collect = resultList.stream().map(temp -> {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(temp, resultVO);
|
||||
resultVO.setPname(Objects.nonNull(byId) ? byId.getName() : "最高级");
|
||||
return resultVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictTreeVO queryByCode(String code) {
|
||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
query.clear();
|
||||
query.eq(DictTree::getCode, code).eq(DictTree::getState, DictConst.ENABLE);
|
||||
DictTree result = this.getOne(query);
|
||||
if (result != null) {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(result, resultVO);
|
||||
return resultVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryLastLevelById(String id) {
|
||||
return this.baseMapper.queryLastLevelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictTree queryById(String id) {
|
||||
return this.lambdaQuery().eq(DictTree::getId, id).eq(DictTree::getState, DictConst.ENABLE).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryAll() {
|
||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
// @Override
|
||||
// public DictTreeVO queryByCode(String code) {
|
||||
// LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
// query.clear();
|
||||
// query.eq(DictTree::getCode, code).eq(DictTree::getState, DictConst.ENABLE);
|
||||
// DictTree result = this.getOne(query);
|
||||
// if (result != null) {
|
||||
// DictTreeVO resultVO = new DictTreeVO();
|
||||
// BeanUtils.copyProperties(result, resultVO);
|
||||
// return resultVO;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryAllByType(Integer type) {
|
||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getType, type);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
// @Override
|
||||
// public List<DictTreeVO> queryByPid(String pid) {
|
||||
// List<DictTreeVO> collect = new ArrayList<>();
|
||||
// LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
// query.eq(DictTree::getPid, pid).eq(DictTree::getState, DictConst.ENABLE).orderByDesc(DictTree::getSort);
|
||||
// List<DictTree> resultList = this.list(query);
|
||||
// DictTree byId = this.getById(pid);
|
||||
// if (CollUtil.isNotEmpty(resultList)) {
|
||||
// collect = resultList.stream().map(temp -> {
|
||||
// DictTreeVO resultVO = new DictTreeVO();
|
||||
// BeanUtils.copyProperties(temp, resultVO);
|
||||
// resultVO.setPname(Objects.nonNull(byId) ? byId.getName() : "最高级");
|
||||
// return resultVO;
|
||||
// }).collect(Collectors.toList());
|
||||
// }
|
||||
// return collect;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public List<DictTreeVO> queryLastLevelById(String id) {
|
||||
// return this.baseMapper.queryLastLevelById(id);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryTree() {
|
||||
@@ -155,26 +145,24 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
List<DictTree> dictTreeList = this.list(lambdaQueryWrapper);
|
||||
return dictTreeList.stream().filter(item -> DictConst.FATHER_ID.equals(item.getPid())).peek(item -> {
|
||||
item.setLevel(0);
|
||||
// item.setLevel(0);
|
||||
item.setChildren(getChildren(item, dictTreeList));
|
||||
}).collect(Collectors.toList());
|
||||
}).sorted(Comparator.comparingInt(DictTree::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryByCodeList(String code) {
|
||||
List<DictTree> sysDicTreePOList = this.list(new LambdaQueryWrapper<DictTree>().eq(DictTree::getState, 0));
|
||||
return sysDicTreePOList.stream().filter(item -> item.getCode().equals(code)).peek(item -> {
|
||||
item.setLevel(0);
|
||||
item.setChildren(getChildren(item, sysDicTreePOList));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
// @Override
|
||||
// public List<DictTree> queryAll() {
|
||||
// LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
// return this.list(lambdaQueryWrapper);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DictTree> getDictTreeByKeyword(String keyword) {
|
||||
List<DictTree> dictTree = this.queryTree();
|
||||
this.filterTreeByName(dictTree, keyword);
|
||||
return dictTree;
|
||||
}
|
||||
// @Override
|
||||
// public List<DictTree> queryAllByType(Integer type) {
|
||||
// LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getType, type);
|
||||
// return this.list(lambdaQueryWrapper);
|
||||
// }
|
||||
|
||||
private List<DictTree> filterTreeByName(List<DictTree> tree, String keyword) {
|
||||
if (CollectionUtils.isEmpty(tree) || !StrUtil.isNotBlank(keyword)) {
|
||||
@@ -205,8 +193,8 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
|
||||
private List<DictTree> getChildren(DictTree dictTree, List<DictTree> all) {
|
||||
return all.stream().filter(item -> item.getPid().equals(dictTree.getId())).peek(item -> {
|
||||
item.setLevel(dictTree.getLevel() + 1);
|
||||
// item.setLevel(dictTree.getLevel() + 1);
|
||||
item.setChildren(getChildren(item, all));
|
||||
}).collect(Collectors.toList());
|
||||
}).sorted(Comparator.comparingInt(DictTree::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user