EventTemplate控制器编写
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.EventDictParam;
|
||||
import com.njcn.system.pojo.po.ReportDict;
|
||||
import com.njcn.system.service.IEventDictService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @createTime 2022/09/27
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/reportDict")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "字典数据管理")
|
||||
public class EventDictController extends BaseController {
|
||||
|
||||
private final IEventDictService iEventDictService;
|
||||
|
||||
/**
|
||||
* 新增字典
|
||||
* @param eventDictParam
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addDict")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("新增字典表")
|
||||
@ApiImplicitParam(name = "eventDictParam", value = "字典表数据", required = true)
|
||||
public HttpResult<Boolean> addDict(@RequestBody EventDictParam eventDictParam){
|
||||
String methodDescribe = getMethodDescribe("addDict");
|
||||
LogUtil.njcnDebug(log, "{},字典表数据数据为:{}", methodDescribe, eventDictParam);
|
||||
boolean res = iEventDictService.addDict(eventDictParam);
|
||||
if(res){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
} else{
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典
|
||||
* @param dictUpdateParam
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateDict")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("更新字典表")
|
||||
@ApiImplicitParam(name = "dictUpadateParam", value = "更新字典表实体", required = true)
|
||||
public HttpResult<Boolean> updateDict(@RequestBody EventDictParam.DictUpdateParam dictUpdateParam){
|
||||
String methodDescribe = getMethodDescribe("updateDict");
|
||||
LogUtil.njcnDebug(log, "{},字典表数据数据为:{}", methodDescribe, dictUpdateParam);
|
||||
boolean res = iEventDictService.updateDict(dictUpdateParam);
|
||||
if(res){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
} else{
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/deleteDict")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("删除字典表")
|
||||
@ApiImplicitParam(name = "id", value = "字典表索引", required = true)
|
||||
public HttpResult<Boolean> delDict(@RequestBody String id){
|
||||
String methodDescribe = getMethodDescribe("deleteDict");
|
||||
iEventDictService.delete(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典列表
|
||||
* @param dictQueryParam
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getList")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("查询字典列表")
|
||||
@ApiImplicitParam(name = "dictQueryParam", value = "查询字典列表实体", required = true)
|
||||
public HttpResult<Page<ReportDict>> getList(@RequestBody EventDictParam.DictQueryParam dictQueryParam){
|
||||
String methodDescribe = getMethodDescribe("getList");
|
||||
Page<ReportDict> res = iEventDictService.getList(dictQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getDictById")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("查询字典")
|
||||
public HttpResult<ReportDict> getDictById(String id){
|
||||
String methodDescribe = getMethodDescribe("getDictById");
|
||||
ReportDict res = iEventDictService.getDictById(id);
|
||||
if (Objects.nonNull(res)){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.EventTemplateParam;
|
||||
import com.njcn.system.pojo.po.EventTemplate;
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
import com.njcn.system.service.IEventTemplateService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -17,10 +15,12 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.jdbc.Null;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -38,38 +38,43 @@ public class EventTemplateController extends BaseController{
|
||||
|
||||
private final IEventTemplateService iEventTemplateService;
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@ApiOperation("获取字典树")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
|
||||
@GetMapping("/getEventTemplateTree")
|
||||
public HttpResult<List<EventTemplateTree>> getEventTemplateTree(){
|
||||
String methodDescribe = getMethodDescribe("getEventTemplateTree");
|
||||
List<EventTemplateTree> tree = iEventTemplateService.getEventTemplateTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典类型数据
|
||||
* 查询所有模板
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getList")
|
||||
@ApiOperation("查询字典数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<EventTemplate>> getList(@RequestBody @Validated EventTemplateParam.EventTemplateQueryParam queryParam) {
|
||||
@ApiOperation("查询模板数据")
|
||||
public HttpResult<List<EventTemplate>> getList() {
|
||||
String methodDescribe = getMethodDescribe("getList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<EventTemplate> result = iEventTemplateService.getList(queryParam);
|
||||
List<EventTemplate> result = iEventTemplateService.getList();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* 根据id查询模板
|
||||
* @author hany
|
||||
* @date 2022/09/26
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getTemplateById")
|
||||
@ApiOperation("查询模板数据")
|
||||
@ApiImplicitParam(name = "id",value = "模板id",required = true)
|
||||
public HttpResult<EventTemplate> getTemplateById(@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("getTemplateById");
|
||||
EventTemplate eventTemplate = iEventTemplateService.getTemplateById(id);
|
||||
if (Objects.nonNull(eventTemplate)){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventTemplate, methodDescribe);
|
||||
}
|
||||
else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模板
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@@ -77,7 +82,7 @@ public class EventTemplateController extends BaseController{
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("新增模板")
|
||||
@ApiImplicitParam(name = "eventTemplateParam", value = "模板数据", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated EventTemplateParam eventTemplateParam){
|
||||
public HttpResult<Object> add(@RequestBody @Validated EventTemplateParam eventTemplateParam){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
boolean result = iEventTemplateService.add(eventTemplateParam);
|
||||
if (result) {
|
||||
@@ -88,12 +93,12 @@ public class EventTemplateController extends BaseController{
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* 修改模板
|
||||
* @author hany
|
||||
* @date 2022/09/08
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.UPDATE)
|
||||
@ApiOperation("修改模板")
|
||||
@ApiImplicitParam(name = "eventUpdateParam", value = "模板实体", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated EventTemplateParam.EventTemplateUpdateParam eventUpdateParam){
|
||||
@@ -107,7 +112,8 @@ public class EventTemplateController extends BaseController{
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除模板
|
||||
* @param ids 暂态报表模板id
|
||||
* @author hany
|
||||
* @date 2022/09/08
|
||||
*/
|
||||
@@ -120,7 +126,8 @@ public class EventTemplateController extends BaseController{
|
||||
boolean result = iEventTemplateService.delete(ids);
|
||||
if(result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.system.pojo.vo.EventTemplateTree;
|
||||
import com.njcn.system.service.IEventTreeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "字典树管理")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/EventTree")
|
||||
public class EventTreeController extends BaseController {
|
||||
|
||||
private final IEventTreeService iEventTreeService;
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@ApiOperation("获取字典树")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
|
||||
@GetMapping("/getEventTree")
|
||||
public HttpResult<List<EventTemplateTree>> getEventTemplateTree(){
|
||||
String methodDescribe = getMethodDescribe("getEventTree");
|
||||
List<EventTemplateTree> tree = iEventTreeService.getEventTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.ReportDict;
|
||||
|
||||
public interface EventDictMapper extends BaseMapper<ReportDict> {
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.pojo.po.EventTemplate;
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,17 +14,9 @@ public interface EventTemplateMapper extends BaseMapper<EventTemplate> {
|
||||
|
||||
/**
|
||||
* 返回所有树节点(全部report_template_dict表数据)
|
||||
*
|
||||
* @author hany
|
||||
* @date 2022/09/21
|
||||
*/
|
||||
List<EventTemplateTree> getAllList();
|
||||
|
||||
/**
|
||||
* 分页查询字典数据
|
||||
* @param page 分页数据
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 字典数据
|
||||
*/
|
||||
Page<EventTemplate> page(@Param("page")Page<EventTemplate> page, @Param("ew") QueryWrapper<EventTemplate> queryWrapper);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
<!--获取所有表数据-->
|
||||
<select id="getAllList" resultType="com.njcn.system.pojo.vo.EventTemplateTree">
|
||||
select id, pid, name, level, sort
|
||||
from report_template_dict
|
||||
select id, name, type ,code
|
||||
from report_template
|
||||
where state = 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.pojo.param.EventDictParam;
|
||||
import com.njcn.system.pojo.po.ReportDict;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @createTime 2022/09/27
|
||||
*/
|
||||
public interface IEventDictService {
|
||||
/**
|
||||
* 新增字典
|
||||
* @param eventDictParam
|
||||
* @return
|
||||
*/
|
||||
boolean addDict(EventDictParam eventDictParam);
|
||||
|
||||
/**
|
||||
* 修改字典
|
||||
* @param dictUpdateParam
|
||||
* @return
|
||||
*/
|
||||
boolean updateDict(EventDictParam.DictUpdateParam dictUpdateParam);
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
/**
|
||||
* 查询字典列表
|
||||
* @param dictQueryParam
|
||||
* @return
|
||||
*/
|
||||
Page<ReportDict> getList(EventDictParam.DictQueryParam dictQueryParam);
|
||||
|
||||
/**
|
||||
* 查询字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ReportDict getDictById(String id);
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.pojo.param.EventTemplateParam;
|
||||
import com.njcn.system.pojo.po.EventTemplate;
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,30 +13,31 @@ import java.util.List;
|
||||
public interface IEventTemplateService {
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
*/
|
||||
List<EventTemplateTree> getEventTemplateTree();
|
||||
|
||||
/**
|
||||
* 根据前台传递参数,分页查询字典数据
|
||||
* @param queryParam 查询参数
|
||||
* 查询模板
|
||||
* @return 字典列表
|
||||
*/
|
||||
Page<EventTemplate> getList(EventTemplateParam.EventTemplateQueryParam queryParam);
|
||||
List<EventTemplate> getList();
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* 根据id查询模板
|
||||
* @return
|
||||
*/
|
||||
EventTemplate getTemplateById(String id);
|
||||
|
||||
/**
|
||||
* 新增模板
|
||||
* * @param EventTemplateParam 模板实体
|
||||
*/
|
||||
boolean add(EventTemplateParam eventTemplateParam);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* 修改模板
|
||||
* @param eventDataUpdateParam
|
||||
*/
|
||||
boolean update(EventTemplateParam.EventTemplateUpdateParam eventDataUpdateParam);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除模板
|
||||
* @param ids 模板ids
|
||||
*/
|
||||
boolean delete(List<String> ids);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
import java.util.List;
|
||||
|
||||
public interface IEventTreeService {
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
*
|
||||
* @author hany
|
||||
* @date 2022/09/26
|
||||
*/
|
||||
List<EventTemplateTree> getEventTree();
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
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.db.constant.DbConstant;
|
||||
import com.njcn.system.enums.EventResponseEnum;
|
||||
import com.njcn.system.mapper.EventDictMapper;
|
||||
import com.njcn.system.pojo.param.EventDictParam;
|
||||
import com.njcn.system.pojo.po.ReportDict;
|
||||
import com.njcn.system.service.IEventDictService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hany
|
||||
* @createTime 2022/09/27
|
||||
*/
|
||||
@Service
|
||||
public class EventDictServiceImpl extends ServiceImpl<EventDictMapper, ReportDict> implements IEventDictService {
|
||||
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
* @param eventDictParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean addDict (EventDictParam eventDictParam){
|
||||
checkName(eventDictParam,true);
|
||||
ReportDict rptDict = new ReportDict();
|
||||
BeanUtils.copyProperties(eventDictParam,rptDict);
|
||||
rptDict.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(rptDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @param dictUpdateParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean updateDict (EventDictParam.DictUpdateParam dictUpdateParam){
|
||||
checkName(dictUpdateParam,false);
|
||||
ReportDict rptDict = new ReportDict();
|
||||
BeanUtils.copyProperties(dictUpdateParam,rptDict);
|
||||
return this.updateById(rptDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean delete (String id){
|
||||
LambdaQueryWrapper<ReportDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ReportDict::getPid,id).eq(ReportDict::getState,DataStateEnum.ENABLE.getCode());
|
||||
int res = this.count(lambdaQueryWrapper);
|
||||
if(res>0){
|
||||
throw new BusinessException(EventResponseEnum.CHILDREN_EXIT);
|
||||
}
|
||||
UpdateWrapper<ReportDict> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda().eq(ReportDict::getState,DataStateEnum.ENABLE.getCode()).set(ReportDict::getState,DataStateEnum.DELETED.getCode()).eq(ReportDict::getId,id);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典列表
|
||||
* @param dictQueryParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<ReportDict> getList(EventDictParam.DictQueryParam dictQueryParam){
|
||||
QueryWrapper<ReportDict> queryWrapper = new QueryWrapper<>();
|
||||
if (Objects.nonNull(dictQueryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(dictQueryParam.getSearchValue())) {
|
||||
//字典类型表,提供名称、编码模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("report_dict.name",dictQueryParam.getSearchValue())
|
||||
.or().like("report_dict.describe",dictQueryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(dictQueryParam.getSortBy(), dictQueryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, dictQueryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(dictQueryParam.getSortBy()));
|
||||
}else{
|
||||
queryWrapper.eq("report_dict.pid",dictQueryParam.getPid());
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "report_dict.update_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("report_dict.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(dictQueryParam),PageFactory.getPageSize(dictQueryParam)),queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ReportDict getDictById(String id){
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称重复校验
|
||||
* @author hany
|
||||
* @date 2022/09/27
|
||||
*/
|
||||
private void checkName(EventDictParam eventDictParam,boolean flag){
|
||||
LambdaQueryWrapper<ReportDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ReportDict::getName,eventDictParam.getName())
|
||||
.eq(ReportDict::getState, DataStateEnum.ENABLE.getCode());
|
||||
//修改
|
||||
if(!flag){
|
||||
if(eventDictParam instanceof EventDictParam.DictUpdateParam ){
|
||||
lambdaQueryWrapper.ne(ReportDict::getId,((EventDictParam.DictUpdateParam)eventDictParam).getId());
|
||||
}
|
||||
}
|
||||
int res = this.count(lambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (res >= 1) {
|
||||
throw new BusinessException(EventResponseEnum.DIC_NAME_REPEAT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,23 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.plugins.pagination.Page;
|
||||
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.db.constant.DbConstant;
|
||||
import com.njcn.system.enums.EventResponseEnum;
|
||||
import com.njcn.system.enums.TemplateTreeEnum;
|
||||
import com.njcn.system.mapper.EventTemplateMapper;
|
||||
import com.njcn.system.pojo.param.EventTemplateParam;
|
||||
import com.njcn.system.pojo.po.EventTemplate;
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
import com.njcn.system.service.IEventTemplateService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: hany
|
||||
@@ -34,83 +26,28 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, EventTemplate> implements IEventTemplateService {
|
||||
|
||||
private final EventTemplateMapper eventTemplateMapper;
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@Override
|
||||
public List<EventTemplateTree> getEventTemplateTree() {
|
||||
List<EventTemplateTree> dictTree = new ArrayList<>();
|
||||
List<EventTemplateTree> allList = eventTemplateMapper.getAllList();
|
||||
List<EventTemplateTree> reportList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.REPORT_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> lineList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> detailList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.DETAIL_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> eventList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> densityList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_D_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> reasonList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_R_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, detailList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, eventList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, densityList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, reasonList)));
|
||||
reportList.forEach(report -> report.setChildren(getChildren(report, lineList)));
|
||||
|
||||
if (CollectionUtil.isNotEmpty(allList)) {
|
||||
EventTemplateTree eventTemplateTree = new EventTemplateTree();
|
||||
eventTemplateTree.setId("9999999");
|
||||
eventTemplateTree.setLevel(0);
|
||||
eventTemplateTree.setName("新增模板");
|
||||
if (CollectionUtil.isNotEmpty(reportList)) {
|
||||
eventTemplateTree.setChildren(reportList);
|
||||
}
|
||||
dictTree.add(eventTemplateTree);
|
||||
}
|
||||
return dictTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部子节点
|
||||
*
|
||||
* @author hany
|
||||
* @date 2022/09/21
|
||||
*/
|
||||
public List<EventTemplateTree> getChildren(EventTemplateTree item, List<EventTemplateTree> all) {
|
||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典类型数据
|
||||
* 查询所有模板
|
||||
* @author hany
|
||||
* @date 2022/09/13
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<EventTemplate> getList(EventTemplateParam.EventTemplateQueryParam queryParam) {
|
||||
QueryWrapper<EventTemplate> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//字典类型表,仅提供名称和编码模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("report_template.name",queryParam.getSearchValue())
|
||||
.or().like("report_template.code",queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "report_template.update_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.ne("report_template.state", DataStateEnum.DELETED.getCode());
|
||||
//初始化分页数据
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
public List<EventTemplate> getList() {
|
||||
return this.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询模板数据
|
||||
* @author hany
|
||||
* @date 2022/09/26
|
||||
*/
|
||||
@Override
|
||||
public EventTemplate getTemplateById(String id) {
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +58,10 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
|
||||
@Override
|
||||
public boolean add(EventTemplateParam eventTemplateParam) {
|
||||
checkName(eventTemplateParam,true);
|
||||
EventTemplate eventDict = new EventTemplate();
|
||||
BeanUtils.copyProperties(eventTemplateParam,eventDict);
|
||||
eventDict.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(eventDict);
|
||||
EventTemplate eventTemplate = new EventTemplate();
|
||||
BeanUtils.copyProperties(eventTemplateParam,eventTemplate);
|
||||
eventTemplate.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(eventTemplate);
|
||||
}
|
||||
/**
|
||||
* 修改模板
|
||||
@@ -132,9 +69,9 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
|
||||
@Override
|
||||
public boolean update(EventTemplateParam.EventTemplateUpdateParam eventTemplateUpdateParam) {
|
||||
checkName(eventTemplateUpdateParam,false);
|
||||
EventTemplate eventDict = new EventTemplate();
|
||||
BeanUtils.copyProperties(eventTemplateUpdateParam,eventDict);
|
||||
return this.updateById(eventDict);
|
||||
EventTemplate eventTemplate = new EventTemplate();
|
||||
BeanUtils.copyProperties(eventTemplateUpdateParam,eventTemplate);
|
||||
return this.updateById(eventTemplate);
|
||||
|
||||
}
|
||||
|
||||
@@ -153,16 +90,16 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
|
||||
private void checkName(EventTemplateParam eventTemplateParam,boolean flag){
|
||||
LambdaQueryWrapper<EventTemplate> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EventTemplate::getName,eventTemplateParam.getName())
|
||||
.eq(EventTemplate::getState, DataStateEnum.ENABLE.getCode());
|
||||
.eq(EventTemplate::getType,eventTemplateParam.getType());
|
||||
//修改
|
||||
if(!flag){
|
||||
if(eventTemplateParam instanceof EventTemplateParam.EventTemplateUpdateParam ){
|
||||
lambdaQueryWrapper.ne(EventTemplate::getId,((EventTemplateParam.EventTemplateUpdateParam)eventTemplateParam).getId());
|
||||
}
|
||||
}
|
||||
int res = this.count(lambdaQueryWrapper);
|
||||
int result = this.count(lambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (res >= 1) {
|
||||
if (result >= 1) {
|
||||
throw new BusinessException(EventResponseEnum.DIC_NAME_REPEAT);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.njcn.system.enums.TemplateTreeEnum;
|
||||
import com.njcn.system.mapper.EventTemplateMapper;
|
||||
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||
import com.njcn.system.service.IEventTreeService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class EventTreeServiceImpl implements IEventTreeService {
|
||||
|
||||
private final EventTemplateMapper eventTemplateMapper;
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
* @author hany
|
||||
* @date 2022/09/09
|
||||
*/
|
||||
@Override
|
||||
public List<EventTemplateTree> getEventTree() {
|
||||
List<EventTemplateTree> dictTree = new ArrayList<>();
|
||||
List<EventTemplateTree> allList = eventTemplateMapper.getAllList();
|
||||
List<EventTemplateTree> reportList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.REPORT_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> lineList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> detailList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.DETAIL_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> eventList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> densityList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_D_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
List<EventTemplateTree> reasonList = allList.stream().filter(item -> item.getLevel().equals(TemplateTreeEnum.TRANS_R_LEVEL.getCode())).sorted(Comparator.comparing(EventTemplateTree::getSort)).collect(Collectors.toList());
|
||||
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, detailList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, eventList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, densityList)));
|
||||
lineList.forEach(line -> line.setChildren(getChildren(line, reasonList)));
|
||||
reportList.forEach(report -> report.setChildren(getChildren(report, lineList)));
|
||||
|
||||
if (CollectionUtil.isNotEmpty(allList)) {
|
||||
EventTemplateTree eventTemplateTree = new EventTemplateTree();
|
||||
eventTemplateTree.setId("9999999");
|
||||
eventTemplateTree.setLevel(0);
|
||||
eventTemplateTree.setName("新增模板");
|
||||
if (CollectionUtil.isNotEmpty(reportList)) {
|
||||
eventTemplateTree.setChildren(reportList);
|
||||
}
|
||||
dictTree.add(eventTemplateTree);
|
||||
}
|
||||
return dictTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部子节点
|
||||
*
|
||||
* @author hany
|
||||
* @date 2022/09/21
|
||||
*/
|
||||
public List<EventTemplateTree> getChildren(EventTemplateTree item, List<EventTemplateTree> all) {
|
||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user