MapLong Long map = pubDataListTableMapperselectListqueryWrapperstreamcollectCollectorstoMapPubDataListTablegetDataInfo PubDataListTablegetDataId;代码的作用
这段代码的作用是将数据库表pubDataListTable中符合查询条件的记录转换为一个Map对象。其中,queryWrapper是查询条件的封装对象。
具体实现过程如下:
- 调用
pubDataListTableMapper的selectList方法,传入queryWrapper作为参数,获取符合查询条件的记录列表。 - 使用
stream方法将列表转换为一个Stream对象。 - 调用
collect方法,传入Collectors.toMap方法作为参数,将Stream对象中的每个元素转换为Map对象的键值对。 Collectors.toMap方法的第一个参数PubDataListTable::getDataInfo是用于指定键的提取方式,即将PubDataListTable对象的dataInfo属性作为键。Collectors.toMap方法的第二个参数PubDataListTable::getDataId是用于指定值的提取方式,即将PubDataListTable对象的dataId属性作为值。
最终,将根据dataInfo属性作为键,dataId属性作为值,构建一个Map<Long, Long>对象
原文地址: http://www.cveoy.top/t/topic/h9JT 著作权归作者所有。请勿转载和采集!