<?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.hzya.frame.sys.proofLog.dao.impl.ProofLogDaoImpl">
	<resultMap id="get-ProofLogEntity-result" type="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		<!--主键ID -->
		<result property="id" column="id" />
		<!--原数据 -->
		<result property="raw_data" column="raw_data" />
		<!--凭证数据 -->
		<result property="proof_data" column="proof_data" />
		<!--排序 -->
		<result property="sorts" column="sorts" />
		<!--创建人id -->
		<result property="create_user_id" column="create_user_id" />
		<!--创建时间 -->
		<result property="create_time" column="create_time" />
		<!--修改人id -->
		<result property="modify_user_id" column="modify_user_id" />
		<!--修改时间 -->
		<result property="modify_time" column="modify_time" />
		<!--状态(Y正常N删除) -->
		<result property="sts" column="sts" />
		<!--组织机构ID -->
		<result property="org_id" column="org_id" />
	</resultMap>

	<sql id="ProofLogEntity_Base_Column_List">
		id,
		raw_data,
		proof_data,
		sorts,
		create_user_id,
		create_time,
		modify_user_id,
		modify_time,
		sts,
		org_id
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-ProofLogEntity-result">
		select
		<include refid="ProofLogEntity_Base_Column_List" />
		from sys_proof_log where id = #{ id } and sts='Y'
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-ProofLogEntity-result" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		select
		<include refid="ProofLogEntity_Base_Column_List" />
		from sys_proof_log
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="raw_data != null and raw_data !='' "> and raw_data = #{raw_data}</if>
			<if test="proof_data != null and proof_data !='' "> and proof_data = #{proof_data}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
			and sts='Y'
		</trim>
		<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		select count(1) from sys_proof_log
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="raw_data != null and raw_data !='' "> and raw_data = #{raw_data} </if>
			<if test="proof_data != null and proof_data !='' "> and proof_data = #{proof_data} </if>
			<if test="sorts != null "> and sorts = #{sorts}  </if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id} </if>
			<if test="create_time != null "> and create_time = #{create_time}  </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null "> and modify_time = #{modify_time}  </if>
			<if test="sts != null and sts !='' "> and sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id} </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
	</select>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-ProofLogEntity-result" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		select
		<include refid="ProofLogEntity_Base_Column_List" />
		from sys_proof_log
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="raw_data != null and raw_data !='' "> and raw_data like concat('%',#{raw_data},'%') </if>
			<if test="proof_data != null and proof_data !='' "> and proof_data like concat('%',#{proof_data},'%') </if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id like concat('%',#{create_user_id},'%') </if>
			<if test="create_time != null and create_time !='' "> and create_time like concat('%',#{create_time},'%') </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
			<if test="modify_time != null and modify_time !='' "> and modify_time like concat('%',#{modify_time},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </if>
			<if test="org_id != null and org_id !='' "> and org_id like concat('%',#{org_id},'%') </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-ProofLogEntity-result" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		select
		<include refid="ProofLogEntity_Base_Column_List" />
		from sys_proof_log
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="raw_data != null and raw_data !='' "> or raw_data = #{raw_data} </if>
			<if test="proof_data != null and proof_data !='' "> or proof_data = #{proof_data} </if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> or create_user_id = #{create_user_id} </if>
			<if test="create_time != null and create_time !='' "> or create_time = #{create_time} </if>
			<if test="modify_user_id != null and modify_user_id !='' "> or modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null and modify_time !='' "> or modify_time = #{modify_time} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> or org_id = #{org_id} </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		insert into sys_proof_log(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="raw_data != null and raw_data !='' "> raw_data, </if>
			<if test="proof_data != null and proof_data !='' "> proof_data, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id, </if>
			<if test="org_id != null and org_id !='' "> org_id, </if>
			create_time,
			modify_time,
			sts
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="raw_data != null and raw_data !='' "> #{raw_data}, </if>
			<if test="proof_data != null and proof_data !='' "> #{proof_data}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="create_user_id != null and create_user_id !='' "> #{create_user_id}, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> #{modify_user_id}, </if>
			<if test="org_id != null and org_id !='' "> #{org_id}, </if>
			<if test="create_time != null "> #{create_time} ,</if>
			<if test="modify_time != null "> #{modify_time},</if>
			'Y'
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		update sys_proof_log set
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id = #{id},</if>
			<if test="raw_data != null and raw_data !='' "> raw_data = #{raw_data},</if>
			<if test="proof_data != null and proof_data !='' "> proof_data = #{proof_data},</if>
			<if test="sorts != null ">sorts = #{sorts},</if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id = #{create_user_id},</if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id = #{modify_user_id},</if>
			<if test="org_id != null and org_id !='' "> org_id = #{org_id},</if>
			<if test="modify_time != null "> modify_time =#{modify_time}  </if>
			<if test="modify_time  == null "> modify_time = now()</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 逻辑删除 -->
	<update id="entity_logicDelete" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		update sys_proof_log set
		sts='N',modify_time = now(),modify_user_id = #{modify_user_id} where
		id = #{id}
	</update>

	<!-- 逻辑删除多条件 -->
	<update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		update sys_proof_log set
		sts='N',modify_time = now(),modify_user_id = #{modify_user_id} 
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="raw_data != null and raw_data !='' "> and raw_data = #{raw_data}</if>
			<if test="proof_data != null and proof_data !='' "> and proof_data = #{proof_data}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null and create_time !='' "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null and modify_time !='' "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
		</trim>
	</update>

	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.proofLog.entity.ProofLogEntity">
		delete from sys_proof_log where id =#{id}
	</delete>
</mapper>
