mirror of https://gitee.com/y_project/RuoYi.git
优化部门列表树排除条件
parent
08fc4740d5
commit
f68f4824cd
|
@ -189,7 +189,7 @@ public class SysDeptController extends BaseController
|
||||||
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
|
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
|
||||||
{
|
{
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
dept.setDeptId(excludeId);
|
dept.setExcludeId(excludeId);
|
||||||
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
|
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.ruoyi.common.core.domain.entity;
|
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.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +50,9 @@ public class SysDept extends BaseEntity
|
||||||
/** 父部门名称 */
|
/** 父部门名称 */
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
|
/** 排除编号 */
|
||||||
|
private Long excludeId;
|
||||||
|
|
||||||
public Long getDeptId()
|
public Long getDeptId()
|
||||||
{
|
{
|
||||||
return deptId;
|
return deptId;
|
||||||
|
@ -163,6 +169,17 @@ public class SysDept extends BaseEntity
|
||||||
this.parentName = parentName;
|
this.parentName = parentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getExcludeId()
|
||||||
|
{
|
||||||
|
return excludeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludeId(Long excludeId)
|
||||||
|
{
|
||||||
|
this.excludeId = excludeId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
@ -70,14 +70,14 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
@DataScope(deptAlias = "d")
|
@DataScope(deptAlias = "d")
|
||||||
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
|
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
|
||||||
{
|
{
|
||||||
Long deptId = dept.getDeptId();
|
Long excludeId = dept.getExcludeId();
|
||||||
List<SysDept> deptList = deptMapper.selectDeptList(dept);
|
List<SysDept> deptList = deptMapper.selectDeptList(dept);
|
||||||
Iterator<SysDept> it = deptList.iterator();
|
Iterator<SysDept> it = deptList.iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
SysDept d = (SysDept) it.next();
|
SysDept d = (SysDept) it.next();
|
||||||
if (d.getDeptId().intValue() == deptId
|
if (d.getDeptId().intValue() == excludeId
|
||||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), excludeId + ""))
|
||||||
{
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue