mirror of
https://gitee.com/xiaonuobase/snowy
synced 2025-12-16 11:13:59 +08:00
【新增】底座新增几个插件需要的API方法
This commit is contained in:
@@ -57,4 +57,20 @@ public interface SysOrgApi {
|
||||
* @date 2022/7/22 14:45
|
||||
**/
|
||||
Page<JSONObject> orgListSelector(String parentId);
|
||||
|
||||
/**
|
||||
* 获取某组织的所有父级id集合
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2025/5/10 12:13
|
||||
*/
|
||||
List<String> getParentIdListByOrgId(String orgId);
|
||||
|
||||
/**
|
||||
* 根据组织id获取组织列表
|
||||
*
|
||||
* @author wangshuo
|
||||
* @date 2025/01/10 14:45
|
||||
**/
|
||||
List<JSONObject> getOrgListByIdListWithoutException(List<String> orgIdList);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,6 +26,7 @@ import vip.xiaonuo.sys.modular.org.param.SysOrgSelectorOrgListParam;
|
||||
import vip.xiaonuo.sys.modular.org.service.SysOrgService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组织API接口提供者
|
||||
@@ -64,4 +66,14 @@ public class SysOrgApiProvider implements SysOrgApi {
|
||||
sysOrgSelectorOrgListParam.setParentId(parentId);
|
||||
return BeanUtil.toBean(sysOrgService.orgListSelector(sysOrgSelectorOrgListParam), Page.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParentIdListByOrgId(String orgId) {
|
||||
return sysOrgService.getParentIdListByOrgId(orgId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getOrgListByIdListWithoutException(List<String> orgIdList) {
|
||||
return sysOrgService.listByIds(orgIdList).stream().map(JSONUtil::parseObj).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,4 +172,12 @@ public interface SysOrgService extends IService<SysOrg> {
|
||||
* @date 2022/4/24 20:08
|
||||
*/
|
||||
Page<SysUser> userSelector(SysOrgSelectorUserParam sysOrgSelectorUserParam);
|
||||
|
||||
/**
|
||||
* 获取某组织的所有父级id集合
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2025/5/10 12:13
|
||||
*/
|
||||
List<String> getParentIdListByOrgId(String orgId);
|
||||
}
|
||||
|
||||
@@ -331,6 +331,25 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParentIdListByOrgId(String orgId) {
|
||||
List<SysOrg> sysOrgList = this.getAllOrgList();
|
||||
List<String> resultList = CollectionUtil.newArrayList();
|
||||
if(ObjectUtil.isNotEmpty(sysOrgList)) {
|
||||
execRecursionFindParentByList(orgId, sysOrgList, resultList);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private List<String> execRecursionFindParentByList(String id, List<SysOrg> list,List<String> resultList) {
|
||||
SysOrg parentById = list.stream().filter(sysOrg -> sysOrg.getId().equals(id)).findFirst().orElse(null);
|
||||
if(ObjectUtil.isNotEmpty(parentById)) {
|
||||
resultList.add(parentById.getParentId());
|
||||
execRecursionFindParentByList(parentById.getParentId(), list, resultList);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/* ====以下为各种递归方法==== */
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user