【system】更新antdv版本组织机构树获取

pull/3/head
fengshuonan 2021-01-11 21:10:01 +08:00
parent 37438358fa
commit d6924fc276
5 changed files with 62 additions and 42 deletions

View File

@ -1,6 +1,13 @@
package cn.stylefeng.roses.kernel.system.pojo.ztree; 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 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 * jquery ztree
@ -8,11 +15,15 @@ import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
* @author fengshuonan * @author fengshuonan
* @date 2021/1/6 21:47 * @date 2021/1/6 21:47
*/ */
public class ZTreeNode { @ToString
@EqualsAndHashCode
public class ZTreeNode implements AbstractTreeNode {
/** /**
* id * id
*/ */
@Getter
@Setter
private Long id; private Long id;
/** /**
@ -23,23 +34,38 @@ public class ZTreeNode {
/** /**
* *
*/ */
@Getter
@Setter
private String name; private String name;
/** /**
* *
*/ */
@Getter
@Setter
private Boolean open; private Boolean open;
/** /**
* *
*/ */
@Getter
@Setter
private Boolean checked; private Boolean checked;
/** /**
* single or group * single or group
*/ */
@Getter
@Setter
private String iconSkin; private String iconSkin;
/**
*
*/
@Getter
@Setter
private List children;
/** /**
* ztree * ztree
* *
@ -56,51 +82,27 @@ public class ZTreeNode {
return zTreeNode; return zTreeNode;
} }
public Long getId() {
return id; @Override
public String getNodeId() {
return id.toString();
} }
public void setId(Long id) { @Override
this.id = id; public String getNodeParentId() {
return pId.toString();
} }
public Long getpId() { @Override
return pId; public void setChildrenNodes(List childrenNodes) {
this.children = childrenNodes;
} }
public void setpId(Long pId) { public void setpId(Long pId) {
this.pId = pId; this.pId = pId;
} }
public String getName() { public Long getpId() {
return name; return pId;
}
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;
} }
} }

View File

@ -425,7 +425,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
// 记录菜单节点 // 记录菜单节点
menuTreeNodeList.add(menuTree); menuTreeNodeList.add(menuTree);
} }
// 返回结果 // 返回结果
if (lateralFlag) { if (lateralFlag) {
return menuTreeNodeList; return menuTreeNodeList;

View File

@ -139,7 +139,20 @@ public class HrOrganizationController {
*/ */
@GetResource(name = "获取zTree形式的组织机构树用于角色配置数据范围类型并且数据范围类型是指定组织机构时layui版本", path = "/hrOrganization/zTree") @GetResource(name = "获取zTree形式的组织机构树用于角色配置数据范围类型并且数据范围类型是指定组织机构时layui版本", path = "/hrOrganization/zTree")
public List<ZTreeNode> layuiSelectParentMenuTreeList(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) { public List<ZTreeNode> layuiSelectParentMenuTreeList(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) {
return hrOrganizationService.orgZTree(hrOrganizationRequest); return hrOrganizationService.orgZTree(hrOrganizationRequest, false);
} }
/**
* zTreeantd 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);
}
} }

View File

@ -119,10 +119,11 @@ public interface HrOrganizationService extends IService<HrOrganization> {
* ztreelayui * ztreelayui
* *
* @param hrOrganizationRequest * @param hrOrganizationRequest
* @param buildTree true-false-
* @return ztree * @return ztree
* @author fengshuonan * @author fengshuonan
* @date 2021/1/9 18:40 * @date 2021/1/9 18:40
*/ */
List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest); List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree);
} }

View File

@ -308,7 +308,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
} }
@Override @Override
public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest) { public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree) {
// 获取角色id // 获取角色id
Long roleId = hrOrganizationRequest.getRoleId(); 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;
}
} }
/** /**