一、确定数据源
select m.id,m.a,m.b,d.main_id,d.aa,d.bb
from table_main as m
left join table_detail as d on m.id=d.main_id
where
m.status_id= 2
and m.x_id = #{x_id}
二、定义数据视图类
三、定义mapper接口
四、编写xml语句
<resultMap id="ResultMap" type="*MainVo">
<result property="*" column="*"/>
<collection property="productsList" column="id"
javaType="ArrayList" ofType="*SubVo">
<result property="productName" column="erp_product_short_name"/>
</collection>
</resultMap>
<select id="select*By*" parameterType="String" resultMap="ResultMap">
select m.id,m.a,m.b,d.main_id,d.aa,d.bb
from table_main as m
left join table_detail as d on m.id=d.main_id
where
m.status_id= 2
and m.x_id = #{x_id}
</select>
五、编写server(可添加其他逻辑)调用mapper
六、control层调用server方法
可参考:
https://blog.youkuaiyun.com/weixin_34259559/article/details/91848771
https://blog.youkuaiyun.com/qq_40588618/article/details/89517692