First, determine the data source
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}
2. Define the data view class
3. Define the mapper interface
4. Write the xml statement
<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>
Five, write server (additional logic can be added) call mapper
Six, control layer call server method
Reference:
https://blog.csdn.net/weixin_34259559/article/details/91848771
https://blog.csdn.net/qq_40588618/article/details/89517692