From 4fe7be8960043d737ec411fc18175ef800bfa670 Mon Sep 17 00:00:00 2001 From: hanyong <1334742946@qq.com> Date: Fri, 28 Oct 2022 16:01:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=A8=A1=E6=9D=BF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/system/pojo/constant/DicState.java | 18 +++ .../java/com/njcn/system/pojo/dto/DicDTO.java | 32 +++++ .../com/njcn/system/pojo/param/DicParam.java | 52 +++++++ .../system/pojo/param/EventTemplateParam.java | 4 +- .../java/com/njcn/system/pojo/po/Dic.java | 30 ++++ .../njcn/system/pojo/po/EventTemplate.java | 2 +- .../java/com/njcn/system/pojo/vo/DicVO.java | 35 +++++ .../njcn/system/pojo/vo/EventTemplateVO.java | 2 +- .../njcn/system/controller/DicController.java | 129 ++++++++++++++++++ .../controller/EventTemplateController.java | 13 +- .../com/njcn/system/mapper/DicMapper.java | 12 ++ .../njcn/system/mapper/mapping/DicMapper.xml | 8 ++ .../com/njcn/system/service/IDicService.java | 52 +++++++ .../system/service/IEventTemplateService.java | 2 +- .../system/service/impl/DicServiceImpl.java | 124 +++++++++++++++++ .../service/impl/EventDictServiceImpl.java | 4 +- .../impl/EventTemplateServiceImpl.java | 20 ++- 17 files changed, 525 insertions(+), 14 deletions(-) create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/constant/DicState.java create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/dto/DicDTO.java create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/DicParam.java create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/Dic.java create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/DicVO.java create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/controller/DicController.java create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/mapper/DicMapper.java create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/DicMapper.xml create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/service/IDicService.java create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/DicServiceImpl.java diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/constant/DicState.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/constant/DicState.java new file mode 100644 index 000000000..a237cb15a --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/constant/DicState.java @@ -0,0 +1,18 @@ +package com.njcn.system.pojo.constant; + +public interface DicState { + + /** + * 状态 0-正常;1-停用;2-删除 默认正常 + */ + int ENABLE = 0; + + int PAUSE = 1; + + int DELETE = 2; + + /** + * 顶层父类的pid + */ + String FATHER_PID = "0"; +} diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/dto/DicDTO.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/dto/DicDTO.java new file mode 100644 index 000000000..182da807e --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/dto/DicDTO.java @@ -0,0 +1,32 @@ +package com.njcn.system.pojo.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class DicDTO implements Serializable { + + @ApiModelProperty("Id") + private String id; + + @ApiModelProperty("父节点") + private String pid; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("编码") + private String code; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("描述") + private String remark; + + @ApiModelProperty("子级") + List children; +} diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/DicParam.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/DicParam.java new file mode 100644 index 000000000..7ffde402f --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/DicParam.java @@ -0,0 +1,52 @@ +package com.njcn.system.pojo.param; + +import com.njcn.common.pojo.constant.PatternRegex; +import com.njcn.web.constant.ValidMessage; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +@Data +public class DicParam { + + @ApiModelProperty("节点") + @NotBlank(message = ValidMessage.PID_NOT_BLANK) + private String pid; + + @ApiModelProperty("名称") + @NotBlank(message = ValidMessage.NAME_NOT_BLANK) + @Pattern(regexp = PatternRegex.DIC_REGEX, message = ValidMessage.NAME_FORMAT_ERROR) + private String name; + + @ApiModelProperty("编号") + @NotBlank(message = ValidMessage.CODE_NOT_BLANK) + private String code; + + @ApiModelProperty("排序") + @NotNull(message = ValidMessage.SORT_NOT_NULL) + @Range(min = 0, max = 999, message = ValidMessage.PARAM_FORMAT_ERROR) + private Integer sort; + + @ApiModelProperty("描述") + private String remark; + + + /** + * 更新操作实体 + * 需要填写的参数:id + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class UpdateParam extends DicParam { + + @ApiModelProperty("Id") + @NotBlank(message = ValidMessage.ID_NOT_BLANK) + @Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR) + private String id; + } +} diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/EventTemplateParam.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/EventTemplateParam.java index ec0d3b50f..2bd41ec4a 100644 --- a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/EventTemplateParam.java +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/EventTemplateParam.java @@ -26,7 +26,7 @@ public class EventTemplateParam { @ApiModelProperty("模板描述") @NotBlank(message = ValidMessage.CODE_NOT_BLANK) @Pattern(regexp = PatternRegex.DES64_REGEX, message = ValidMessage.CODE_FORMAT_ERROR) - private String mark; + private String code; @ApiModelProperty("类型") private Integer type; @@ -56,7 +56,7 @@ public class EventTemplateParam { /** * 区分监测点与区域报告 */ - private String type; + private Integer type; } /** diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/Dic.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/Dic.java new file mode 100644 index 000000000..e21974eb4 --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/Dic.java @@ -0,0 +1,30 @@ +package com.njcn.system.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("sys_dic_tree") +public class Dic extends BaseEntity { + + private static final long serialVersionUID = 1L; + + private String id; + + private String pid; + + private String pids; + + private String name; + + private String code; + + private Integer sort; + + private String remark; + + private Integer status; +} diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/EventTemplate.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/EventTemplate.java index 90cfebf01..2bfd220f3 100644 --- a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/EventTemplate.java +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/EventTemplate.java @@ -37,7 +37,7 @@ public class EventTemplate extends BaseEntity { /** * 模板名称 */ - private String mark; + private String code; /** * 状态:0-删除 1-正常 diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/DicVO.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/DicVO.java new file mode 100644 index 000000000..7c2d05bc3 --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/DicVO.java @@ -0,0 +1,35 @@ +package com.njcn.system.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class DicVO implements Serializable { + + @ApiModelProperty("Id") + private String id; + + @ApiModelProperty("父节点") + private String pid; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("编码") + private String code; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("描述") + private String remark; + + @ApiModelProperty("状态") + private Integer status; + + @ApiModelProperty("子级") + List children; +} diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/EventTemplateVO.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/EventTemplateVO.java index 31b8b0835..eaedadcf6 100644 --- a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/EventTemplateVO.java +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/EventTemplateVO.java @@ -32,7 +32,7 @@ public class EventTemplateVO implements Serializable { /** * 模板描述 */ - private String mark; + private String code; /** * 状态:0-删除 1-正常 diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/DicController.java b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/DicController.java new file mode 100644 index 000000000..1fb32f86c --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/DicController.java @@ -0,0 +1,129 @@ +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> getDicTree(){ + String methodDescribe = getMethodDescribe("getDicTree"); + List list = dicService.getDicTree(); + 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 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 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 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 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); + } +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/EventTemplateController.java b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/EventTemplateController.java index 91560169e..217184836 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/EventTemplateController.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/EventTemplateController.java @@ -10,6 +10,7 @@ import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; import com.njcn.system.pojo.param.EventTemplateParam; import com.njcn.system.pojo.po.EventTemplate; +import com.njcn.system.pojo.vo.EventTemplateVO; import com.njcn.system.service.IEventTemplateService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; @@ -47,11 +48,13 @@ public class EventTemplateController extends BaseController{ * @return */ @OperateInfo(info = LogEnum.SYSTEM_COMMON) - @GetMapping("/getList") + @PostMapping("/getList") @ApiOperation("查询所有模板") - public HttpResult> getList() { + @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true) + public HttpResult> getList(@RequestBody @Validated EventTemplateParam.EventTemplateQueryParam queryParam) { String methodDescribe = getMethodDescribe("getList"); - List res = iEventTemplateService.getList(); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); + Page res = iEventTemplateService.getList(queryParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); } @@ -123,7 +126,7 @@ public class EventTemplateController extends BaseController{ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE) @ApiOperation("删除模板") @ApiImplicitParam(name = "ids", value = "模板索引", required = true) - public HttpResult delete(@RequestBody List ids){ + public HttpResult delete(@RequestBody List ids){ String methodDescribe = getMethodDescribe("delete"); boolean result = iEventTemplateService.delete(ids); if(result){ @@ -142,7 +145,7 @@ public class EventTemplateController extends BaseController{ @PostMapping("/selectRelevance") @ApiOperation("根据模板id查询关系") @ApiImplicitParam(name = "ids", value = "角色索引", required = true) - public HttpResult selectRelevance(@RequestBody List ids) { + public HttpResult selectRelevance(@RequestBody @Validated List ids) { String methodDescribe = getMethodDescribe("selectRelevance"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, ids); boolean result = iEventTemplateService.selectRelevance(ids); diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/DicMapper.java b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/DicMapper.java new file mode 100644 index 000000000..ee6c881f3 --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/DicMapper.java @@ -0,0 +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 { + + List getAllDic(); +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/DicMapper.xml b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/DicMapper.xml new file mode 100644 index 000000000..0bbb23554 --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/DicMapper.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/IDicService.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IDicService.java new file mode 100644 index 000000000..99b5bb86d --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IDicService.java @@ -0,0 +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 getDicTree(); + + /** + * 功能描述:新增 + * + * @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); +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/IEventTemplateService.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IEventTemplateService.java index ed1700968..fb5df537f 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/IEventTemplateService.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IEventTemplateService.java @@ -19,7 +19,7 @@ public interface IEventTemplateService extends IService { * 查询模板 * @return 字典列表 */ - List getList(); + Page getList(EventTemplateParam.EventTemplateQueryParam queryParam); /** * 根据id查询模板 diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/DicServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/DicServiceImpl.java new file mode 100644 index 000000000..83657531c --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/DicServiceImpl.java @@ -0,0 +1,124 @@ +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.enums.common.DataStateEnum; +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.po.EventTemplate; +import com.njcn.system.pojo.vo.DicVO; +import com.njcn.system.service.IDicService; +import com.njcn.user.pojo.constant.FunctionState; +import com.njcn.user.pojo.param.FunctionParam; +import com.njcn.user.pojo.po.Function; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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 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 getDicTree() { + List list = dicMapper.getAllDic(); + return list.stream() + .filter(fun -> Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid())) + .peek(funS -> funS.setChildren(getChildList(funS, list))) + .sorted(Comparator.comparingInt(DicVO::getSort)) + .collect(Collectors.toList()); + } + + /** + * 递归组装 + */ + private List getChildList(DicVO dictMenu, List 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 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); + } + } + +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventDictServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventDictServiceImpl.java index 6a6a7f4ef..d16d41c78 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventDictServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventDictServiceImpl.java @@ -109,7 +109,7 @@ public class EventDictServiceImpl extends ServiceImpl param.like("report_dict.name",dictQueryParam.getSearchValue()) - .or().like("report_dict.describe",dictQueryParam.getSearchValue())); + .or().like("report_dict.report_describe",dictQueryParam.getSearchValue())); } //排序 if (ObjectUtil.isAllNotEmpty(dictQueryParam.getSortBy(), dictQueryParam.getOrderBy())) { @@ -154,7 +154,7 @@ public class EventDictServiceImpl extends ServiceImpl getChildList(EventReportDictVO dictMenu, List categories) { return categories.stream().filter(o -> Objects.equals(o.getPid(), dictMenu.getId())) diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventTemplateServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventTemplateServiceImpl.java index 81b7b835d..0ec970052 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventTemplateServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/EventTemplateServiceImpl.java @@ -41,8 +41,24 @@ public class EventTemplateServiceImpl extends ServiceImpl getList() { - return this.list(); + public Page getList(EventTemplateParam.EventTemplateQueryParam queryParam) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtil.isNotNull(queryParam)) { + //查询参数不为空,进行条件填充 + if (StrUtil.isNotBlank(queryParam.getSearchValue())) { + //根据名称模糊查询 + queryWrapper + .and(param -> param.like("report_template.name", queryParam.getSearchValue())); + } + } + queryWrapper.ne("report_template.state", DataStateEnum.DELETED.getCode()); + if (queryParam.getType().equals(0)){ + queryWrapper.in("report_template.type",0); + }else if(queryParam.getType().equals(1)){ + queryWrapper.eq("report_template.type",1); + } + //初始化分页数据 + return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper); } /**