<sql id="column">
a.id id,
a.order_id orderId,
a.customer_no customerNo,
a.nums nums,
a.state state,
DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%S') createTime,
a.create_no createNo,
DATE_FORMAT(a.update_time,'%Y-%m-%d %H:%i:%S') updateTime,
a.update_no updateNo,
b.id customerId,
b.customer_name customerName,
b.birthday birthday,
b.sex sex,
b.address address,
b.create_time customerCreateTime,
b.create_no customerCreateNo,
b.update_time customerUpdateTime,
b.update_no customerUpdateNo,
d.id orderDetailId,
d.order_id orderDetailOrderId,
d.goods_id orderDetailGoodsId,
d.price price,
d.is_pay isPay,
d.is_ship isShip,
d.status status,
d.create_time orderDetailCreateTime,
d.create_no orderDetailCreateNo,
d.update_time orderDetailUpdateTime,
d.update_no orderDetailUpdateNo
</sql>
<select id="findOrderInfosUserResultMap" resultMap="orderDetailUserResultMap">
SELECT
<include refid="column"/>
FROM order_info a , customer b, order_detail d WHERE a.customer_no = b.customer_no AND a.order_id = d.order_id
</select>
<resultMap id="orderInfosUserResultMap" type="com.chenfh.mybatis.springbootmybatis.dto.OrdersRelevanceDto">
<!-- Column: 订单信息(order_info)的唯一标识列; property: 订单信息的唯一标识列映射到OrdersRelevanceDto类中的那个属性-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="orderId" jdbcType="INTEGER" property="orderId"/>
<result column="customerNo" jdbcType="INTEGER" property="customerNo"/>
<result column="nums" jdbcType="INTEGER" property="nums"/>
<result column="state" jdbcType="INTEGER" property="state"/>
<result column="createTime" jdbcType="VARCHAR" property="createTime"/>
<result column="createNo" jdbcType="VARCHAR" property="createNo"/>
<result column="updateTime" jdbcType="VARCHAR" property="updateTime"/>
<result column="updateNo" jdbcType="VARCHAR" property="updateNo"/>
<!-- 配置映射相关联的用户信息; association: 用于关联映射关系查询单个对象的信息;
property:要将关联查询的用户信息映射到OrdersRelevanceDto中的那个属性-->
<association property="customerDto" javaType="com.chenfh.mybatis.springbootmybatis.dto.CustomerDto">
<!-- id: 关联查询用户的唯一标识; column: 指定唯一标识用户信息的列; property: 映射到CustomerDto的那个属性 -->
<id column="customerNo" property="customerNo"/>
<result column="customerId" jdbcType="INTEGER" property="id"/>
<result column="customerName" jdbcType="VARCHAR" property="customerName"/>
<result column="birthday" jdbcType="VARCHAR" property="birthday"/>
<result column="sex" jdbcType="CHAR" property="sex"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="customerCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
<result column="customerCreateNo" jdbcType="VARCHAR" property="createNo"/>
<result column="customerUpdateTime" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="customerUpdateNo" jdbcType="VARCHAR" property="updateNo"/>
</association>
</resultMap>
<resultMap id="orderDetailUserResultMap" type="com.chenfh.mybatis.springbootmybatis.dto.OrderDetailRelevanceDto" extends="orderInfosUserResultMap">
<!-- 订单明细信息
一个订单关联查询出了多条明细, 要使用collection进行映射;collection: 对关联查询到多条记录到集合对象中;
ofType: 指定要映射到集合属性中POJO的类型(com.chenfh.mybatis.springbootmybatis.dto.OrderDetailDto)-->
<collection property="orderDetailDtoList" ofType="com.chenfh.mybatis.springbootmybatis.dto.OrderDetailDto">
<id column="orderDetailId" jdbcType="INTEGER" property="id" />
<result column="orderDetailOrderId" jdbcType="INTEGER" property="orderId" />
<result column="orderDetailGoodsId" jdbcType="INTEGER" property="goodsId" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="isPay" jdbcType="INTEGER" property="isPay" />
<result column="isShip" jdbcType="INTEGER" property="isShip" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="orderDetailCreateTime" jdbcType="TIMESTAMP" property="createTime" />
<result column="orderDetailCreateNo" jdbcType="VARCHAR" property="createNo" />
<result column="orderDetailUpdateTime" jdbcType="TIMESTAMP" property="updateTime" />
<result column="orderDetailUpdateNo" jdbcType="VARCHAR" property="updateNo" />
</collection>
</resultMap>