mirror of https://gitee.com/stylefeng/roses
【system】更新antdv版本组织机构树获取
parent
37438358fa
commit
d6924fc276
|
@ -1,6 +1,13 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.ztree;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractTreeNode;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* jquery ztree 插件的节点封装
|
||||
|
@ -8,11 +15,15 @@ import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
|||
* @author fengshuonan
|
||||
* @date 2021/1/6 21:47
|
||||
*/
|
||||
public class ZTreeNode {
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class ZTreeNode implements AbstractTreeNode {
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -23,23 +34,38 @@ public class ZTreeNode {
|
|||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否打开节点
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean open;
|
||||
|
||||
/**
|
||||
* 是否被选中
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean checked;
|
||||
|
||||
/**
|
||||
* 节点图标 single or group
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private String iconSkin;
|
||||
|
||||
/**
|
||||
* 子节点集合
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private List children;
|
||||
|
||||
/**
|
||||
* 创建ztree的父级节点
|
||||
*
|
||||
|
@ -56,51 +82,27 @@ public class ZTreeNode {
|
|||
return zTreeNode;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
@Override
|
||||
public String getNodeParentId() {
|
||||
return pId.toString();
|
||||
}
|
||||
|
||||
public Long getpId() {
|
||||
return pId;
|
||||
@Override
|
||||
public void setChildrenNodes(List childrenNodes) {
|
||||
this.children = childrenNodes;
|
||||
}
|
||||
|
||||
public void setpId(Long pId) {
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(Boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public String getIconSkin() {
|
||||
return iconSkin;
|
||||
}
|
||||
|
||||
public void setIconSkin(String iconSkin) {
|
||||
this.iconSkin = iconSkin;
|
||||
public Long getpId() {
|
||||
return pId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
// 记录菜单节点
|
||||
menuTreeNodeList.add(menuTree);
|
||||
}
|
||||
|
||||
|
||||
// 返回结果
|
||||
if (lateralFlag) {
|
||||
return menuTreeNodeList;
|
||||
|
|
|
@ -139,7 +139,20 @@ public class HrOrganizationController {
|
|||
*/
|
||||
@GetResource(name = "获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)", path = "/hrOrganization/zTree")
|
||||
public List<ZTreeNode> layuiSelectParentMenuTreeList(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) {
|
||||
return hrOrganizationService.orgZTree(hrOrganizationRequest);
|
||||
return hrOrganizationService.orgZTree(hrOrganizationRequest, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/9 18:37
|
||||
*/
|
||||
@GetResource(name = "获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本)", path = "/hrOrganization/treeWithChildren")
|
||||
public ResponseData treeWithChildren(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) {
|
||||
List<ZTreeNode> zTreeNodes = hrOrganizationService.orgZTree(hrOrganizationRequest, true);
|
||||
return new SuccessResponseData(zTreeNodes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -119,10 +119,11 @@ public interface HrOrganizationService extends IService<HrOrganization> {
|
|||
* 获取ztree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)
|
||||
*
|
||||
* @param hrOrganizationRequest 请求参数
|
||||
* @param buildTree 是否构建成树结构的节点,true-带树结构,false-不带
|
||||
* @return ztree形式的组织机构树
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/9 18:40
|
||||
*/
|
||||
List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest);
|
||||
List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree);
|
||||
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest) {
|
||||
public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree) {
|
||||
|
||||
// 获取角色id
|
||||
Long roleId = hrOrganizationRequest.getRoleId();
|
||||
|
@ -328,7 +328,11 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
}
|
||||
}
|
||||
|
||||
return zTreeNodes;
|
||||
if (buildTree) {
|
||||
return new DefaultTreeBuildFactory<ZTreeNode>().doTreeBuild(zTreeNodes);
|
||||
} else {
|
||||
return zTreeNodes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue