add 查询树形字典
This commit is contained in:
+53
@@ -3,12 +3,28 @@ package com.jero.modules.system.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.enums.LanguageEnum;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.system.util.TreeUtils;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
@@ -50,6 +66,7 @@ public class SysDictItemController {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询字典内容列表")
|
||||
@GetMapping("/page")
|
||||
public Result<IPage<SysDictItem>> queryPageList(SysDictItem sysDictItem, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
|
||||
@@ -63,6 +80,42 @@ public class SysDictItemController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:查询字典数据树形列表
|
||||
* @param sysDictItem
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询字典内容树形列表")
|
||||
@GetMapping("/treeList")
|
||||
public Result<JSONArray> queryTreeList(SysDictItem sysDictItem,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
|
||||
List<SysDictItem> sysDictItems = sysDictItemService.list(queryWrapper);
|
||||
//配置
|
||||
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
|
||||
// 自定义属性名 都要默认值的
|
||||
treeNodeConfig.setWeightKey("sortOrder");
|
||||
treeNodeConfig.setIdKey("id");
|
||||
// 最大递归深度
|
||||
treeNodeConfig.setDeep(-1);
|
||||
//转换器
|
||||
List<Tree<String>> treeNodes = TreeUtil.build(sysDictItems, "0", treeNodeConfig,
|
||||
(treeNode, tree) -> {
|
||||
tree.setId(treeNode.getId());
|
||||
tree.setParentId(treeNode.getParentId());
|
||||
tree.setWeight(treeNode.getSortOrder());
|
||||
tree.setName(treeNode.getItemText());
|
||||
// 扩展属性 ...
|
||||
Map<String, Object> map = BeanUtil.beanToMap(treeNode);
|
||||
for (String s : map.keySet()) {
|
||||
tree.putExtra(s, map.get(s));
|
||||
}
|
||||
});
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(treeNodes,SerializerFeature.WriteMapNullValue));
|
||||
return Result.OK(jsonArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:新增
|
||||
* @return
|
||||
|
||||
@@ -39,6 +39,10 @@ public class SysDictItem implements Serializable {
|
||||
* 字典id
|
||||
*/
|
||||
private String dictId;
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 字典项文本
|
||||
|
||||
+13
-10
@@ -204,14 +204,16 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
|
||||
/**
|
||||
* 逻辑删除
|
||||
*(0非固定字段 1固定字段 2字段固定,内部可配)
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "标签管理-通过id删除")
|
||||
@ApiOperation(value="标签管理-通过id删除", notes="标签管理-通过id删除")
|
||||
@GetMapping(value = "/logicDelete")
|
||||
@PostMapping(value = "/logicDelete")
|
||||
@RequiresPermissions("tag:logicDelete")
|
||||
public Result<String> logicDelete(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<String> logicDelete(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
String id = map.get("id");
|
||||
Result<String> result = new Result<>();
|
||||
LawsTag lawsTag = lawsTagService.queryById(id);
|
||||
if(StringUtils.isNotBlank(String.valueOf(lawsTag.getIsReadOnly()))) {
|
||||
@@ -230,16 +232,17 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
|
||||
|
||||
/**
|
||||
* 批量逻辑删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "标签管理-批量删除")
|
||||
@ApiOperation(value="标签管理-批量删除", notes="标签管理-批量删除")
|
||||
@GetMapping(value = "/logicDeleteBatch")
|
||||
@PostMapping(value = "/logicDeleteBatch")
|
||||
@RequiresPermissions("tag:logicDeleteBatch")
|
||||
public Result<?> logicDeleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<LawsTag> result = new Result<LawsTag>();
|
||||
public Result<?> logicDeleteBatch(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
String ids = map.get("ids");
|
||||
Result<LawsTag> result = new Result<>();
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
for(String list:idList){
|
||||
LawsTag midTag= lawsTagService.getById(list);
|
||||
|
||||
Reference in New Issue
Block a user