以衣服尺码为例
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.benefm.mapper.ProductMapper">
<select id="findAllProduct" resultMap="productMap">
select p.id as id,p.create_time as create_time, p.name as name,p.price as price,p.cover_pic as cover_pic, p.product_pic as product_pic, p.type as type,p1.name as productSizeName ,p1.stock_amount as stock_amount,p1.sales_amount as sales_amount,p1.id as productSizeId,p1.create_time as p_create_time,p1.product_id as product_id from product p left
join product_size p1 on p.id=p1.product_id order by
case when p1.name='M' then 0
when p1.name='L' then 1
when p1.name='XL' then 2
when p1.name='XXL' then 3
when p1.name='XXXL' then 4
when p1.name='XXXXL' then 5
end ASC limit ${(page-1)*pageSize},${pageSize};
</select>
<resultMap id="productMap" type="com.benefm.entity.Product">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="cover_pic" column="cover_pic"/>
<result property="product_pic" column="product_pic"/>
<result property="price" column="price"/>
<result property="create_time" column="create_time"/>
<collection property="productSizeList" ofType="com.benefm.entity.ProductSize">
<result property="id" column="productSizeId"/>
<result property="name" column="productSizeName"/>
<result property="product_id" column="product_id"/>
<result property="stock_amount" column="stock_amount"/>
<result property="sales_amount" column="sales_amount"/>
<result property="create_time" column="p_create_time"/>
</collection>
</resultMap>
</mapper>