add 选择框查询字典内容树形列表
This commit is contained in:
+44
-4
@@ -1,10 +1,7 @@
|
||||
package com.jero.modules.system.controller;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -135,6 +132,49 @@ public class SysDictItemController {
|
||||
return Result.OK(jsonArray != null ? jsonArray : new JSONArray());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择框查询字典内容树形列表")
|
||||
@GetMapping("/treeListOption")
|
||||
public Result<JSONArray> treeListOption(SysDictItem sysDictItem,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
|
||||
List<SysDictItem> sysDictItems = sysDictItemService.list(queryWrapper);
|
||||
//当查询结果中有数据的父级不存在时,赋值父级id为"0"
|
||||
List<String> idList = sysDictItems.stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
idList.add("0");
|
||||
//赋值pId
|
||||
sysDictItems.forEach(i ->{
|
||||
String parentId = i.getParentId();
|
||||
if (idList.contains(parentId)) {
|
||||
i.setPId(parentId);
|
||||
}else {
|
||||
i.setPId("0");
|
||||
}
|
||||
});
|
||||
//配置
|
||||
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
|
||||
// 自定义属性名 都要默认值的
|
||||
treeNodeConfig.setWeightKey("sortOrder");
|
||||
treeNodeConfig.setIdKey("id");
|
||||
treeNodeConfig.setParentIdKey("pId");
|
||||
// 最大递归深度
|
||||
treeNodeConfig.setDeep(-1);
|
||||
//转换器
|
||||
List<Tree<String>> treeNodes = TreeUtil.build(sysDictItems, "0", treeNodeConfig,
|
||||
(treeNode, tree) -> {
|
||||
String id = treeNode.getId();
|
||||
tree.setId(id);
|
||||
tree.setParentId(treeNode.getPId());
|
||||
tree.setWeight(treeNode.getSortOrder());
|
||||
tree.setName(treeNode.getItemText());
|
||||
tree.putExtra("key", id);
|
||||
tree.putExtra("value", id);
|
||||
tree.putExtra("title", treeNode.getItemText());
|
||||
});
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(treeNodes,SerializerFeature.WriteMapNullValue));
|
||||
return Result.OK(jsonArray != null ? jsonArray : new JSONArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:新增
|
||||
* @return
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import lombok.experimental.Accessors;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="多选标准弹框查询", description="多选标准弹框查询")
|
||||
public class ManyStandardSelectionBoxVO {
|
||||
@ApiModelProperty(value = "来源(1国内标准、2海外标准、3企业标准)")
|
||||
@ApiModelProperty(value = "来源(1国标、2外标、3企标)")
|
||||
private java.lang.String source;
|
||||
@ApiModelProperty(value = "标准号/标准名称")
|
||||
private java.lang.String standardNumberOrName;
|
||||
|
||||
+4
-4
@@ -47,11 +47,11 @@ public class LawsNodeRelation implements Serializable {
|
||||
@ApiModelProperty(value = "节点code")
|
||||
private java.lang.String nodeCode;
|
||||
/**唯一关联标识(id或者编号)*/
|
||||
@Excel(name = "唯一关联标识(id或者编号)", width = 15)
|
||||
@ApiModelProperty(value = "唯一关联标识(id或者编号)")
|
||||
@Excel(name = "唯一关联标识(编号)", width = 15)
|
||||
@ApiModelProperty(value = "唯一关联标识(编号)")
|
||||
private java.lang.String uniqueRelationFlag;
|
||||
/**所属模块编码*/
|
||||
/**所属模块编码(1国标、2外标、3企标)*/
|
||||
@Excel(name = "所属模块编码", width = 15)
|
||||
@ApiModelProperty(value = "所属模块编码")
|
||||
@ApiModelProperty(value = "所属模块编码(1国标、2外标、3企标)")
|
||||
private java.lang.String moduleCode;
|
||||
}
|
||||
|
||||
+4
-60
@@ -2,9 +2,6 @@ package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 树型节点关联
|
||||
@@ -15,62 +12,9 @@ import java.util.List;
|
||||
public interface ILawsNodeRelationService extends IService<LawsNodeRelation> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
IPage<LawsNodeRelation> queryPage(LawsNodeRelation lawsNodeRelation, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
* @Author: liao
|
||||
* @Date: 2023/9/13 10:52
|
||||
* @Description: 配置标准
|
||||
**/
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<LawsNodeRelation> queryList(LawsNodeRelation lawsNodeRelation, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
void add(LawsNodeRelation lawsNodeRelation);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
void editById(LawsNodeRelation lawsNodeRelation);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LawsNodeRelation queryById(String id);
|
||||
}
|
||||
|
||||
-90
@@ -1,18 +1,12 @@
|
||||
package com.jero.modules.laws.standard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
|
||||
import com.jero.modules.laws.standard.mapper.LawsNodeRelationMapper;
|
||||
import com.jero.modules.laws.standard.service.ILawsNodeRelationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,88 +19,4 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsNodeRelationServiceImpl extends ServiceImpl<LawsNodeRelationMapper, LawsNodeRelation> implements ILawsNodeRelationService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<LawsNodeRelation> queryPage(LawsNodeRelation lawsNodeRelation, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LawsNodeRelation> queryWrapper = QueryGenerator.initQueryWrapper(lawsNodeRelation, req.getParameterMap());
|
||||
Page<LawsNodeRelation> page = new Page<>(pageNo, pageSize);
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<LawsNodeRelation> queryList(LawsNodeRelation lawsNodeRelation, HttpServletRequest req) {
|
||||
return list(QueryGenerator.initQueryWrapper(lawsNodeRelation, req.getParameterMap()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(LawsNodeRelation lawsNodeRelation) {
|
||||
save(lawsNodeRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsNodeRelation
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(LawsNodeRelation lawsNodeRelation) {
|
||||
saveOrUpdate(lawsNodeRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过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 LawsNodeRelation queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user