<?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.activiti.mapper.TestActivitiExpenseMapper">

	<sql id="testActivitiExpenseColumns">
		a.id AS "id",
		a.name AS "user.id",
		a.proc_ins_id AS "procInsId",
		a.cost AS "cost",
		a.office_id AS "office.id",
		a.reason AS "reason",
		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",

		user.name AS "user.name",



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

	<sql id="testActivitiExpenseJoins">

		LEFT JOIN sys_user user ON user.id = a.name
		LEFT JOIN sys_office office ON office.id = a.office_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.activiti.service.dto.TestActivitiExpenseDTO">
		SELECT
			<include refid="testActivitiExpenseColumns"/>
		FROM test_activiti_expense a
		<include refid="testActivitiExpenseJoins"/>
		WHERE a.id = #{id} and a.del_flag = 0
	</select>

	<select id="findList" resultType="com.jeeplus.test.activiti.service.dto.TestActivitiExpenseDTO" >
		SELECT
			<include refid="testActivitiExpenseColumns"/>
		FROM test_activiti_expense a
		<include refid="testActivitiExpenseJoins"/>
	    ${ew.customSqlSegment}
	</select>

</mapper>
