<?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.one.mapper.TestFormLeaveMapper">

	<sql id="testFormLeaveColumns">
		a.id AS "id",
		a.company_id AS "company.id",
		a.office_id AS "office.id",
		a.user_id AS "user.id",
		a.area_id AS "area.id",
		a.begin_date AS "beginDate",
		a.end_date AS "endDate",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.del_flag AS "delFlag",

		company.name AS "company.name",

		office.name AS "office.name",

		user.name AS "user.name",

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

	<sql id="testFormLeaveJoins">

		LEFT JOIN sys_office company ON company.id = a.company_id
		LEFT JOIN sys_office office ON office.id = a.office_id
		LEFT JOIN sys_user user ON user.id = a.user_id
		LEFT JOIN sys_area area ON area.id = a.area_id
		LEFT JOIN sys_user createBy ON createBy.id = a.create_by
		LEFT JOIN sys_user updateBy ON updateBy.id = a.update_by
	</sql>



	<select id="findById" resultType="com.jeeplus.test.one.service.dto.TestFormLeaveDTO">
		SELECT
			<include refid="testFormLeaveColumns"/>
		FROM test_form_leave a
		<include refid="testFormLeaveJoins"/>
		WHERE a.id = #{id} and a.del_flag = 0
	</select>

	<select id="findList" resultType="com.jeeplus.test.one.service.dto.TestFormLeaveDTO">
		SELECT
			<include refid="testFormLeaveColumns"/>
		FROM test_form_leave a
		<include refid="testFormLeaveJoins"/>
	    ${ew.customSqlSegment}
	</select>

</mapper>
