<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
		"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="com.house365.beans.entity.EvaluateUserCustomerLogEntity">
	<typeAlias alias="evaluateUserCustomerLogEntity"
			   type="com.house365.beans.entity.EvaluateUserCustomerLogEntity"/>
	<resultMap id="evaluateUserCustomerLog"
			   class="com.house365.beans.entity.EvaluateUserCustomerLogEntity">
		<result property="id" column="id"/>
		<result property="userId" column="user_id"/>
		<result property="userName" column="user_name"/>
		<result property="projectId" column="project_id"/>
		<result property="projectName" column="project_name"/>
		<result property="customerName" column="customer_name"/>
		<result property="score" column="score"/>
		<result property="contentTags" column="contentTags"/>
		<result property="content" column="content"/>
		<result property="isDeleted" column="is_deleted"/>
		<result property="isEvaluated" column="is_evaluated"/>
		<result property="checkStatus" column="check_status"/>
		<result property="createTime" column="create_time"/>
		<result property="evaluateTime" column="evaluate_time"/>
		<result property="checkTime" column="check_time"/>
		<result property="checkMan" column="check_man"/>
		<result property="city" column="city"/>
		<result property="channel" column="channel"/>
	</resultMap>

	<!-- 用于select查询公用抽取的列 -->
	<sql id="evaluateUserCustomerLog.columns">
	    <![CDATA[
        a.id, a.user_id, a.user_name, a.project_id, a.project_name, a.customer_name, a.score, a.content,a.contentTags,
        a.is_deleted, a.is_evaluated, a.check_status, a.create_time, a.evaluate_time, a.check_time, a.check_man,
        a.city, a.channel
	    ]]>
	</sql>

	<!-- 新增记录 -->
	<insert id="save" parameterClass="evaluateUserCustomerLogEntity">
		<![CDATA[
	        INSERT INTO evaluate_user_customer_log (
	        	id, 
	        	user_id, 
	        	user_name, 
	        	project_id, 
	        	project_name, 
	        	customer_name, 
	        	score, 
	        	content, 
	        	is_deleted, 
	        	is_evaluated, 
	        	check_status, 
	        	create_time, 
	        	evaluate_time, 
	        	check_time, 
	        	check_man, 
	        	city, 
	        	channel
	        ) VALUES (
	        	#id#, 
	        	#userId#, 
	        	#userName#, 
	        	#projectId#, 
	        	#projectName#, 
	        	#customerName#, 
	        	#score#, 
	        	#content#, 
	        	#isDeleted#, 
	        	#isEvaluated#, 
	        	#checkStatus#, 
	        	#createTime#, 
	        	#evaluateTime#, 
	        	#checkTime#, 
	        	#checkMan#, 
	        	#city#, 
	        	#channel#
	        )
	    ]]>
		<selectKey resultClass="java.lang.Integer" type="post"
				   keyProperty="id">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<!-- 通过ID修改 -->
	<update id="update" parameterClass="evaluateUserCustomerLogEntity">
	    <![CDATA[
	        UPDATE evaluate_user_customer_log SET
		        user_id = #userId#, 
		        user_name = #userName#, 
		        project_id = #projectId#, 
		        project_name = #projectName#, 
		        customer_name = #customerName#, 
		        score = #score#, 
		        content = #content#,
		        contentTags = #contentTags#,
		        is_deleted = #isDeleted#, 
		        is_evaluated = #isEvaluated#, 
		        check_status = #checkStatus#, 
		        create_time = #createTime#, 
		        evaluate_time = #evaluateTime#, 
		        check_time = #checkTime#, 
		        check_man = #checkMan#, 
		        city = #city#, 
		        channel = #channel#
	        WHERE 
		        id = #id#
	    ]]>
	</update>

	<!-- 通过ID删除 -->
	<delete id="delete">
	    <![CDATA[
	        DELETE FROM evaluate_user_customer_log WHERE
	        id = #id#
	    ]]>
	</delete>

	<!-- 通过ID列表批量删除 -->
	<delete id="deleteByIds" parameterClass="java.lang.String">
	    <![CDATA[
	        DELETE FROM evaluate_user_customer_log WHERE
	        id IN ($ids$)
	    ]]>
	</delete>

	<!-- 通过ID查询 -->
	<select id="getById" resultMap="evaluateUserCustomerLog">
		SELECT
		<include refid="evaluateUserCustomerLog.columns"/>
		<![CDATA[
	        FROM evaluate_user_customer_log a
	        WHERE 
		        a.id = #id#
	    ]]>
	</select>

	<!-- 用于分页查询抽取的公共的条件 -->
	<sql id="evaluateUserCustomerLog.queryPage">
		<dynamic prepend="WHERE">
			<!-- 默认不开启实体作为条件 -->
			<!-- 
		    <isNotNull property="entity">
				<isNotEmpty prepend="AND" property="entity.id">
		            <![CDATA[
					id = #entity.id#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.userId">
		            <![CDATA[
					user_id = #entity.userId#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.userName">
		            <![CDATA[
					user_name = #entity.userName#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.projectId">
		            <![CDATA[
					project_id = #entity.projectId#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.projectName">
		            <![CDATA[
					project_name = #entity.projectName#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.customerName">
		            <![CDATA[
					customer_name = #entity.customerName#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.score">
		            <![CDATA[
					score = #entity.score#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.content">
		            <![CDATA[
					content = #entity.content#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.isDeleted">
		            <![CDATA[
					is_deleted = #entity.isDeleted#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.isEvaluated">
		            <![CDATA[
					is_evaluated = #entity.isEvaluated#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.checkStatus">
		            <![CDATA[
					check_status = #entity.checkStatus#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.createTime">
		            <![CDATA[
					create_time = #entity.createTime#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.evaluateTime">
		            <![CDATA[
					evaluate_time = #entity.evaluateTime#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.checkTime">
		            <![CDATA[
					check_time = #entity.checkTime#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.checkMan">
		            <![CDATA[
					check_man = #entity.checkMan#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.city">
		            <![CDATA[
					city = #entity.city#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.channel">
		            <![CDATA[
					channel = #entity.channel#
		            ]]>
				</isNotEmpty>
			</isNotNull>
			 -->
			<isNotNull property="searchFilters">
				<isNotEmpty prepend="AND" property="searchFilters.id">
					<![CDATA[
					a.id $searchFilters.id.operation$ #searchFilters.id.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.userId">
					<![CDATA[
					a.user_id $searchFilters.userId.operation$ #searchFilters.userId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.userName">
					<![CDATA[
					a.user_name $searchFilters.userName.operation$ #searchFilters.userName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.projectId">
					<![CDATA[
					a.project_id $searchFilters.projectId.operation$ #searchFilters.projectId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.projectName">
					<![CDATA[
					a.project_name $searchFilters.projectName.operation$ #searchFilters.projectName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.customerName">
					<![CDATA[
					a.customer_name $searchFilters.customerName.operation$ #searchFilters.customerName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.score">
					<![CDATA[
					a.score $searchFilters.score.operation$ #searchFilters.score.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.content">
					<![CDATA[
					a.content $searchFilters.content.operation$ #searchFilters.content.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isDeleted">
					<![CDATA[
					a.is_deleted $searchFilters.isDeleted.operation$ #searchFilters.isDeleted.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isEvaluated">
					<![CDATA[
					a.is_evaluated $searchFilters.isEvaluated.operation$ #searchFilters.isEvaluated.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.checkStatus">
					<![CDATA[
					a.check_status $searchFilters.checkStatus.operation$ #searchFilters.checkStatus.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.createTime">
					<![CDATA[
					a.create_time $searchFilters.createTime.operation$ #searchFilters.createTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.evaluateTime">
					<![CDATA[
					a.evaluate_time $searchFilters.evaluateTime.operation$ #searchFilters.evaluateTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.evaluateTimeStart">
					<![CDATA[
					a.evaluate_time >= #searchFilters.evaluateTimeStart.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.evaluateTimeEnd">
					<![CDATA[
					a.evaluate_time <= #searchFilters.evaluateTimeEnd.value#
		            ]]>
				</isNotEmpty>


				<isNotEmpty prepend="AND" property="searchFilters.checkTime">
					<![CDATA[
					a.check_time $searchFilters.checkTime.operation$ #searchFilters.checkTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.checkMan">
					<![CDATA[
					a.check_man $searchFilters.checkMan.operation$ #searchFilters.checkMan.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.city">
					<![CDATA[
					a.city $searchFilters.city.operation$ #searchFilters.city.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.channel">
					<![CDATA[
					a.channel $searchFilters.channel.operation$ #searchFilters.channel.value#
		            ]]>
				</isNotEmpty>
			</isNotNull>
		</dynamic>
		<dynamic prepend="ORDER BY">
			<isNotNull property="orderColumn">
				<![CDATA[
				$orderColumn$
				]]>
				<isNotNull property="orderMode">
					$orderMode$
				</isNotNull>
			</isNotNull>
		</dynamic>
	</sql>

	<!-- 为分页查询符合条件的记录数 -->
	<select id="queryByPage_count" resultClass="int">
		SELECT count(*) FROM evaluate_user_customer_log a join user b on a.user_id=b.id and b.enabled=1
		<include refid="evaluateUserCustomerLog.queryPage"/>
	</select>

	<!-- 分页查询指定页记录 -->
	<select id="queryByPage" resultMap="evaluateUserCustomerLog">
		SELECT
		<include refid="evaluateUserCustomerLog.columns"/>
		<![CDATA[
	        FROM evaluate_user_customer_log  a join user b on a.user_id=b.id and b.enabled=1
	    ]]>
		<include refid="evaluateUserCustomerLog.queryPage"/>
		<![CDATA[
		    LIMIT #paging.startRecord#, #paging.pageSize#
        ]]>
	</select>

	<!-- 查询所有记录 -->
	<select id="queryAll" resultMap="evaluateUserCustomerLog">
		SELECT
		<include refid="evaluateUserCustomerLog.columns"/>
		<![CDATA[
		    FROM evaluate_user_customer_log a join user b on a.user_id=b.id and b.enabled=1
	    ]]>
		<include refid="evaluateUserCustomerLog.queryPage"/>
	</select>
</sqlMap>
