部门接口,字典树接口调整
This commit is contained in:
@@ -1,137 +1,137 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.system.pojo.param.DicParam;
|
||||
import com.njcn.system.pojo.po.Dic;
|
||||
import com.njcn.system.pojo.vo.DicVO;
|
||||
import com.njcn.system.service.IDicService;
|
||||
import com.njcn.user.pojo.param.FunctionParam;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/dic")
|
||||
@Api(tags = "树型字典管理")
|
||||
@AllArgsConstructor
|
||||
public class DicController extends BaseController {
|
||||
|
||||
private final IDicService dicService;
|
||||
|
||||
/**
|
||||
* 获取树
|
||||
* @return
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/dicTree")
|
||||
@ApiOperation("获取字典树")
|
||||
public HttpResult<List<DicVO>> getDicTree(){
|
||||
String methodDescribe = getMethodDescribe("getDicTree");
|
||||
List<DicVO> list = dicService.getDicTree(null);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/codeDicTree")
|
||||
@ApiOperation("根据code获取字典树")
|
||||
public HttpResult<List<DicVO>> getCodeDicTree(String code){
|
||||
String methodDescribe = getMethodDescribe("getCodeDicTree");
|
||||
List<DicVO> list = dicService.getDicTree(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
* @param dicParam
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增")
|
||||
@ApiImplicitParam(name = "dicParam", value = "新增数据", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated DicParam dicParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},数据为:{}", methodDescribe, dicParam);
|
||||
boolean result = dicService.addDic(dicParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param dicParam
|
||||
* @return
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
@ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated DicParam.UpdateParam dicParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe,dicParam);
|
||||
boolean result = dicService.updateDic(dicParam);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
@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);
|
||||
boolean result = dicService.deleteDic(id);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getDicById")
|
||||
@ApiOperation("查看详情")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<Dic> getDicById(String id){
|
||||
String methodDescribe = getMethodDescribe("getDicById");
|
||||
LogUtil.njcnDebug(log, "{},id为:{}", methodDescribe,id);
|
||||
Dic dic = dicService.getDicById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,dic,methodDescribe);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.controller;
|
||||
//
|
||||
//
|
||||
//import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
//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.HttpResultUtil;
|
||||
//import com.njcn.common.utils.LogUtil;
|
||||
//import com.njcn.system.pojo.param.DicParam;
|
||||
//import com.njcn.system.pojo.po.Dic;
|
||||
//import com.njcn.system.pojo.vo.DicVO;
|
||||
//import com.njcn.system.service.IDicService;
|
||||
//import com.njcn.user.pojo.param.FunctionParam;
|
||||
//import com.njcn.user.pojo.po.Function;
|
||||
//import com.njcn.web.controller.BaseController;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiImplicitParam;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @author hany
|
||||
// * @date 2022/10/18
|
||||
// */
|
||||
//@Validated
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/dic")
|
||||
//@Api(tags = "树型字典管理")
|
||||
//@AllArgsConstructor
|
||||
//public class DicController extends BaseController {
|
||||
//
|
||||
// private final IDicService dicService;
|
||||
//
|
||||
// /**
|
||||
// * 获取树
|
||||
// * @return
|
||||
// */
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/dicTree")
|
||||
// @ApiOperation("获取字典树")
|
||||
// public HttpResult<List<DicVO>> getDicTree(){
|
||||
// String methodDescribe = getMethodDescribe("getDicTree");
|
||||
// List<DicVO> list = dicService.getDicTree(null);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/codeDicTree")
|
||||
// @ApiOperation("根据code获取字典树")
|
||||
// public HttpResult<List<DicVO>> getCodeDicTree(String code){
|
||||
// String methodDescribe = getMethodDescribe("getCodeDicTree");
|
||||
// List<DicVO> list = dicService.getDicTree(code);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
// }
|
||||
// /**
|
||||
// * 新增
|
||||
// * @param dicParam
|
||||
// */
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
// @PostMapping("/add")
|
||||
// @ApiOperation("新增")
|
||||
// @ApiImplicitParam(name = "dicParam", value = "新增数据", required = true)
|
||||
// public HttpResult<Boolean> add(@RequestBody @Validated DicParam dicParam) {
|
||||
// String methodDescribe = getMethodDescribe("add");
|
||||
// LogUtil.njcnDebug(log, "{},数据为:{}", methodDescribe, dicParam);
|
||||
// boolean result = dicService.addDic(dicParam);
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改
|
||||
// * @param dicParam
|
||||
// * @return
|
||||
// */
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
// @PutMapping("/update")
|
||||
// @ApiOperation("修改")
|
||||
// @ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
||||
// public HttpResult<Boolean> update(@RequestBody @Validated DicParam.UpdateParam dicParam) {
|
||||
// String methodDescribe = getMethodDescribe("update");
|
||||
// LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe,dicParam);
|
||||
// boolean result = dicService.updateDic(dicParam);
|
||||
// if (result){
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
// @DeleteMapping("/delete")
|
||||
// @ApiOperation("删除")
|
||||
// @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);
|
||||
// boolean result = dicService.deleteDic(id);
|
||||
// if (result){
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getDicById")
|
||||
// @ApiOperation("查看详情")
|
||||
// @ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
// public HttpResult<Dic> getDicById(String id){
|
||||
// String methodDescribe = getMethodDescribe("getDicById");
|
||||
// LogUtil.njcnDebug(log, "{},id为:{}", methodDescribe,id);
|
||||
// Dic dic = dicService.getDicById(id);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,dic,methodDescribe);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -130,6 +130,15 @@ public class DictTreeController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryAllByType")
|
||||
@ApiOperation("分类查询所有树形字典")
|
||||
public HttpResult<List<SysDicTreePO>> queryAllByType(@RequestParam("type")Integer type) {
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
List<SysDicTreePO> result = sysDicTreePOService.queryAllByType(type);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryTree")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.Dic;
|
||||
import com.njcn.system.pojo.vo.DicVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DicMapper extends BaseMapper<Dic> {
|
||||
|
||||
List<DicVO> getAllDic();
|
||||
}
|
||||
//package com.njcn.system.mapper;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
//import com.njcn.system.pojo.po.Dic;
|
||||
//import com.njcn.system.pojo.vo.DicVO;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public interface DicMapper extends BaseMapper<Dic> {
|
||||
//
|
||||
// List<DicVO> getAllDic();
|
||||
//}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.system.mapper.DicMapper">
|
||||
|
||||
<select id="getAllDic" resultType="DicVO">
|
||||
SELECT * from sys_dic_tree WHERE status = 0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,52 +1,52 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
|
||||
import com.njcn.system.pojo.param.DicParam;
|
||||
import com.njcn.system.pojo.po.Dic;
|
||||
import com.njcn.system.pojo.vo.DicVO;
|
||||
import com.njcn.user.pojo.param.FunctionParam;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
public interface IDicService {
|
||||
|
||||
/**
|
||||
* 获取树
|
||||
* @return
|
||||
*/
|
||||
List<DicVO> getDicTree(String code);
|
||||
|
||||
/**
|
||||
* 功能描述:新增
|
||||
*
|
||||
* @param dicParam 资源参数
|
||||
*/
|
||||
boolean addDic(DicParam dicParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改
|
||||
*
|
||||
* @param dicParam
|
||||
*/
|
||||
boolean updateDic(DicParam.UpdateParam dicParam);
|
||||
|
||||
/**
|
||||
* 功能描述:删除
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
*/
|
||||
boolean deleteDic(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id获取菜单详情
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
Dic getDicById(String id);
|
||||
}
|
||||
//package com.njcn.system.service;
|
||||
//
|
||||
//
|
||||
//import com.njcn.system.pojo.param.DicParam;
|
||||
//import com.njcn.system.pojo.po.Dic;
|
||||
//import com.njcn.system.pojo.vo.DicVO;
|
||||
//import com.njcn.user.pojo.param.FunctionParam;
|
||||
//import com.njcn.user.pojo.po.Function;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @author hany
|
||||
// * @date 2022/10/18
|
||||
// */
|
||||
//public interface IDicService {
|
||||
//
|
||||
// /**
|
||||
// * 获取树
|
||||
// * @return
|
||||
// */
|
||||
// List<DicVO> getDicTree(String code);
|
||||
//
|
||||
// /**
|
||||
// * 功能描述:新增
|
||||
// *
|
||||
// * @param dicParam 资源参数
|
||||
// */
|
||||
// boolean addDic(DicParam dicParam);
|
||||
//
|
||||
// /**
|
||||
// * 功能描述: 修改
|
||||
// *
|
||||
// * @param dicParam
|
||||
// */
|
||||
// boolean updateDic(DicParam.UpdateParam dicParam);
|
||||
//
|
||||
// /**
|
||||
// * 功能描述:删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return boolean
|
||||
// */
|
||||
// boolean deleteDic(String id);
|
||||
//
|
||||
// /**
|
||||
// * 功能描述: 根据id获取菜单详情
|
||||
// *
|
||||
// * @param id
|
||||
// */
|
||||
// Dic getDicById(String id);
|
||||
//}
|
||||
|
||||
@@ -40,5 +40,12 @@ public interface SysDicTreePOService extends IService<SysDicTreePO>{
|
||||
*/
|
||||
List<SysDicTreePO> queryAll();
|
||||
|
||||
/**
|
||||
* 分类查询所有树形字典
|
||||
* @author cdf
|
||||
* @date 2023/12/18
|
||||
*/
|
||||
List<SysDicTreePO> queryAllByType(Integer type);
|
||||
|
||||
List<SysDicTreePO> queryTree();
|
||||
}
|
||||
|
||||
@@ -8,25 +8,20 @@ import com.njcn.system.pojo.po.*;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||
import com.njcn.system.service.IDicService;
|
||||
import com.njcn.system.service.IEleEpdPqdService;
|
||||
import com.njcn.system.service.SysDicTreePOService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.system.mapper.CsStatisticalSetPOMapper;
|
||||
import com.njcn.system.service.CsStatisticalSetPOService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/9 16:17【需求编号】
|
||||
*
|
||||
@@ -38,7 +33,6 @@ import org.springframework.util.CollectionUtils;
|
||||
public class CsStatisticalSetPOServiceImpl extends MppServiceImpl<CsStatisticalSetPOMapper, CsStatisticalSetPO> implements CsStatisticalSetPOService{
|
||||
|
||||
private final IEleEpdPqdService epdPqdService;
|
||||
private final IDicService dicService;
|
||||
|
||||
private final SysDicTreePOService sysDicTreePOService;
|
||||
@Override
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.system.enums.EventResponseEnum;
|
||||
import com.njcn.system.enums.TemplateTreeEnum;
|
||||
import com.njcn.system.mapper.DicMapper;
|
||||
import com.njcn.system.pojo.constant.DicState;
|
||||
import com.njcn.system.pojo.param.DicParam;
|
||||
import com.njcn.system.pojo.po.Dic;
|
||||
import com.njcn.system.pojo.vo.DicVO;
|
||||
import com.njcn.system.service.IDicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DicServiceImpl extends ServiceImpl<DicMapper, Dic> implements IDicService {
|
||||
|
||||
private final DicMapper dicMapper;
|
||||
|
||||
@Override
|
||||
public boolean addDic(DicParam dicParam) {
|
||||
checkDicParam(dicParam,false);
|
||||
Dic dic = new Dic();
|
||||
BeanUtil.copyProperties(dicParam, dic);
|
||||
dic.setStatus(DicState.ENABLE);
|
||||
if (Objects.equals(dicParam.getPid(),DicState.FATHER_PID)){
|
||||
dic.setPids(DicState.FATHER_PID);
|
||||
} else {
|
||||
Dic fatherFaction = this.lambdaQuery().eq(Dic::getId,dicParam.getPid()).one();
|
||||
if (Objects.equals(fatherFaction.getPid(),DicState.FATHER_PID)){
|
||||
dic.setPids(dicParam.getPid());
|
||||
} else {
|
||||
String pidS = fatherFaction.getPids();
|
||||
dic.setPids(pidS+","+dicParam.getPid());
|
||||
}
|
||||
}
|
||||
return this.save(dic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDic(DicParam.UpdateParam dicParam) {
|
||||
checkDicParam(dicParam,true);
|
||||
Dic dic = new Dic();
|
||||
BeanUtil.copyProperties(dicParam, dic);
|
||||
return this.updateById(dic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDic(String id) {
|
||||
return this.lambdaUpdate().set(Dic::getStatus, DicState.DELETE).in(Dic::getId, id).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dic getDicById(String id) {
|
||||
return this.lambdaQuery().eq(Dic::getId,id).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取树
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DicVO> getDicTree(String code) {
|
||||
List<DicVO> list = dicMapper.getAllDic();
|
||||
return list.stream()
|
||||
.filter(fun -> {
|
||||
boolean flag =true;
|
||||
boolean flag1 =true;
|
||||
flag = Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid());
|
||||
if(!StringUtils.isEmpty(code)){
|
||||
flag1 = fun.getCode().equals(code);
|
||||
}
|
||||
|
||||
return flag&&flag1;
|
||||
|
||||
})
|
||||
.peek(funS -> funS.setChildren(getChildList(funS, list)))
|
||||
.sorted(Comparator.comparingInt(DicVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归组装
|
||||
*/
|
||||
private List<DicVO> getChildList(DicVO dictMenu, List<DicVO> categories) {
|
||||
return categories.stream().filter(o -> Objects.equals(o.getPid(),dictMenu.getId()))
|
||||
.peek(o -> o.setChildren(getChildList(o, categories)))
|
||||
.sorted(Comparator.comparingInt(DicVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,
|
||||
* 1.检查是否存在相同名称的菜单
|
||||
*/
|
||||
private void checkDicParam(DicParam dicParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<Dic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
.eq(Dic::getName,dicParam.getName())
|
||||
.eq(Dic::getStatus, DicState.ENABLE);
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (dicParam instanceof DicParam.UpdateParam) {
|
||||
lambdaQueryWrapper.ne(Dic::getId, ((DicParam.UpdateParam) dicParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(lambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(EventResponseEnum.NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.system.service.impl;
|
||||
//
|
||||
//import cn.hutool.core.bean.BeanUtil;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
//import com.njcn.common.pojo.exception.BusinessException;
|
||||
//import com.njcn.system.enums.EventResponseEnum;
|
||||
//import com.njcn.system.enums.TemplateTreeEnum;
|
||||
//import com.njcn.system.mapper.DicMapper;
|
||||
//import com.njcn.system.pojo.constant.DicState;
|
||||
//import com.njcn.system.pojo.param.DicParam;
|
||||
//import com.njcn.system.pojo.po.Dic;
|
||||
//import com.njcn.system.pojo.vo.DicVO;
|
||||
//import com.njcn.system.service.IDicService;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang.StringUtils;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.util.Comparator;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * @author hany
|
||||
// * @date 2022/10/18
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Service
|
||||
//@RequiredArgsConstructor
|
||||
//public class DicServiceImpl extends ServiceImpl<DicMapper, Dic> implements IDicService {
|
||||
//
|
||||
// private final DicMapper dicMapper;
|
||||
//
|
||||
// @Override
|
||||
// public boolean addDic(DicParam dicParam) {
|
||||
// checkDicParam(dicParam,false);
|
||||
// Dic dic = new Dic();
|
||||
// BeanUtil.copyProperties(dicParam, dic);
|
||||
// dic.setStatus(DicState.ENABLE);
|
||||
// if (Objects.equals(dicParam.getPid(),DicState.FATHER_PID)){
|
||||
// dic.setPids(DicState.FATHER_PID);
|
||||
// } else {
|
||||
// Dic fatherFaction = this.lambdaQuery().eq(Dic::getId,dicParam.getPid()).one();
|
||||
// if (Objects.equals(fatherFaction.getPid(),DicState.FATHER_PID)){
|
||||
// dic.setPids(dicParam.getPid());
|
||||
// } else {
|
||||
// String pidS = fatherFaction.getPids();
|
||||
// dic.setPids(pidS+","+dicParam.getPid());
|
||||
// }
|
||||
// }
|
||||
// return this.save(dic);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean updateDic(DicParam.UpdateParam dicParam) {
|
||||
// checkDicParam(dicParam,true);
|
||||
// Dic dic = new Dic();
|
||||
// BeanUtil.copyProperties(dicParam, dic);
|
||||
// return this.updateById(dic);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean deleteDic(String id) {
|
||||
// return this.lambdaUpdate().set(Dic::getStatus, DicState.DELETE).in(Dic::getId, id).update();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Dic getDicById(String id) {
|
||||
// return this.lambdaQuery().eq(Dic::getId,id).one();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取树
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public List<DicVO> getDicTree(String code) {
|
||||
// List<DicVO> list = dicMapper.getAllDic();
|
||||
// return list.stream()
|
||||
// .filter(fun -> {
|
||||
// boolean flag =true;
|
||||
// boolean flag1 =true;
|
||||
// flag = Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid());
|
||||
// if(!StringUtils.isEmpty(code)){
|
||||
// flag1 = fun.getCode().equals(code);
|
||||
// }
|
||||
//
|
||||
// return flag&&flag1;
|
||||
//
|
||||
// })
|
||||
// .peek(funS -> funS.setChildren(getChildList(funS, list)))
|
||||
// .sorted(Comparator.comparingInt(DicVO::getSort))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 递归组装
|
||||
// */
|
||||
// private List<DicVO> getChildList(DicVO dictMenu, List<DicVO> categories) {
|
||||
// return categories.stream().filter(o -> Objects.equals(o.getPid(),dictMenu.getId()))
|
||||
// .peek(o -> o.setChildren(getChildList(o, categories)))
|
||||
// .sorted(Comparator.comparingInt(DicVO::getSort))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 校验参数,
|
||||
// * 1.检查是否存在相同名称的菜单
|
||||
// */
|
||||
// private void checkDicParam(DicParam dicParam, boolean isExcludeSelf) {
|
||||
// LambdaQueryWrapper<Dic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper
|
||||
// .eq(Dic::getName,dicParam.getName())
|
||||
// .eq(Dic::getStatus, DicState.ENABLE);
|
||||
// //更新的时候,需排除当前记录
|
||||
// if (isExcludeSelf) {
|
||||
// if (dicParam instanceof DicParam.UpdateParam) {
|
||||
// lambdaQueryWrapper.ne(Dic::getId, ((DicParam.UpdateParam) dicParam).getId());
|
||||
// }
|
||||
// }
|
||||
// int countByAccount = this.count(lambdaQueryWrapper);
|
||||
// //大于等于1个则表示重复
|
||||
// if (countByAccount >= 1) {
|
||||
// throw new BusinessException(EventResponseEnum.NAME_REPEAT);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -108,6 +108,13 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDicTreePO> queryAllByType(Integer type) {
|
||||
LambdaQueryWrapper<SysDicTreePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDicTreePO::getStatus, 0).eq(SysDicTreePO::getType,type);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDicTreePO> queryTree() {
|
||||
LambdaQueryWrapper<SysDicTreePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user