<?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.yifu.cloud.plus.v1.yifu.salary.mapper.TAuditRecordMapper">

	<resultMap id="tAuditRecordMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditRecord">
		<id property="id" column="id"/>
		<result property="flowId" column="flow_id"/>
		<result property="domainId" column="domain_id"/>
		<result property="nodeId" column="node_id"/>
		<result property="approvalMan" column="approval_man"/>
		<result property="approvalManName" column="approval_man_name"/>
		<result property="approvalTime" column="approval_time"/>
		<result property="approvalResult" column="approval_result"/>
		<result property="approvalOpinion" column="approval_opinion"/>
		<result property="deleteFlag" column="delete_flag"/>
		<result property="preFlag" column="pre_flag"/>
		<result property="submitMan" column="submit_man"/>
		<result property="submitManName" column="submit_man_name"/>
		<result property="reason" column="reason"/>
		<result property="auditType" column="audit_type"/>
		<result property="createTime" column="create_time"/>
		<result property="nodeName" column="node_name"/>
		<result property="entityName" column="entity_name"/>
		<result property="submitCreateTime" column="submit_create_time"/>
		<result property="backFlag" column="back_flag"/>
		<result property="backNodeName" column="back_node_name"/>
		<result property="backNodeId" column="back_node_id"/>
		<result property="addSignNodeId" column="add_sign_node_id"/>
	</resultMap>
	<sql id="Base_Column_List">
                a.id,
                a.flow_id,
                a.domain_id,
                a.node_id,
                a.approval_man,
                a.approval_man_name,
                a.approval_time,
                a.approval_result,
                a.approval_opinion,
                a.delete_flag,
                a.pre_flag,
                a.submit_man,
                a.submit_man_name,
                a.reason,
                a.audit_type,
                a.create_time,
                a.node_name,
                a.entity_name,
                a.submit_create_time,
                a.back_flag,
                a.back_node_name,
                a.back_node_id,
                a.add_sign_node_id
    </sql>
	<sql id="tAuditRecord_where">
		<if test="tAuditRecord != null">
			<if test="tAuditRecord.id != null and tAuditRecord.id.trim() != ''">
				AND a.id = #{tAuditRecord.id}
			</if>
			<if test="tAuditRecord.flowId != null and tAuditRecord.flowId.trim() != ''">
				AND a.flow_id = #{tAuditRecord.flowId}
			</if>
			<if test="tAuditRecord.domainId != null and tAuditRecord.domainId.trim() != ''">
				AND a.domain_id = #{tAuditRecord.domainId}
			</if>
			<if test="tAuditRecord.nodeId != null and tAuditRecord.nodeId.trim() != ''">
				AND a.node_id = #{tAuditRecord.nodeId}
			</if>
			<if test="tAuditRecord.approvalMan != null and tAuditRecord.approvalMan.trim() != ''">
				AND a.approval_man = #{tAuditRecord.approvalMan}
			</if>
			<if test="tAuditRecord.approvalManName != null and tAuditRecord.approvalManName.trim() != ''">
				AND a.approval_man_name = #{tAuditRecord.approvalManName}
			</if>
			<if test="tAuditRecord.approvalTime != null">
				AND a.approval_time = #{tAuditRecord.approvalTime}
			</if>
			<if test="tAuditRecord.approvalResult != null and tAuditRecord.approvalResult.trim() != ''">
				AND a.approval_result = #{tAuditRecord.approvalResult}
			</if>
			<if test="tAuditRecord.approvalOpinion != null and tAuditRecord.approvalOpinion.trim() != ''">
				AND a.approval_opinion = #{tAuditRecord.approvalOpinion}
			</if>
			<if test="tAuditRecord.deleteFlag != null and tAuditRecord.deleteFlag.trim() != ''">
				AND a.delete_flag = #{tAuditRecord.deleteFlag}
			</if>
			<if test="tAuditRecord.preFlag != null and tAuditRecord.preFlag.trim() != ''">
				AND a.pre_flag = #{tAuditRecord.preFlag}
			</if>
			<if test="tAuditRecord.submitMan != null and tAuditRecord.submitMan.trim() != ''">
				AND a.submit_man = #{tAuditRecord.submitMan}
			</if>
			<if test="tAuditRecord.submitManName != null and tAuditRecord.submitManName.trim() != ''">
				AND a.submit_man_name = #{tAuditRecord.submitManName}
			</if>
			<if test="tAuditRecord.reason != null and tAuditRecord.reason.trim() != ''">
				AND a.reason = #{tAuditRecord.reason}
			</if>
			<if test="tAuditRecord.auditType != null and tAuditRecord.auditType.trim() != ''">
				AND a.audit_type = #{tAuditRecord.auditType}
			</if>
			<if test="tAuditRecord.createTime != null">
				AND a.create_time = #{tAuditRecord.createTime}
			</if>
			<if test="tAuditRecord.nodeName != null and tAuditRecord.nodeName.trim() != ''">
				AND a.node_name = #{tAuditRecord.nodeName}
			</if>
			<if test="tAuditRecord.entityName != null and tAuditRecord.entityName.trim() != ''">
				AND a.entity_name = #{tAuditRecord.entityName}
			</if>
			<if test="tAuditRecord.submitCreateTime != null">
				AND a.submit_create_time = #{tAuditRecord.submitCreateTime}
			</if>
			<if test="tAuditRecord.backFlag != null and tAuditRecord.backFlag.trim() != ''">
				AND a.back_flag = #{tAuditRecord.backFlag}
			</if>
			<if test="tAuditRecord.backNodeName != null and tAuditRecord.backNodeName.trim() != ''">
				AND a.back_node_name = #{tAuditRecord.backNodeName}
			</if>
			<if test="tAuditRecord.backNodeId != null and tAuditRecord.backNodeId.trim() != ''">
				AND a.back_node_id = #{tAuditRecord.backNodeId}
			</if>
			<if test="tAuditRecord.addSignNodeId != null and tAuditRecord.addSignNodeId.trim() != ''">
				AND a.add_sign_node_id = #{tAuditRecord.addSignNodeId}
			</if>
		</if>
	</sql>
	<!--tAuditRecord简单分页查询-->
	<select id="getTAuditRecordPage" resultMap="tAuditRecordMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_audit_record a
		<where>
			1=1
			<include refid="tAuditRecord_where"/>
		</where>
	</select>

	<!--查询审核记录数据-->
	<select id="getAuditRecordList" resultMap="tAuditRecordMap">
		SELECT
		a.id,
		a.flow_id,
		a.domain_id,
		a.node_id,
		a.approval_man,
		a.approval_man_name,
		a.approval_time,
		a.approval_result,
		a.approval_opinion,
		a.submit_man,
		a.submit_man_name,
		a.reason,
		a.create_time,
		a.node_name,
		a.entity_name,
		a.submit_create_time
		FROM t_audit_record a
		<where>
			a.domain_id = #{domainId} AND a.audit_type = #{auditType}
			AND a.delete_flag = '0'
			order by a.create_time,a.id
		</where>
	</select>
</mapper>
