【更新】机构大数据优化(待完善)

This commit is contained in:
xuyuxiang
2026-02-26 16:56:15 +08:00
parent f00d86aae3
commit 23e4ad1cb0
41 changed files with 156 additions and 292 deletions

View File

@@ -29,8 +29,8 @@ export default {
groupOwnUser(data) {
return request('ownUser', data, 'get')
},
// 获取机构树
groupOrgTreeSelector(data) {
// 获取机构树(懒加载)
groupOrgTreeLazySelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取用户选择器

View File

@@ -32,7 +32,7 @@ export default {
},
// 获取机构树(懒加载)
orgTreeLazy(data) {
return request('treeLazy', data, 'get')
return request('tree', data, 'get')
},
// 提交表单 edit为true时为编辑默认为新增
submitForm(data, edit = false) {
@@ -46,13 +46,9 @@ export default {
orgDetail(data) {
return request('detail', data, 'get')
},
// 获取机构树选择器
orgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取机构树选择器(懒加载)
orgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取人员选择器
orgUserSelector(data) {

View File

@@ -38,13 +38,9 @@ export default {
positionDetail(data) {
return request('detail', data, 'get')
},
// 获取机构树选择器
positionOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取机构树选择器(懒加载)
positionOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取岗位选择器
positionPositionSelector(data) {

View File

@@ -46,13 +46,9 @@ export default {
userResetPassword(data) {
return request('resetPassword', data)
},
// 获取组织选择器
userOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取组织选择器(懒加载)
userOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取职位选择器
userPositionSelector(data) {

View File

@@ -29,8 +29,8 @@ export default {
groupOwnUser(data) {
return request('ownUser', data, 'get')
},
// 获取机构树
groupOrgTreeSelector(data) {
// 获取机构树(懒加载)
groupOrgTreeLazySelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取用户选择器

View File

@@ -28,7 +28,7 @@ export default {
},
// 获取组织树(懒加载)
orgTreeLazy(data) {
return request('treeLazy', data, 'get')
return request('tree', data, 'get')
},
// 提交表单 edit为true时为编辑默认为新增
submitForm(data, edit = false) {
@@ -42,13 +42,9 @@ export default {
orgDetail(data) {
return request('detail', data, 'get')
},
// 获取组织树选择器
orgOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取组织树选择器(懒加载)
orgOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取用户选择器
orgUserSelector(data) {

View File

@@ -38,13 +38,9 @@ export default {
positionDetail(data) {
return request('detail', data, 'get')
},
// 获取组织树选择器
positionOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取组织树选择器(懒加载)
positionOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取职位选择器
positionPositionSelector(data) {

View File

@@ -66,13 +66,9 @@ export default {
roleGrantUser(data) {
return request('grantUser', data)
},
// 获取机构树
roleOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取机构树(懒加载)
roleOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取资源授权树
roleResourceTreeSelector(data) {

View File

@@ -46,13 +46,9 @@ export default {
userResetPassword(data) {
return request('resetPassword', data)
},
// 获取组织选择器
userOrgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取组织选择器(懒加载)
userOrgTreeLazySelector(data) {
return request('orgTreeLazySelector', data, 'get')
return request('orgTreeSelector', data, 'get')
},
// 获取职位选择器
userPositionSelector(data) {

View File

@@ -16,6 +16,7 @@
v-model:expandedKeys="defaultExpandedKeys"
:tree-data="treeData"
:field-names="treeFieldNames"
:load-data="onLoadData"
@select="treeSelect"
>
</a-tree>
@@ -160,7 +161,7 @@
const tableData = ref([])
const selectedData = ref([])
const recordIds = ref()
const props = defineProps(['orgPageApi', 'orgTreeApi', 'radioModel', 'dataIsConverterFlw', 'checkedOrgListApi'])
const props = defineProps(['orgPageApi', 'orgTreeLazyApi', 'radioModel', 'dataIsConverterFlw', 'checkedOrgListApi'])
// 是否是单选
const radioModel = props.radioModel || false
// 数据是否转换成工作流格式
@@ -177,25 +178,19 @@
ids = goDataConverter(ids)
}
recordIds.value = ids
if (props.orgTreeApi) {
// 获取机构树
props.orgTreeApi().then((data) => {
if (props.orgTreeLazyApi) {
// 加载根节点(不传 parentId
props.orgTreeLazyApi().then((data) => {
cardLoading.value = false
if (data !== null) {
treeData.value = data
// 默认展开2级
treeData.value.forEach((item) => {
// 因为0的顶级
if (item.parentId === '0') {
defaultExpandedKeys.value.push(item.id)
// 取到下级ID
if (item.children) {
item.children.forEach((items) => {
defaultExpandedKeys.value.push(items.id)
})
}
}
})
treeData.value = data.map((item) => ({
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}))
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}
})
}
@@ -322,6 +317,23 @@
delete searchFormState.value.searchKey
loadData()
}
// 懒加载子节点
const onLoadData = (treeNode) => {
return new Promise((resolve) => {
if (!props.orgTreeLazyApi || treeNode.dataRef.children || treeNode.dataRef.isLeaf) {
resolve()
return
}
props.orgTreeLazyApi({ parentId: treeNode.dataRef.id }).then((data) => {
treeNode.dataRef.children = data.map((item) => ({
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}))
treeData.value = [...treeData.value]
resolve()
})
})
}
const handleClose = () => {
searchFormState.value = {}
tableRecordNum.value = 0
@@ -330,6 +342,9 @@
pageSize.value = 20
total.value = 0
selectedData.value = []
treeData.value = undefined
defaultExpandedKeys.value = []
cardLoading.value = true
visible.value = false
}

View File

@@ -339,8 +339,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -335,8 +335,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -342,8 +342,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -334,8 +334,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -183,8 +183,8 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return bizGroupApi.groupOrgTreeSelector(param).then((data) => {
orgTreeLazyApi: (param) => {
return bizGroupApi.groupOrgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)
})
},

View File

@@ -192,11 +192,6 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return bizOrgApi.orgTreeSelector(param).then((data) => {
return Promise.resolve(data)
})
},
orgTreeLazyApi: (param) => {
return bizOrgApi.orgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)

View File

@@ -259,7 +259,8 @@
}
})
if (isEmpty(defaultExpandedKeys.value)) {
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -373,8 +373,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
treeDefaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -334,7 +334,8 @@
}
})
if (isEmpty(defaultExpandedKeys.value)) {
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}
@@ -502,11 +503,6 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return bizUserApi.userOrgTreeSelector(param).then((orgTree) => {
return Promise.resolve(orgTree)
})
},
orgTreeLazyApi: (param) => {
return bizUserApi.userOrgTreeLazySelector(param).then((orgTree) => {
return Promise.resolve(orgTree)

View File

@@ -182,8 +182,8 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return sysGroupApi.groupOrgTreeSelector(param).then((data) => {
orgTreeLazyApi: (param) => {
return sysGroupApi.groupOrgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)
})
},

View File

@@ -191,11 +191,6 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return orgApi.orgOrgTreeSelector(param).then((data) => {
return Promise.resolve(data)
})
},
orgTreeLazyApi: (param) => {
return orgApi.orgOrgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)

View File

@@ -256,8 +256,8 @@
}
})
if (isEmpty(defaultExpandedKeys.value)) {
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -318,7 +318,8 @@
})
)
if (isEmpty(defaultExpandedKeys.value)) {
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}
@@ -419,11 +420,6 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return roleApi.roleOrgTreeSelector(param).then((data) => {
return Promise.resolve(data)
})
},
orgTreeLazyApi: (param) => {
return orgApi.orgOrgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)

View File

@@ -373,8 +373,8 @@
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
treeDefaultExpandedKeys.value.push(treeData.value[0].id)
}
}

View File

@@ -350,8 +350,8 @@
}
})
if (isEmpty(defaultExpandedKeys.value)) {
// 默认展开第一级
if (treeData.value.length > 0) {
// 只有一个根节点时才自动展开
if (treeData.value.length === 1) {
defaultExpandedKeys.value.push(treeData.value[0].id)
}
}
@@ -523,8 +523,8 @@
}
// 传递设计器需要的API
const selectorApiFunction = {
orgTreeApi: (param) => {
return userApi.userOrgTreeSelector(param).then((data) => {
orgTreeLazyApi: (param) => {
return userApi.userOrgTreeLazySelector(param).then((data) => {
return Promise.resolve(data)
})
},

View File

@@ -14,6 +14,7 @@ package vip.xiaonuo.biz.modular.group.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.group.entity.BizGroup;
import vip.xiaonuo.biz.modular.group.param.*;
import vip.xiaonuo.biz.modular.group.service.BizGroupService;
import vip.xiaonuo.biz.modular.org.param.BizOrgTreeLazyParam;
import vip.xiaonuo.biz.modular.user.entity.BizUser;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
@@ -142,8 +144,8 @@ public class BizGroupController {
@Operation(summary = "获取组织树选择器")
@SaCheckPermission("/biz/group/orgTreeSelector")
@GetMapping("/biz/group/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(bizGroupService.orgTreeSelector());
public CommonResult<List<JSONObject>> orgTreeSelector(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return CommonResult.data(bizGroupService.orgTreeLazySelector(bizOrgTreeLazyParam));
}
/**

View File

@@ -13,10 +13,12 @@
package vip.xiaonuo.biz.modular.group.service;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vip.xiaonuo.biz.modular.group.entity.BizGroup;
import vip.xiaonuo.biz.modular.group.param.*;
import vip.xiaonuo.biz.modular.org.param.BizOrgTreeLazyParam;
import vip.xiaonuo.biz.modular.user.entity.BizUser;
import java.util.List;
@@ -93,6 +95,14 @@ public interface BizGroupService extends IService<BizGroup> {
*/
List<Tree<String>> orgTreeSelector();
/**
* 获取机构树选择器(懒加载)
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
List<JSONObject> orgTreeLazySelector(BizOrgTreeLazyParam bizOrgTreeLazyParam);
/**
* 获取用户选择器
*

View File

@@ -20,6 +20,7 @@ import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -34,6 +35,7 @@ import vip.xiaonuo.biz.modular.group.mapper.BizGroupMapper;
import vip.xiaonuo.biz.modular.group.param.*;
import vip.xiaonuo.biz.modular.group.service.BizGroupService;
import vip.xiaonuo.biz.modular.org.entity.BizOrg;
import vip.xiaonuo.biz.modular.org.param.BizOrgTreeLazyParam;
import vip.xiaonuo.biz.modular.org.service.BizOrgService;
import vip.xiaonuo.biz.modular.user.entity.BizUser;
import vip.xiaonuo.biz.modular.user.enums.BizUserStatusEnum;
@@ -157,6 +159,11 @@ public class BizGroupServiceImpl extends ServiceImpl<BizGroupMapper, BizGroup> i
return TreeUtil.build(treeNodeList, "0");
}
@Override
public List<JSONObject> orgTreeLazySelector(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return bizOrgService.treeLazy(bizOrgTreeLazyParam);
}
@Override
public Page<BizUser> userSelector(BizGroupSelectorUserParam bizGroupSelectorUserParam) {
QueryWrapper<BizUser> queryWrapper = new QueryWrapper<BizUser>().checkSqlInjection();

View File

@@ -75,8 +75,8 @@ public class BizOrgController {
*/
@ApiOperationSupport(order = 2)
@Operation(summary = "获取机构树(懒加载)")
@SaCheckPermission("/biz/org/treeLazy")
@GetMapping("/biz/org/treeLazy")
@SaCheckPermission("/biz/org/tree")
@GetMapping("/biz/org/tree")
public CommonResult<List<JSONObject>> treeLazy(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return CommonResult.data(bizOrgService.treeLazy(bizOrgTreeLazyParam));
}
@@ -162,20 +162,6 @@ public class BizOrgController {
/* ====机构部分所需要用到的选择器==== */
/**
* 获取机构树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 8)
@Operation(summary = "获取机构树选择器")
@SaCheckPermission("/biz/org/orgTreeSelector")
@GetMapping("/biz/org/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(bizOrgService.orgTreeSelector());
}
/**
* 获取机构树选择器(懒加载)
*
@@ -184,8 +170,8 @@ public class BizOrgController {
*/
@ApiOperationSupport(order = 8)
@Operation(summary = "获取机构树选择器(懒加载)")
@SaCheckPermission("/biz/org/orgTreeLazySelector")
@GetMapping("/biz/org/orgTreeLazySelector")
@SaCheckPermission("/biz/org/orgTreeSelector")
@GetMapping("/biz/org/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return CommonResult.data(bizOrgService.treeLazy(bizOrgTreeLazyParam));
}

View File

@@ -38,22 +38,6 @@ public interface BizOrgService extends IService<BizOrg> {
*/
Page<BizOrg> page(BizOrgPageParam bizOrgPageParam);
/**
* 获取机构树
*
* @author xuyuxiang
* @date 2022/4/24 20:08
*/
List<Tree<String>> tree();
/**
* 获取机构树(带搜索关键字)
*
* @author xuyuxiang
* @date 2022/4/24 20:08
*/
List<Tree<String>> tree(String searchKey);
/**
* 获取机构树(懒加载)
*

View File

@@ -137,54 +137,45 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
if (loginUserDataScope != null && ObjectUtil.isEmpty(loginUserDataScope)) {
return CollectionUtil.newArrayList();
}
// loginUserDataScope == null 时为 SCOPE_ALL不做数据范围过滤
if (loginUserDataScope == null) {
// SCOPE_ALL直接查询当前父级下的所有子机构
List<BizOrg> childList = this.list(new LambdaQueryWrapper<BizOrg>()
.eq(BizOrg::getParentId, parentId)
.orderByAsc(BizOrg::getSortCode));
if (ObjectUtil.isEmpty(childList)) {
// loginUserDataScope == null 时为 SCOPE_ALL不做数据范围过滤否则取可见机构ID集合
Set<String> visibleOrgIds = null;
if (loginUserDataScope != null) {
visibleOrgIds = this.getVisibleOrgIds(loginUserDataScope);
if (ObjectUtil.isEmpty(visibleOrgIds)) {
return CollectionUtil.newArrayList();
}
List<String> childIds = childList.stream().map(BizOrg::getId).collect(Collectors.toList());
Set<String> hasChildrenParentIds = this.list(new LambdaQueryWrapper<BizOrg>()
.select(BizOrg::getParentId)
.in(BizOrg::getParentId, childIds))
.stream().map(BizOrg::getParentId).collect(Collectors.toSet());
return childList.stream().map(bizOrg -> {
JSONObject jsonObject = JSONUtil.parseObj(bizOrg);
jsonObject.set("isLeaf", !hasChildrenParentIds.contains(bizOrg.getId()));
return jsonObject;
}).collect(Collectors.toList());
}
return this.fetchChildrenWithLeafFlag(parentId, visibleOrgIds);
}
// 从版本化缓存获取可见机构ID集合命中时无需加载全量数据
Set<String> visibleOrgIds = this.getVisibleOrgIds(loginUserDataScope);
if (ObjectUtil.isEmpty(visibleOrgIds)) {
return CollectionUtil.newArrayList();
/**
* 查询指定父节点下的直接子机构列表,并为每个子机构设置 isLeaf 标志。
* visibleOrgIds 为 null 时表示 SCOPE_ALL不做数据范围过滤与 SysOrg 行为一致);
* 非 null 时仅返回集合内可见的子机构,且 isLeaf 判断也限制在可见范围内。
*/
private List<JSONObject> fetchChildrenWithLeafFlag(String parentId, Set<String> visibleOrgIds) {
// 查询当前父级下的(可见)子机构
LambdaQueryWrapper<BizOrg> childQuery = new LambdaQueryWrapper<BizOrg>()
.eq(BizOrg::getParentId, parentId)
.orderByAsc(BizOrg::getSortCode)
.orderByAsc(BizOrg::getId);
if (visibleOrgIds != null) {
CommonSqlUtil.safeIn(childQuery, BizOrg::getId, visibleOrgIds);
}
// SQL直查获取当前父级下的可见子机构替代内存过滤2万条记录
LambdaQueryWrapper<BizOrg> childQueryWrapper = new LambdaQueryWrapper<BizOrg>()
.eq(BizOrg::getParentId, parentId);
CommonSqlUtil.safeIn(childQueryWrapper, BizOrg::getId, visibleOrgIds);
childQueryWrapper.orderByAsc(BizOrg::getSortCode);
List<BizOrg> childList = this.list(childQueryWrapper);
List<BizOrg> childList = this.list(childQuery);
if (ObjectUtil.isEmpty(childList)) {
return CollectionUtil.newArrayList();
}
// SQL批量查询判断哪些子机构还有可见的下级单次SQL替代N次遍历
// 批量判断哪些子机构还有(可见的)下级
List<String> childIds = childList.stream().map(BizOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<BizOrg> hasChildrenWrapper = new LambdaQueryWrapper<BizOrg>()
LambdaQueryWrapper<BizOrg> hasChildrenQuery = new LambdaQueryWrapper<BizOrg>()
.select(BizOrg::getParentId)
.in(BizOrg::getParentId, childIds);
CommonSqlUtil.safeIn(hasChildrenWrapper, BizOrg::getId, visibleOrgIds);
Set<String> hasChildrenParentIds = this.list(hasChildrenWrapper)
if (visibleOrgIds != null) {
CommonSqlUtil.safeIn(hasChildrenQuery, BizOrg::getId, visibleOrgIds);
}
Set<String> hasChildrenParentIds = this.list(hasChildrenQuery)
.stream().map(BizOrg::getParentId).collect(Collectors.toSet());
return childList.stream().map(bizOrg -> {
JSONObject jsonObject = JSONUtil.parseObj(bizOrg);
jsonObject.set("isLeaf", !hasChildrenParentIds.contains(bizOrg.getId()));
@@ -192,18 +183,6 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
}).collect(Collectors.toList());
}
/**
* 获取机构树(懒加载)
*
* @author xuyuxiang
* @date 2022/4/24 20:08
*/
public List<JSONObject> treeLazy(String parentId) {
BizOrgTreeLazyParam bizOrgTreeLazyParam = new BizOrgTreeLazyParam();
bizOrgTreeLazyParam.setParentId(parentId);
return this.treeLazy(bizOrgTreeLazyParam);
}
/**
* 全量搜索模式返回嵌套树结构的JSONObject列表
* searchKey为空字符串时返回全量树非空时按关键字过滤

View File

@@ -131,20 +131,6 @@ public class BizPositionController {
/* ====岗位部分所需要用到的选择器==== */
/**
* 获取组织树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 6)
@Operation(summary = "获取组织树选择器")
@SaCheckPermission("/biz/position/orgTreeSelector")
@GetMapping("/biz/position/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(bizPositionService.orgTreeSelector());
}
/**
* 获取组织树选择器(懒加载)
*
@@ -153,8 +139,8 @@ public class BizPositionController {
*/
@ApiOperationSupport(order = 6)
@Operation(summary = "获取组织树选择器(懒加载)")
@SaCheckPermission("/biz/position/orgTreeLazySelector")
@GetMapping("/biz/position/orgTreeLazySelector")
@SaCheckPermission("/biz/position/orgTreeSelector")
@GetMapping("/biz/position/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return CommonResult.data(bizPositionService.orgTreeLazySelector(bizOrgTreeLazyParam));
}

View File

@@ -246,20 +246,6 @@ public class BizUserController {
/* ====人员部分所需要用到的选择器==== */
/**
* 获取机构树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 13)
@Operation(summary = "获取机构树选择器")
@SaCheckPermission("/biz/user/orgTreeSelector")
@GetMapping("/biz/user/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(bizUserService.orgTreeSelector());
}
/**
* 获取机构树选择器(懒加载)
*
@@ -268,8 +254,8 @@ public class BizUserController {
*/
@ApiOperationSupport(order = 13)
@Operation(summary = "获取机构树选择器(懒加载)")
@SaCheckPermission("/biz/user/orgTreeLazySelector")
@GetMapping("/biz/user/orgTreeLazySelector")
@SaCheckPermission("/biz/user/orgTreeSelector")
@GetMapping("/biz/user/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(BizOrgTreeLazyParam bizOrgTreeLazyParam) {
return CommonResult.data(bizUserService.orgTreeLazySelector(bizOrgTreeLazyParam));
}

View File

@@ -12,7 +12,7 @@
*/
package vip.xiaonuo.sys.modular.group.controller;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -29,6 +29,7 @@ import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.sys.modular.group.entity.SysGroup;
import vip.xiaonuo.sys.modular.group.param.*;
import vip.xiaonuo.sys.modular.group.service.SysGroupService;
import vip.xiaonuo.sys.modular.org.param.SysOrgTreeLazyParam;
import vip.xiaonuo.sys.modular.user.entity.SysUser;
import java.util.List;
@@ -134,8 +135,8 @@ public class SysGroupController {
*/
@Operation(summary = "获取组织树选择器")
@GetMapping("/sys/group/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(sysGroupService.orgTreeSelector());
public CommonResult<List<JSONObject>> orgTreeSelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysGroupService.orgTreeLazySelector(sysOrgTreeLazyParam));
}
/**

View File

@@ -13,10 +13,12 @@
package vip.xiaonuo.sys.modular.group.service;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vip.xiaonuo.sys.modular.group.entity.SysGroup;
import vip.xiaonuo.sys.modular.group.param.*;
import vip.xiaonuo.sys.modular.org.param.SysOrgTreeLazyParam;
import vip.xiaonuo.sys.modular.user.entity.SysUser;
import java.util.List;
@@ -93,6 +95,14 @@ public interface SysGroupService extends IService<SysGroup> {
*/
List<Tree<String>> orgTreeSelector();
/**
* 获取组织树选择器(懒加载)
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
List<JSONObject> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam);
/**
* 获取用户选择器
*

View File

@@ -19,6 +19,7 @@ import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -37,6 +38,7 @@ import vip.xiaonuo.sys.modular.group.mapper.SysGroupMapper;
import vip.xiaonuo.sys.modular.group.param.*;
import vip.xiaonuo.sys.modular.group.service.SysGroupService;
import vip.xiaonuo.sys.modular.org.entity.SysOrg;
import vip.xiaonuo.sys.modular.org.param.SysOrgTreeLazyParam;
import vip.xiaonuo.sys.modular.org.service.SysOrgService;
import vip.xiaonuo.sys.modular.position.param.SysPositionIdParam;
import vip.xiaonuo.sys.modular.relation.entity.SysRelation;
@@ -144,6 +146,11 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
return TreeUtil.build(treeNodeList, "0");
}
@Override
public List<JSONObject> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return List.of();
}
@Override
public Page<SysUser> userSelector(SysGroupSelectorUserParam sysGroupSelectorUserParam) {
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().checkSqlInjection();

View File

@@ -73,7 +73,7 @@ public class SysOrgController {
*/
@ApiOperationSupport(order = 2)
@Operation(summary = "获取组织树(懒加载)")
@GetMapping("/sys/org/treeLazy")
@GetMapping("/sys/org/tree")
public CommonResult<List<JSONObject>> treeLazy(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysOrgService.treeLazy(sysOrgTreeLazyParam));
}
@@ -154,19 +154,6 @@ public class SysOrgController {
/* ====组织部分所需要用到的选择器==== */
/**
* 获取组织树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 8)
@Operation(summary = "获取组织树选择器")
@GetMapping("/sys/org/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(sysOrgService.orgTreeSelector());
}
/**
* 获取组织树选择器(懒加载)
*
@@ -175,7 +162,7 @@ public class SysOrgController {
*/
@ApiOperationSupport(order = 8)
@Operation(summary = "获取组织树选择器(懒加载)")
@GetMapping("/sys/org/orgTreeLazySelector")
@GetMapping("/sys/org/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysOrgService.treeLazy(sysOrgTreeLazyParam));
}

View File

@@ -140,18 +140,6 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
}).collect(Collectors.toList());
}
/**
* 获取机构树(懒加载)
*
* @author xuyuxiang
* @date 2022/4/21 16:13
**/
public List<JSONObject> treeLazy(String parentId) {
SysOrgTreeLazyParam sysOrgTreeLazyParam = new SysOrgTreeLazyParam();
sysOrgTreeLazyParam.setParentId(parentId);
return this.treeLazy(sysOrgTreeLazyParam);
}
/**
* 全量搜索模式返回嵌套树结构的JSONObject列表
* searchKey为空字符串时返回全量树非空时按关键字过滤

View File

@@ -125,19 +125,6 @@ public class SysPositionController {
/* ====职位部分所需要用到的选择器==== */
/**
* 获取组织树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 6)
@Operation(summary = "获取组织树选择器")
@GetMapping("/sys/position/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(sysPositionService.orgTreeSelector());
}
/**
* 获取组织树选择器(懒加载)
*
@@ -146,7 +133,7 @@ public class SysPositionController {
*/
@ApiOperationSupport(order = 6)
@Operation(summary = "获取组织树选择器(懒加载)")
@GetMapping("/sys/position/orgTreeLazySelector")
@GetMapping("/sys/position/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysPositionService.orgTreeLazySelector(sysOrgTreeLazyParam));
}

View File

@@ -240,19 +240,6 @@ public class SysRoleController {
/* ====角色部分所需要用到的选择器==== */
/**
* 获取组织树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 14)
@Operation(summary = "获取组织树选择器")
@GetMapping("/sys/role/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(sysRoleService.orgTreeSelector());
}
/**
* 获取组织树选择器(懒加载)
*
@@ -261,7 +248,7 @@ public class SysRoleController {
*/
@ApiOperationSupport(order = 15)
@Operation(summary = "获取组织树选择器(懒加载)")
@GetMapping("/sys/role/orgTreeLazySelector")
@GetMapping("/sys/role/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysRoleService.orgTreeLazySelector(sysOrgTreeLazyParam));
}

View File

@@ -317,19 +317,6 @@ public class SysUserController {
/* ====用户部分所需要用到的选择器==== */
/**
* 获取组织树选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 19)
@Operation(summary = "获取组织树选择器")
@GetMapping("/sys/user/orgTreeSelector")
public CommonResult<List<Tree<String>>> orgTreeSelector() {
return CommonResult.data(sysUserService.orgTreeSelector());
}
/**
* 获取组织树选择器(懒加载)
*
@@ -338,7 +325,7 @@ public class SysUserController {
*/
@ApiOperationSupport(order = 19)
@Operation(summary = "获取组织树选择器(懒加载)")
@GetMapping("/sys/user/orgTreeLazySelector")
@GetMapping("/sys/user/orgTreeSelector")
public CommonResult<List<JSONObject>> orgTreeLazySelector(SysOrgTreeLazyParam sysOrgTreeLazyParam) {
return CommonResult.data(sysUserService.orgTreeLazySelector(sysOrgTreeLazyParam));
}