<?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.TestDataMainMapper">

	<sql id="testDataMainColumns">
		a.id AS "id",
		a.user_id AS "user.id",
		a.office_id AS "office.id",
		a.area AS "area",
		a.name AS "name",
		a.sex AS "sex",
		a.file AS "file",
		a.in_date AS "inDate",
		a.tenant_id AS "tenantId",
		a.create_by_id AS "createBy.id",
		a.create_time AS "createTime",
		a.update_by_id AS "updateBy.id",
		a.update_time AS "updateTime",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",

		user.name AS "user.name",

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

	<sql id="testDataMainJoins">

		LEFT JOIN sys_user user ON user.id = a.user_id
		LEFT JOIN sys_office office ON office.id = a.office_id
	</sql>



	<select id="findById" resultType="com.jeeplus.test.onetomany.service.dto.TestDataMainDTO">
		SELECT
			<include refid="testDataMainColumns"/>
		FROM test_data_main a
		<include refid="testDataMainJoins"/>
		WHERE a.id = #{id} and a.del_flag = 0
	</select>

	<select id="findList" resultType="com.jeeplus.test.onetomany.service.dto.TestDataMainDTO" >
		SELECT
			<include refid="testDataMainColumns"/>
		FROM test_data_main a
		<include refid="testDataMainJoins"/>
	    ${ew.customSqlSegment}
	</select>

</mapper>
