您的位置:首页 > 游戏 > 游戏 > oracle数据回显时候递归实战

oracle数据回显时候递归实战

2024/9/22 3:24:30 来源:https://blog.csdn.net/tellmewhoisi/article/details/139177879  浏览:    关键词:oracle数据回显时候递归实战

太简单的两篇递归循环
orcale 在项目里递归循环实战

先看资产表T_ATOM_ASSET结构
在这里插入图片描述
看业务类别表T_ATOM_BUSI_CATEGORY结构
在这里插入图片描述

问题出现

在这里插入图片描述
页面显示
在这里插入图片描述
实际对应的归属业务分类
在这里插入图片描述

涉及到oracle递归实战(这里不会如何直接在atomAsset的seelct里面处理递归回显)

直接在实现层看atomAssetMapper和atomBusiCategoryMapper处理(这里转来转去数据格式,不知道有啥简单方法不)
impl

    @Overridepublic PageResult<AtomAsset> queryAll(AtomAssetQueryCriteria criteria, Page<Object> page){IPage<AtomAsset> all = atomAssetMapper.findAll(criteria, page);List<AtomAsset> records = all.getRecords();//        根据每条数据类的busiSort递归向下查找归属业务分类if(records.size() > 0 ){for (int i = 0; i < records.size(); i++) {String busiSort = records.get(i).getBusiSort();
//                逗号分隔字符串截取String[] split = busiSort.split(",");
//                string[] 转List<String>再转Set<String>-----为了去重List<String> strings = new ArrayList<>(Arrays.asList(split));Set<String> taskSet  = new LinkedHashSet<>();taskSet.addAll(strings);
//                记录最终对应的分类名字结果Set<String> taskSetResult  = new LinkedHashSet<>();for(String item : taskSet){
//                    根据分类id获取分类名称(递归向下查找)List<String> subCategory = atomBusiCategoryMapper.findSubCategory(Long.parseLong(item));
//                    根据分类id获取当前自己的分类名称String currentCategoryName = atomBusiCategoryMapper.findCategoryNameByCateforyId(Long.parseLong(item));taskSetResult.addAll(subCategory);taskSetResult.add(currentCategoryName);}
//                set又转成List返回前端records.get(i).setBusiSortName(new ArrayList<>(taskSetResult));}}
//        System.out.println(all);return PageUtil.toPage(all);}

直接看AtomBusiCategoryMapper.xml的小小递归写法

    <select id="findSubCategory" resultType="java.lang.String">select distinct category_namefrom T_ATOM_BUSI_CATEGORYstart with superior_id = #{categotyId}connect by prior category_id = superior_id</select><select id="findCategoryNameByCateforyId" resultType="java.lang.String">select category_namefrom T_ATOM_BUSI_CATEGORYwhere category_id = #{categotyId}</select>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com