<?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.jeeplus.test.onetomany.mapper.TestDataChild21Mapper">

	<sql id="testDataChild21Columns">
		a.id AS "id",
		a.startarea AS "startArea.id",
		a.endarea AS "endArea.id",
		a.starttime AS "starttime",
		a.endtime AS "endtime",
		a.price AS "price",
		a.test_data_main_id AS "testDataMainDTO.id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",

		startArea.name AS "startArea.name",

		endArea.name AS "endArea.name"
	</sql>

	<sql id="testDataChild21Joins">

		LEFT JOIN sys_area startArea ON startArea.id = a.startarea
		LEFT JOIN sys_area endArea ON endArea.id = a.endarea
			LEFT JOIN test_data_main b ON b.id = a.test_data_main_id
	</sql>


	<select id="findById" resultType="com.jeeplus.test.onetomany.service.dto.TestDataChild21DTO">
		SELECT
			<include refid="testDataChild21Columns"/>
		FROM test_data_child1 a
		<include refid="testDataChild21Joins"/>
		WHERE a.id = #{id} and a.del_flag = 0
	</select>

	<select id="findList" resultType="com.jeeplus.test.onetomany.service.dto.TestDataChild21DTO">
		SELECT
			<include refid="testDataChild21Columns"/>
		FROM test_data_child1 a
		<include refid="testDataChild21Joins"/>
		WHERE a.test_data_main_id = #{TestDataMainFormId} and a.del_flag = 0
	</select>

</mapper>
