菜单模块

This commit is contained in:
cwchen 2024-02-27 17:45:08 +08:00
parent bf2515f4c7
commit 155819f5d2
4 changed files with 22 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package com.securitycontrol.entity.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -29,6 +30,10 @@ public class TreeNode {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String level;
@ApiModelProperty(value = "是否禁用")
@JsonProperty("isDisabled")
private boolean isDisabled = false;
@ApiModelProperty(value = "子节点")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeNode> children = new ArrayList<>();

View File

@ -2,6 +2,7 @@ package com.securitycontrol.system.base.controller;
import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.entity.system.dto.MenuDto;
import com.securitycontrol.system.base.service.ISelectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@ -37,7 +38,8 @@ public class SelectController extends BaseController {
@ApiOperation(value = "菜单树")
@PostMapping("getMenuTree")
public AjaxResult getMenuTree(){
return service.getMenuTree();
public AjaxResult getMenuTree(MenuDto dto){
return service.getMenuTree(dto);
}
}

View File

@ -1,6 +1,7 @@
package com.securitycontrol.system.base.service;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.entity.system.dto.MenuDto;
/**
* @authorcwchen
@ -22,7 +23,6 @@ public interface ISelectService {
/**
* 角色下拉选
*
* @return AjaxResult
* @description 角色下拉选
* @author cwchen
@ -33,9 +33,10 @@ public interface ISelectService {
/**
* 菜单树
* @return AjaxResult
* @param dto
* @description 菜单树
* @author cwchen
* @date 2024/2/26 13:33
*/
AjaxResult getMenuTree();
AjaxResult getMenuTree(MenuDto dto);
}

View File

@ -2,6 +2,7 @@ package com.securitycontrol.system.base.service.impl;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.entity.system.TreeBuild;
import com.securitycontrol.entity.system.dto.MenuDto;
import com.securitycontrol.entity.system.vo.SelectVo;
import com.securitycontrol.entity.system.vo.TreeNode;
import com.securitycontrol.system.base.mapper.ISelectMapper;
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @authorcwchen
@ -50,12 +52,19 @@ public class SelectServiceImpl implements ISelectService {
}
@Override
public AjaxResult getMenuTree() {
public AjaxResult getMenuTree(MenuDto dto) {
List<TreeNode> groupList = new ArrayList<>();
try {
List<TreeNode> list = mapper.getMenuTree();
if (CollectionUtils.isNotEmpty(list)) {
// 创建树形结构数据集合作为参数
if(dto.getMenuId() != null){
list.forEach(item->{
if(Objects.equals(dto.getMenuId() + "",item.getId())){
item.setDisabled(true);
}
});
}
groupList = TreeBuild.transTreeList(list);
}
} catch (Exception e) {