<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
</sql>
<select id="findOrderInfosUserResultMap" resultMap="orderInfosUserResultMap">
SELECT
<include refid="column"/>,
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
FROM order_info a , customer b WHERE a.customer_no = b.customer_no
</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="order_id" 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>