树形列表显示主表信息和明细信息,后台数据获取:
方法一:
@Override
public IPage<FeeReceivingVO> getPageList(IPage<FeeReceivingVO> page, String condition,Integer feeType,Integer acountsType) {
IPage<FeeReceivingVO> list= baseMapper.getPageList(page ,condition, feeType, acountsType);
for (FeeReceivingVO item : list.getRecords()) {
List<FeeReceivingDetailVO> children = FeeReceivingDetailMapper.geDetailByReceivingId(item.getId());
if(children!=null) {
item.setChildren(children);
}
}
return list;
}
方法二:这样查询结果条数为明细结果条数
方法三:
<!--组合主表和明细表-->
<resultMap id="feeReceivingResult" type="com.canyou.fee.entity.FeeReceivingVO">
<result column="id" property="id" />
<collection property="children" javaType="ArrayList" column="id" ofType="com.canyou.fee.entity.FeeReceivingDetailVO" select="geDetailByReceivingId"/>
</resultMap>
<!--根据条件获取主表信息(需在mapper申明)-->
<select id="getPageList" resultMap="feeReceivingResult">
SELECT * FROM fee_fee_receiving
</select>
<!--根据主表id获取应收明细(需在mapper申明)-->
<select id="geDetailByReceivingId" resultType="com.canyou.fee.entity.FeeReceivingDetailVO">
SELECT *
FROM
fee_fee_receiving_detail AS fd
WHERE fd.is_deleted = 0 AND fd.receiving_id = #{id}
</select>
来源:oschina
链接:https://my.oschina.net/u/2427561/blog/3196965