feat: 通用标准体系-增删改查
This commit is contained in:
@@ -26,4 +26,9 @@ public class FillRuleConstant {
|
||||
*/
|
||||
public static final String CATEGORY = "category_code_rule";
|
||||
|
||||
/**
|
||||
* 体系字典编码
|
||||
*/
|
||||
public static final String SYSTEM = "system_tree_node";
|
||||
|
||||
}
|
||||
|
||||
@@ -60,4 +60,42 @@ public class FillRuleUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ruleCode ruleCode
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Object executeRuleByParam(String ruleCode, JSONObject formData, String moduleCode) {
|
||||
if (!StringUtils.isEmpty(ruleCode)) {
|
||||
try {
|
||||
// 获取 Service
|
||||
ServiceImpl<BaseMapper<T>,T> impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
|
||||
// 根据 ruleCode 查询出实体
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("rule_code", ruleCode);
|
||||
JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
|
||||
if (entity == null) {
|
||||
log.warn("填值规则:" + ruleCode + " 不存在");
|
||||
return null;
|
||||
}
|
||||
// 获取必要的参数
|
||||
String ruleClass = entity.getString("ruleClass");
|
||||
JSONObject params = entity.getJSONObject("ruleParams");
|
||||
if (params == null) {
|
||||
params = new JSONObject();
|
||||
}
|
||||
if (formData == null) {
|
||||
formData = new JSONObject();
|
||||
}
|
||||
params.put("moduleCode", moduleCode);
|
||||
// 通过反射执行配置的类里的方法
|
||||
IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
|
||||
return ruleHandler.execute(params, formData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.jero.modules.laws.enterprise.entity.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 封装树结构的部门的名称的实体类
|
||||
* <p>
|
||||
*
|
||||
* @Author Steve
|
||||
* @Since 2019-01-22
|
||||
*
|
||||
*/
|
||||
public class NodeIdModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 主键ID
|
||||
private String key;
|
||||
|
||||
// 主键ID
|
||||
private String value;
|
||||
|
||||
// 部门名称
|
||||
private String title;
|
||||
|
||||
private List<NodeIdModel> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 将SysDepartTreeModel的部分数据放在该对象当中
|
||||
* @param lawsTreeNodeModel
|
||||
* @return
|
||||
*/
|
||||
public NodeIdModel convert(LawsTreeNodeModel lawsTreeNodeModel) {
|
||||
this.key = lawsTreeNodeModel.getId();
|
||||
this.value = lawsTreeNodeModel.getId();
|
||||
this.title = lawsTreeNodeModel.getNodeName();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 该方法为用户部门的实现类所使用
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
public NodeIdModel convertByLawsNode(LawsTreeNode lawsTreeNode) {
|
||||
this.key = lawsTreeNode.getId();
|
||||
this.value = lawsTreeNode.getId();
|
||||
this.title = lawsTreeNode.getNodeName();
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<NodeIdModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<NodeIdModel> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public static long getSerialVersionUID() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.jero.modules.laws.enterprise.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/9/11 17:13
|
||||
*/
|
||||
@Data
|
||||
public class LawsTreeNodeModel {
|
||||
|
||||
private static final long serialVersionUID = 1986758798970890734L;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的key*/
|
||||
private String key;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的value*/
|
||||
private String value;
|
||||
|
||||
/** 对应depart_name字段,前端数据树中的title*/
|
||||
private String title;
|
||||
|
||||
private boolean isLeaf;
|
||||
|
||||
// 以下所有字段均与LawsTreeNode相同
|
||||
|
||||
/**主键ID*/
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysCode;
|
||||
/**0表示未删除,1表示删除*/
|
||||
@ApiModelProperty(value = "0表示未删除,1表示删除")
|
||||
private java.lang.Integer delFlag;
|
||||
/**父节点id*/
|
||||
@ApiModelProperty(value = "父节点id")
|
||||
private java.lang.String parentId;
|
||||
/**父节点code*/
|
||||
@ApiModelProperty(value = "父节点code")
|
||||
private java.lang.String parentCode;
|
||||
/**节点code*/
|
||||
@ApiModelProperty(value = "节点code")
|
||||
private java.lang.String nodeCode;
|
||||
/**节点名*/
|
||||
@ApiModelProperty(value = "节点名")
|
||||
private java.lang.String nodeName;
|
||||
/**所属模块编码*/
|
||||
@ApiModelProperty(value = "所属模块编码")
|
||||
private java.lang.String moduleCode;
|
||||
/**节点类型(1-根节点、2-子节点)*/
|
||||
@ApiModelProperty(value = "节点类型(1-根节点、2-子节点)")
|
||||
private java.lang.Integer nodeType;
|
||||
/**排序*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private java.lang.Integer nodeOrder;
|
||||
|
||||
private List<LawsTreeNodeModel> children = new ArrayList<>();
|
||||
|
||||
public void setChildren(List<LawsTreeNodeModel> children) {
|
||||
if (children==null){
|
||||
this.isLeaf=true;
|
||||
}
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.jero.modules.laws.enterprise.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.handler.IFillRuleHandler;
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.common.util.YouBianCodeUtil;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
import com.jero.modules.laws.standard.service.ILawsTreeNodeService;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/9/12 10:38
|
||||
*/
|
||||
public class SystemTreeRule implements IFillRuleHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(JSONObject params, JSONObject formData) {
|
||||
String moduleCode = (String)params.get("module_code");
|
||||
ILawsTreeNodeService lawsTreeNodeService = (ILawsTreeNodeService) SpringContextUtils.getBean("lawsTreeNodeServiceImpl");
|
||||
|
||||
LambdaQueryWrapper<LawsTreeNode> query = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<LawsTreeNode> query1 = new LambdaQueryWrapper<>();
|
||||
// 创建一个List集合,存储查询返回的所有LawsTreeNode对象
|
||||
List<LawsTreeNode> nodeList;
|
||||
String[] strArray = new String[2];
|
||||
// 定义部门类型
|
||||
String orgType = "";
|
||||
// 定义新编码字符串
|
||||
String newOrgCode = "";
|
||||
// 定义旧编码字符串
|
||||
String oldOrgCode = "";
|
||||
|
||||
String parentId = getParentId(params, formData);
|
||||
|
||||
//如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
||||
if (StringUtil.isNullOrEmpty(parentId)) {
|
||||
// 线判断数据库中的表是否为空,空则直接返回初始编码
|
||||
query1.eq(LawsTreeNode::getParentId, "").or().isNull(LawsTreeNode::getParentId);
|
||||
query1.eq(LawsTreeNode::getModuleCode, moduleCode);
|
||||
query1.orderByDesc(LawsTreeNode::getNodeCode);
|
||||
nodeList = lawsTreeNodeService.list(query1);
|
||||
if (nodeList == null || nodeList.isEmpty()) {
|
||||
strArray[0] = YouBianCodeUtil.getNextYouBianCode(null);
|
||||
strArray[1] = "1";
|
||||
return strArray;
|
||||
} else {
|
||||
LawsTreeNode node = nodeList.get(0);
|
||||
oldOrgCode = node.getNodeCode();
|
||||
orgType = String.valueOf(node.getNodeType());
|
||||
newOrgCode = YouBianCodeUtil.getNextYouBianCode(oldOrgCode);
|
||||
}
|
||||
} else {//反之则查询出所有同级的部门,获取结果后有两种情况,有同级和没有同级
|
||||
// 封装查询同级的条件
|
||||
query.eq(LawsTreeNode::getParentId, parentId);
|
||||
// 按照模块查询
|
||||
query.eq(LawsTreeNode::getModuleCode, moduleCode);
|
||||
// 降序排序
|
||||
query.orderByDesc(LawsTreeNode::getNodeCode);
|
||||
// 查询出同级部门的集合
|
||||
List<LawsTreeNode> parentList = lawsTreeNodeService.list(query);
|
||||
// 查询出父级部门
|
||||
LawsTreeNode node = lawsTreeNodeService.getById(parentId);
|
||||
// 获取父级部门的Code
|
||||
String parentCode = node.getNodeCode();
|
||||
// 根据父级部门类型算出当前部门的类型
|
||||
orgType = String.valueOf(node.getNodeType() + 1);
|
||||
// 处理同级部门为null的情况
|
||||
if (parentList == null || parentList.isEmpty()) {
|
||||
// 直接生成当前的部门编码并返回
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null);
|
||||
} else { //处理有同级部门的情况
|
||||
// 获取同级部门的编码,利用工具类
|
||||
String subCode = parentList.get(0).getNodeCode();
|
||||
// 返回生成的当前部门编码
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, subCode);
|
||||
}
|
||||
}
|
||||
// 返回最终封装了部门编码和部门类型的数组
|
||||
strArray[0] = newOrgCode;
|
||||
strArray[1] = orgType;
|
||||
return strArray;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getParentId(JSONObject params, JSONObject formData) {
|
||||
String parentId = null;
|
||||
if (formData != null && formData.size() > 0) {
|
||||
Object obj = formData.get("parentId");
|
||||
if (obj != null) {
|
||||
parentId = obj.toString();
|
||||
}
|
||||
} else {
|
||||
if (params != null) {
|
||||
Object obj = params.get("parentId");
|
||||
if (obj != null) {
|
||||
parentId = obj.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentId;
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package com.jero.modules.laws.enterprise.util;
|
||||
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.laws.enterprise.entity.model.NodeIdModel;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FindsTreeNodeChildrenUtil {
|
||||
|
||||
private FindsTreeNodeChildrenUtil(){}
|
||||
|
||||
/**
|
||||
* queryTreeList的子方法 ====1=====
|
||||
* 该方法是s将SysDepart类型的list集合转换成SysDepartTreeModel类型的集合
|
||||
*/
|
||||
public static List<LawsTreeNodeModel> wrapTreeDataToTreeList(List<LawsTreeNode> recordList) {
|
||||
// 在该方法每请求一次,都要对全局list集合进行一次清理
|
||||
List<NodeIdModel> idList = new ArrayList<>();
|
||||
List<LawsTreeNodeModel> records = new ArrayList<>();
|
||||
for (LawsTreeNode treeNode : recordList) {
|
||||
LawsTreeNodeModel lawsTreeNodeModel = new LawsTreeNodeModel();
|
||||
// 将sysDepart转换为sysDepartTreeModel
|
||||
convertSysDepartToSysDepartTreeModel(treeNode, lawsTreeNodeModel);
|
||||
records.add(lawsTreeNodeModel);
|
||||
}
|
||||
List<LawsTreeNodeModel> tree = findChildren(records, idList);
|
||||
setEmptyChildrenAsNull(tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static List<NodeIdModel> wrapTreeDataToNodeIdTreeList(List<LawsTreeNode> recordList) {
|
||||
// 在该方法每请求一次,都要对全局list集合进行一次清理
|
||||
List<NodeIdModel> idList = new ArrayList<>();
|
||||
List<LawsTreeNodeModel> records = new ArrayList<>();
|
||||
for (LawsTreeNode node : recordList) {
|
||||
LawsTreeNodeModel lawsTreeNodeModel = new LawsTreeNodeModel();
|
||||
// 将sysDepart转换为sysDepartTreeModel
|
||||
convertSysDepartToSysDepartTreeModel(node, lawsTreeNodeModel);
|
||||
records.add(lawsTreeNodeModel);
|
||||
}
|
||||
findChildren(records, idList);
|
||||
return idList;
|
||||
}
|
||||
|
||||
/**
|
||||
* queryTreeList的子方法 ====2=====
|
||||
* 该方法是找到并封装顶级父类的节点到TreeList集合
|
||||
*/
|
||||
private static List<LawsTreeNodeModel> findChildren(List<LawsTreeNodeModel> recordList,
|
||||
List<NodeIdModel> nodeIdList) {
|
||||
|
||||
List<LawsTreeNodeModel> treeList = new ArrayList<>();
|
||||
for (LawsTreeNodeModel branch : recordList) {
|
||||
if (oConvertUtils.isEmpty(branch.getParentId())) {
|
||||
treeList.add(branch);
|
||||
NodeIdModel nodeIdModel = new NodeIdModel().convert(branch);
|
||||
nodeIdList.add(nodeIdModel);
|
||||
}
|
||||
}
|
||||
getGrandChildren(treeList, recordList, nodeIdList);
|
||||
return treeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* queryTreeList的子方法====3====
|
||||
* 该方法是找到顶级父类下的所有子节点集合并封装到TreeList集合
|
||||
*/
|
||||
private static void getGrandChildren(List<LawsTreeNodeModel> treeList, List<LawsTreeNodeModel> recordList, List<NodeIdModel> idList) {
|
||||
for (int i = 0; i < treeList.size(); i++) {
|
||||
LawsTreeNodeModel model = treeList.get(i);
|
||||
NodeIdModel idModel = idList.get(i);
|
||||
for (LawsTreeNodeModel m : recordList) {
|
||||
if (m.getParentId() != null && m.getParentId().equals(model.getId())) {
|
||||
model.getChildren().add(m);
|
||||
NodeIdModel dim = new NodeIdModel().convert(m);
|
||||
|
||||
idModel.getChildren().add(dim);
|
||||
}
|
||||
}
|
||||
getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* queryTreeList的子方法 ====4====
|
||||
* 该方法是将子节点为空的List集合设置为Null值
|
||||
*/
|
||||
private static void setEmptyChildrenAsNull(List<LawsTreeNodeModel> treeList) {
|
||||
|
||||
for (LawsTreeNodeModel model : treeList) {
|
||||
if (model.getChildren().isEmpty()) {
|
||||
model.setChildren(null);
|
||||
model.setLeaf(true);
|
||||
} else {
|
||||
setEmptyChildrenAsNull(model.getChildren());
|
||||
model.setLeaf(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将LawsTreeNode对象转换成LawsTreeNodeModel对象
|
||||
* @param lawsTreeNode 待转换的对象
|
||||
* @param lawsTreeNodeModel 转换的结果对象
|
||||
*/
|
||||
public static void convertSysDepartToSysDepartTreeModel(LawsTreeNode lawsTreeNode, LawsTreeNodeModel lawsTreeNodeModel){
|
||||
lawsTreeNodeModel.setKey(lawsTreeNode.getId());
|
||||
lawsTreeNodeModel.setValue( lawsTreeNode.getId());
|
||||
lawsTreeNodeModel.setTitle(lawsTreeNode.getNodeName());
|
||||
lawsTreeNodeModel.setId(lawsTreeNode.getId());
|
||||
lawsTreeNodeModel.setParentId(lawsTreeNode.getParentId());
|
||||
lawsTreeNodeModel.setParentCode(lawsTreeNode.getParentCode());
|
||||
lawsTreeNodeModel.setNodeCode(lawsTreeNode.getNodeCode());
|
||||
lawsTreeNodeModel.setNodeName(lawsTreeNode.getNodeName());
|
||||
lawsTreeNodeModel.setModuleCode(lawsTreeNode.getModuleCode());
|
||||
lawsTreeNodeModel.setNodeType(lawsTreeNode.getNodeType());
|
||||
lawsTreeNodeModel.setNodeOrder(lawsTreeNode.getNodeOrder());
|
||||
lawsTreeNodeModel.setDelFlag(lawsTreeNode.getDelFlag());
|
||||
lawsTreeNodeModel.setCreateBy(lawsTreeNode.getCreateBy());
|
||||
lawsTreeNodeModel.setCreateTime(lawsTreeNode.getCreateTime());
|
||||
lawsTreeNodeModel.setUpdateBy(lawsTreeNode.getUpdateBy());
|
||||
lawsTreeNodeModel.setUpdateTime(lawsTreeNode.getUpdateTime());
|
||||
lawsTreeNodeModel.setSysCode(lawsTreeNode.getSysCode());
|
||||
}
|
||||
}
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
package com.jero.modules.laws.standard.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.jero.modules.laws.standard.service.ILawsNodeRelationService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 树型节点关联
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="树型节点关联")
|
||||
@RestController
|
||||
@RequestMapping("/laws/standard/lawsNodeRelation")
|
||||
@Slf4j
|
||||
public class LawsNodeRelationController extends JeroController<LawsNodeRelation, ILawsNodeRelationService> {
|
||||
@Autowired
|
||||
private ILawsNodeRelationService lawsNodeRelationService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-分页列表查询")
|
||||
@ApiOperation(value="树型节点关联-分页列表查询", notes="树型节点关联-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<LawsNodeRelation>> queryPageList(LawsNodeRelation lawsNodeRelation,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
IPage<LawsNodeRelation> pageList = lawsNodeRelationService.queryPage(lawsNodeRelation, pageNo, pageSize, req);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-列表查询")
|
||||
@ApiOperation(value="树型节点关联-列表查询", notes="树型节点关联-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LawsNodeRelation>> queryList(LawsNodeRelation lawsNodeRelation, HttpServletRequest req) {
|
||||
List<LawsNodeRelation> list = lawsNodeRelationService.queryList(lawsNodeRelation, req);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-添加")
|
||||
@ApiOperation(value="树型节点关联-添加", notes="树型节点关联-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@Validated @RequestBody LawsNodeRelation lawsNodeRelation) {
|
||||
lawsNodeRelationService.add(lawsNodeRelation);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-编辑")
|
||||
@ApiOperation(value="树型节点关联-编辑", notes="树型节点关联-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<T> edit(@Validated @RequestBody LawsNodeRelation lawsNodeRelation) {
|
||||
lawsNodeRelationService.editById(lawsNodeRelation);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-通过id删除")
|
||||
@ApiOperation(value="树型节点关联-通过id删除", notes="树型节点关联-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
lawsNodeRelationService.deleteById(map.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-批量删除")
|
||||
@ApiOperation(value="树型节点关联-批量删除", notes="树型节点关联-批量删除")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
this.lawsNodeRelationService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点关联-通过id查询")
|
||||
@ApiOperation(value="树型节点关联-通过id查询", notes="树型节点关联-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LawsNodeRelation> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
LawsNodeRelation lawsNodeRelation = lawsNodeRelationService.queryById(id);
|
||||
if(lawsNodeRelation==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(lawsNodeRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param lawsNodeRelation
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LawsNodeRelation lawsNodeRelation) {
|
||||
return super.exportXls(request, lawsNodeRelation, LawsNodeRelation.class, "树型节点关联");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<LawsNodeRelation> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, LawsNodeRelation.class);
|
||||
}
|
||||
|
||||
}
|
||||
+87
-140
@@ -1,20 +1,18 @@
|
||||
package com.jero.modules.laws.standard.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
import com.jero.modules.laws.standard.service.ILawsTreeNodeService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
@@ -22,155 +20,104 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Description: 树型节点
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-11
|
||||
* @Date: 2023-09-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="树型节点")
|
||||
@Api(tags = "标准体系")
|
||||
@RestController
|
||||
@RequestMapping("/laws/standard/lawsTreeNode")
|
||||
@Slf4j
|
||||
public class LawsTreeNodeController extends JeroController<LawsTreeNode, ILawsTreeNodeService> {
|
||||
@Autowired
|
||||
private ILawsTreeNodeService lawsTreeNodeService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-分页列表查询")
|
||||
@ApiOperation(value="树型节点-分页列表查询", notes="树型节点-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<LawsTreeNode>> queryPageList(LawsTreeNode lawsTreeNode,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
IPage<LawsTreeNode> pageList = lawsTreeNodeService.queryPage(lawsTreeNode, pageNo, pageSize, req);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
@Resource
|
||||
private ILawsTreeNodeService lawsTreeNodeService;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-列表查询")
|
||||
@ApiOperation(value="树型节点-列表查询", notes="树型节点-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LawsTreeNode>> queryList(LawsTreeNode lawsTreeNode, HttpServletRequest req) {
|
||||
List<LawsTreeNode> list = lawsTreeNodeService.queryList(lawsTreeNode, req);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-添加")
|
||||
@ApiOperation(value="树型节点-添加", notes="树型节点-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@Validated @RequestBody LawsTreeNode lawsTreeNode) {
|
||||
lawsTreeNodeService.add(lawsTreeNode);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-编辑")
|
||||
@ApiOperation(value="树型节点-编辑", notes="树型节点-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<T> edit(@Validated @RequestBody LawsTreeNode lawsTreeNode) {
|
||||
lawsTreeNodeService.editById(lawsTreeNode);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-通过id删除")
|
||||
@ApiOperation(value="树型节点-通过id删除", notes="树型节点-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
|
||||
return Result.error("请选择数据!");
|
||||
@AutoLog(value = "标准体系-体系树")
|
||||
@ApiOperation(value = "标准体系-体系树", notes = "标准体系-体系树")
|
||||
@GetMapping("/{moduleCode}")
|
||||
public Result<List<LawsTreeNodeModel>> queryTreeList(@PathVariable("moduleCode") String moduleCode) {
|
||||
Result<List<LawsTreeNodeModel>> result = new Result<>();
|
||||
try {
|
||||
List<LawsTreeNodeModel> list = lawsTreeNodeService.queryTreeNodeList(moduleCode);
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
lawsTreeNodeService.deleteById(map.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-批量删除")
|
||||
@ApiOperation(value="树型节点-批量删除", notes="树型节点-批量删除")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
this.lawsTreeNodeService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "树型节点-通过id查询")
|
||||
@ApiOperation(value="树型节点-通过id查询", notes="树型节点-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LawsTreeNode> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
LawsTreeNode lawsTreeNode = lawsTreeNodeService.queryById(id);
|
||||
if(lawsTreeNode==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(lawsTreeNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param lawsTreeNode
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LawsTreeNode lawsTreeNode) {
|
||||
return super.exportXls(request, lawsTreeNode, LawsTreeNode.class, "树型节点");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<LawsTreeNode> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, LawsTreeNode.class);
|
||||
* 添加
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "标准体系-添加")
|
||||
@ApiOperation(value = "标准体系-添加", notes = "标准体系-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@RequestBody LawsTreeNode lawsTreeNode, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
try {
|
||||
lawsTreeNode.setCreateBy(username);
|
||||
lawsTreeNodeService.saveTreeNodeData(lawsTreeNode, username);
|
||||
return Result.OK("操作成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "标准体系-编辑")
|
||||
@ApiOperation(value = "标准体系-编辑", notes = "标准体系-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<T> edit(@Validated @RequestBody LawsTreeNode lawsTreeNode, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
lawsTreeNode.setUpdateBy(username);
|
||||
LawsTreeNode lawsTreeNodeEntity = lawsTreeNodeService.getById(lawsTreeNode.getId());
|
||||
if (lawsTreeNodeEntity == null) {
|
||||
return Result.error("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = lawsTreeNodeService.updateTreeNodeDataById(lawsTreeNode, username);
|
||||
if (ok) {
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
}
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "标准体系-通过id删除")
|
||||
@ApiOperation(value = "标准体系-通过id删除", notes = "标准体系-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
String id = map.get("id");
|
||||
if (StringUtils.isBlank(id)) {
|
||||
return Result.error("参数不识别!");
|
||||
}
|
||||
LawsTreeNode lawsTreeNode = lawsTreeNodeService.getById(id);
|
||||
if (lawsTreeNode == null) {
|
||||
return Result.error("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = lawsTreeNodeService.delete(id, lawsTreeNode.getNodeCode());
|
||||
if (ok) {
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
}
|
||||
return Result.OK();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -31,12 +31,17 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_node_relation对象", description="树型节点关联")
|
||||
public class LawsNodeRelation implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 8767689768978692121L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**节点Id*/
|
||||
@Excel(name = "节点code", width = 15)
|
||||
@ApiModelProperty(value = "节点Id")
|
||||
private java.lang.String nodeId;
|
||||
/**节点code*/
|
||||
@Excel(name = "节点code", width = 15)
|
||||
@ApiModelProperty(value = "节点code")
|
||||
|
||||
@@ -31,7 +31,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_tree_node对象", description="树型节点")
|
||||
public class LawsTreeNode implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 8976087978697689121L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@@ -54,35 +55,30 @@ public class LawsTreeNode implements Serializable {
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Excel(name = "所属部门", width = 15)
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysCode;
|
||||
/**0表示未删除,1表示删除*/
|
||||
@Excel(name = "0表示未删除,1表示删除", width = 15)
|
||||
@ApiModelProperty(value = "0表示未删除,1表示删除")
|
||||
private java.lang.Integer delFlag;
|
||||
/**父节点id*/
|
||||
@Excel(name = "父节点id", width = 15)
|
||||
@ApiModelProperty(value = "父节点id")
|
||||
private java.lang.String parentId;
|
||||
/**父节点code*/
|
||||
@Excel(name = "父节点code", width = 15)
|
||||
@ApiModelProperty(value = "父节点code")
|
||||
private java.lang.String parentCode;
|
||||
/**节点code*/
|
||||
@Excel(name = "节点code", width = 15)
|
||||
@ApiModelProperty(value = "节点code")
|
||||
private java.lang.String nodeCode;
|
||||
/**节点名*/
|
||||
@Excel(name = "节点名", width = 15)
|
||||
@ApiModelProperty(value = "节点名")
|
||||
private java.lang.String nodeName;
|
||||
/**所属模块编码*/
|
||||
@Excel(name = "所属模块编码", width = 15)
|
||||
@ApiModelProperty(value = "所属模块编码")
|
||||
private java.lang.String moduleCode;
|
||||
/**节点类型(1-根节点、2-子节点)*/
|
||||
@Excel(name = "节点类型(1-根节点、2-子节点)", width = 15)
|
||||
@ApiModelProperty(value = "节点类型(1-根节点、2-子节点)")
|
||||
private java.lang.Integer nodeType;
|
||||
/**排序*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private java.lang.Integer nodeOrder;
|
||||
}
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
<mapper namespace="com.jero.modules.laws.standard.mapper.LawsNodeRelationMapper">
|
||||
<resultMap id="LawsNodeRelationResultMap" type="com.jero.modules.laws.standard.entity.LawsNodeRelation">
|
||||
<id column="id" property="id" />
|
||||
<result column="node_id" property="nodeId" />
|
||||
<result column="node_code" property="nodeCode" />
|
||||
<result column="unique_relation_flag" property="uniqueRelationFlag" />
|
||||
<result column="module_code" property="moduleCode" />
|
||||
|
||||
+13
-42
@@ -1,9 +1,9 @@
|
||||
package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,63 +14,34 @@ import java.util.List;
|
||||
*/
|
||||
public interface ILawsTreeNodeService extends IService<LawsTreeNode> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
/**
|
||||
* 查询体系树
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
IPage<LawsTreeNode> queryPage(LawsTreeNode lawsTreeNode, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<LawsTreeNode> queryList(LawsTreeNode lawsTreeNode, HttpServletRequest req);
|
||||
List<LawsTreeNodeModel> queryTreeNodeList(String moduleCode);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* 新增
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
* @param username
|
||||
*/
|
||||
void add(LawsTreeNode lawsTreeNode);
|
||||
void saveTreeNodeData(LawsTreeNode lawsTreeNode, String username);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
void editById(LawsTreeNode lawsTreeNode);
|
||||
boolean updateTreeNodeDataById(LawsTreeNode lawsTreeNode, String username);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param nodeCode
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LawsTreeNode queryById(String id);
|
||||
boolean delete(String id, String nodeCode);
|
||||
}
|
||||
|
||||
+105
-87
@@ -1,118 +1,136 @@
|
||||
package com.jero.modules.laws.standard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.constant.FillRuleConstant;
|
||||
import com.jero.common.util.FillRuleUtil;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.enterprise.util.FindsTreeNodeChildrenUtil;
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.jero.modules.laws.standard.entity.LawsTreeNode;
|
||||
import com.jero.modules.laws.standard.mapper.LawsNodeRelationMapper;
|
||||
import com.jero.modules.laws.standard.mapper.LawsTreeNodeMapper;
|
||||
import com.jero.modules.laws.standard.service.ILawsTreeNodeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description: 树型节点
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-09-11
|
||||
* @Date: 2023-09-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsTreeNodeServiceImpl extends ServiceImpl<LawsTreeNodeMapper, LawsTreeNode> implements ILawsTreeNodeService {
|
||||
|
||||
@Resource
|
||||
private LawsNodeRelationMapper lawsNodeRelationMapper;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<LawsTreeNode> queryPage(LawsTreeNode lawsTreeNode, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LawsTreeNode> queryWrapper = QueryGenerator.initQueryWrapper(lawsTreeNode, req.getParameterMap());
|
||||
Page<LawsTreeNode> page = new Page<>(pageNo, pageSize);
|
||||
return page(page, queryWrapper);
|
||||
public List<LawsTreeNodeModel> queryTreeNodeList(String moduleCode) {
|
||||
LambdaQueryWrapper<LawsTreeNode> query = new LambdaQueryWrapper<>();
|
||||
query.eq(LawsTreeNode::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.eq(LawsTreeNode::getModuleCode, moduleCode);
|
||||
query.orderByAsc(LawsTreeNode::getNodeOrder);
|
||||
List<LawsTreeNode> list = this.list(query);
|
||||
// 调用wrapTreeDataToTreeList方法生成树状数据
|
||||
return FindsTreeNodeChildrenUtil.wrapTreeDataToTreeList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTreeNodeData(LawsTreeNode lawsTreeNode, String username) {
|
||||
if (lawsTreeNode != null && username != null) {
|
||||
if (lawsTreeNode.getParentId() == null) {
|
||||
lawsTreeNode.setParentId("");
|
||||
}
|
||||
String s = UUID.randomUUID().toString().replace("-", "");
|
||||
lawsTreeNode.setId(s);
|
||||
// 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
|
||||
// 获取父级ID
|
||||
String parentId = lawsTreeNode.getParentId();
|
||||
//update-begin--Author:baihailong Date:20191209 for:部门编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("parentId", parentId);
|
||||
String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.SYSTEM, formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:部门编码规则生成器做成公用配置
|
||||
lawsTreeNode.setNodeCode(codeArray[0]);
|
||||
String nodeType = codeArray[1];
|
||||
lawsTreeNode.setNodeType(Integer.valueOf(String.valueOf(nodeType)));
|
||||
lawsTreeNode.setCreateTime(new Date());
|
||||
lawsTreeNode.setDelFlag(Integer.parseInt(CommonConstant.DEL_FLAG_0.toString()));
|
||||
this.save(lawsTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTreeNodeDataById(LawsTreeNode lawsTreeNode, String username) {
|
||||
if (lawsTreeNode != null && username != null) {
|
||||
lawsTreeNode.setUpdateTime(new Date());
|
||||
lawsTreeNode.setUpdateBy(username);
|
||||
this.updateById(lawsTreeNode);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id, String nodeCode) {
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
List<String> codeList = new ArrayList<>();
|
||||
codeList.add(nodeCode);
|
||||
this.checkChildrenExists(id, idList);
|
||||
boolean ok = this.removeByIds(idList);
|
||||
// 根据节点code删除标准关联
|
||||
lawsNodeRelationMapper.delete(new LambdaQueryWrapper<LawsNodeRelation>().in(LawsNodeRelation::getNodeId, codeList));
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* delete 方法调用
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @param req
|
||||
* @return
|
||||
* @param id
|
||||
* @param idList
|
||||
*/
|
||||
@Override
|
||||
public List<LawsTreeNode> queryList(LawsTreeNode lawsTreeNode, HttpServletRequest req) {
|
||||
return list(QueryGenerator.initQueryWrapper(lawsTreeNode, req.getParameterMap()));
|
||||
private void checkChildrenExists(String id, List<String> idList) {
|
||||
LambdaQueryWrapper<LawsTreeNode> query = new LambdaQueryWrapper<>();
|
||||
query.eq(LawsTreeNode::getParentId, id);
|
||||
List<LawsTreeNode> departList = this.list(query);
|
||||
if (departList != null && !departList.isEmpty()) {
|
||||
for (LawsTreeNode node : departList) {
|
||||
idList.add(node.getId());
|
||||
this.checkChildrenExists(node.getId(), idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(LawsTreeNode lawsTreeNode) {
|
||||
Date now = new Date();
|
||||
lawsTreeNode.setCreateTime(now);
|
||||
lawsTreeNode.setUpdateTime(now);
|
||||
save(lawsTreeNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsTreeNode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(LawsTreeNode lawsTreeNode) {
|
||||
Date now = new Date();
|
||||
lawsTreeNode.setUpdateTime(now);
|
||||
saveOrUpdate(lawsTreeNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LawsTreeNode queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
// /**
|
||||
// * delete 方法调用
|
||||
// * @param id
|
||||
// * @param codeList
|
||||
// */
|
||||
// private void checkChildrenExists(String id, List<String> codeList) {
|
||||
// LambdaQueryWrapper<LawsTreeNode> query = new LambdaQueryWrapper<>();
|
||||
// query.eq(LawsTreeNode::getParentId, id);
|
||||
// List<LawsTreeNode> nodeList = this.list(query);
|
||||
// if (nodeList != null && !nodeList.isEmpty()) {
|
||||
// for (LawsTreeNode node : nodeList) {
|
||||
// codeList.add(node.getId());
|
||||
// this.checkChildrenExists(node.getNodeCode(), codeList);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user