<?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.modules.sg.audit.record.mapper.RecordMapper">

    <sql id="recordColumns">
		a.id,
		a.information,
		a.material,
		a.importUser,
		a.importDate
	</sql>

	<select id="get" resultType="Record" >
		SELECT
		<include refid="recordColumns"/>
		FROM sj_project_record a
		WHERE a.id = #{id}
	</select>

	<select id="findList" resultType="Record" >
		SELECT
		<include refid="recordColumns"/>
		FROM sj_project_record a
		left join sys_user b on a.create_by = b.id left join sys_office t on b.office_id = t.id
		<where>
			1=1
			<if test="dataScope != null and dataScope != ''">
				${dataScope}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>

	<select id="findAllList" resultType="Record" >
		SELECT
		<include refid="recordColumns"/>
		FROM sj_project_record a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			${dataScope}
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>

	<insert id="insert">
		insert into sj_project_record (
			id,
			information,
			material,
			importUser,
			importDate,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag
		)values(
			#{id},
			'完成',
			'完成',
			#{createBy.name},
			#{createDate},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{delFlag}
		)
	</insert>
</mapper>