Commit 308f3ac7 by levphon

用户返回下级全部组织id接口

1 parent 7ad50edd
......@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* feign组织机构服务接口
......@@ -149,6 +150,12 @@ public class FeignOrganizationController implements cn.com.glsx.usercenter.api.f
}
@Override
public R<Set<Long>> getAllSubOrgIds() {
Set<Long> levelDeptList = organizationService.getAllSubOrgIds();
return R.ok().data(levelDeptList);
}
@Override
public R orgTree(@RequestBody FindOrgRequest request) {
OrgTreeSearch search = new OrgTreeSearch();
search.setOrgName(request.getOrgName());
......
......@@ -25,6 +25,7 @@ import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.common.utils.TreeModelUtil;
import com.glsx.plat.exception.SystemMessage;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -33,7 +34,7 @@ import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import static cn.com.glsx.admin.common.constant.UserConstants.RolePermitCastType.getBeanNameByCode;
import static cn.com.glsx.admin.common.constant.UserConstants.RolePermitCastType.*;
/**
* @author: taoyr
......@@ -305,4 +306,30 @@ public class OrganizationService {
return levelOrgList;
}
public Set<Long> getAllSubOrgIds() {
Integer rolePermissionType = ShieldContextHolder.getRolePermissionType();
//租户维度
if (all.getCode().equals(rolePermissionType) || assignTenants.getCode().equals(rolePermissionType)) {
Set<Long> tenantIdList = ShieldContextHolder.getVisibleTenantIds();
List<Department> departmentList = departmentMapper.selectByTenantIds(tenantIdList);
Set<Long> deptIdSet = departmentList.stream().map(Department::getId).collect(Collectors.toSet());
return deptIdSet;
} else if (selfDepartment.getCode().equals(rolePermissionType) || subDepartment.getCode().equals(rolePermissionType)) {
if (subordinate.getCode().equals(rolePermissionType)) {
List<User> userList = userMapper.selectByIds(ShieldContextHolder.getVisibleCreatorIds());
//下级部门
Set<Long> subUserOrgIdList = userList.stream().map(User::getDepartmentId).collect(Collectors.toSet());
//自己部门
subUserOrgIdList.add(ShieldContextHolder.getDepartmentId());
return subUserOrgIdList;
} else {//self
return Sets.newHashSet(ShieldContextHolder.getDepartmentId());
}
}
return Sets.newHashSet();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!