优化部门列表树排除条件

pull/327/head
RuoYi 2021-08-30 15:05:33 +08:00
parent 08fc4740d5
commit f68f4824cd
3 changed files with 22 additions and 5 deletions

View File

@ -189,7 +189,7 @@ public class SysDeptController extends BaseController
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
{
SysDept dept = new SysDept();
dept.setDeptId(excludeId);
dept.setExcludeId(excludeId);
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
return ztrees;
}

View File

@ -1,8 +1,11 @@
package com.ruoyi.common.core.domain.entity;
import javax.validation.constraints.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.core.domain.BaseEntity;
/**
@ -47,6 +50,9 @@ public class SysDept extends BaseEntity
/** 父部门名称 */
private String parentName;
/** 排除编号 */
private Long excludeId;
public Long getDeptId()
{
return deptId;
@ -163,6 +169,17 @@ public class SysDept extends BaseEntity
this.parentName = parentName;
}
@JsonIgnore
public Long getExcludeId()
{
return excludeId;
}
public void setExcludeId(Long excludeId)
{
this.excludeId = excludeId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -70,14 +70,14 @@ public class SysDeptServiceImpl implements ISysDeptService
@DataScope(deptAlias = "d")
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
{
Long deptId = dept.getDeptId();
Long excludeId = dept.getExcludeId();
List<SysDept> deptList = deptMapper.selectDeptList(dept);
Iterator<SysDept> it = deptList.iterator();
while (it.hasNext())
{
SysDept d = (SysDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
if (d.getDeptId().intValue() == excludeId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), excludeId + ""))
{
it.remove();
}