🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` /** * @author 张跃帅 * @Description: 系统机构类型-工具 * @date 2020/08/12 */ public class SystemOrgTypeUtil { private static final SystemOrgTypeService systemOrgTypeService = SpringUtil.getBean(SystemOrgTypeService.class); /** * 获取-机构类型List */ public static List<SystemOrgTypeEntity> getList() { // 创建查询包装器 LambdaQueryWrapper<SystemOrgTypeEntity> queryWrapper = new LambdaQueryWrapper<>(); // 设置条件 queryWrapper.eq(SystemOrgTypeEntity::getDataFlag, CommonDataFlagEnum.NORMAL.getCode()) .eq(SystemOrgTypeEntity::getDelFlag, CommonDelFlagEnum.NOT_DELETE.getCode()); // 设置排序 queryWrapper.orderByAsc(SystemOrgTypeEntity::getSort); // 返回 return systemOrgTypeService.list(queryWrapper); } /** * 获取-机构类型tree树 */ public static List<Tree<String>> getTree() { // 变量创建ArrayList List<Tree<String>> treeNodeList = CollectionUtil.newArrayList(); // 查询 List<SystemOrgTypeEntity> systemOrgTypeList = SystemOrgTypeUtil.getList(); // 判断 if (systemOrgTypeList != null && systemOrgTypeList.size() > 0) { // 变量-tree父节点id String parentId = CommonTreeParentIdEnum.PARENTID_0.getCode(); // tree转换器 treeNodeList = TreeUtil.build(systemOrgTypeList, parentId, (systemOrgType, tree) -> { // 赋值 tree.setId(Convert.toStr(systemOrgType.getId())); tree.setParentId(parentId); tree.setName(systemOrgType.getName()); // 追加自定义属性 tree.putExtra("code", systemOrgType.getCode()); }); } // 返回 return treeNodeList; } }