<?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.insurances.mapper.insurances.TInsuranceEnclosureMapper">

    <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceEnclosure">
            <id property="id" column="ID" jdbcType="INTEGER"/>
            <result property="enclosureName" column="ENCLOSURE_NAME" jdbcType="VARCHAR"/>
            <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
            <result property="deleteFlag" column="DELETE_FLAG" jdbcType="VARCHAR"/>
            <result property="enclosureAddress" column="ENCLOSURE_ADDRESS" jdbcType="VARCHAR"/>
			<result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
			<result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/>
			<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
			<result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
			<result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,enclosure_name,create_name,
        create_by,create_time,remark,
        delete_flag,enclosure_address,
		updateBy,updateTime
    </sql>
	<select id="getInsuranceEnclosurePage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceEnclosureVo">
		select
		    e.ID as id,
			e.ENCLOSURE_NAME as enclosureName,
		    e.CREATE_NAME as createName,
		    e.REMARK as remark,
		    e.CREATE_TIME as createTime
		from
			t_insurance_enclosure e
		where
			e.DELETE_FLAG = 0
		<if test="param.createName != null and param.createName.trim() != ''">
			and e.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.remark != null and param.remark.trim() != ''">
			and e.REMARK like concat('%',replace(replace(#{param.remark},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.enclosureName != null and param.enclosureName.trim() != ''">
			and e.ENCLOSURE_NAME like concat('%',replace(replace(#{param.enclosureName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startTime != null and param.startTime.trim() != '' ">
			AND e.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.startTime}, ' 00:00:00')
		</if>
		<if test="param.endTime != null and param.endTime.trim() != '' ">
			AND e.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endTime}, ' 23:59:59')
		</if>
		order by e.CREATE_TIME desc

	</select>

</mapper>
