<?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.chinaweal.aiccs.aiccs.market.mapper.AddressAssignMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.market.entity.AddressAssign">
        <id column="id" property="id" />
        <result column="address" property="address" />
        <result column="org_number" property="orgNumber" />
        <result column="type" property="type" />
        <result column="operator" property="operator" />
        <result column="insert_time" property="insertTime" />
        <result column="state" property="state" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, address, org_number, type, operator, insert_time, state
    </sql>

    <select id="getAddressAssignList" resultType="com.chinaweal.aiccs.aiccs.market.entity.AddressAssign">
        select * from address_assign where rem_time is null and org_number like concat('%', #{params.orgNumber}, '%')
        <if test="params.address != null and params.address != ''">
            and address like concat('%', #{params.address}, '%')
        </if>
        <if test="params.operator != null and params.operator != ''">
            and operator = #{params.operator}
        </if>
        <if test="params.startDate != null and params.startDate != ''">
            <if test="params.startDate != params.endDate">
                and insert_time <![CDATA[ > ]]> #{params.startDate} and insert_time <![CDATA[ < ]]> #{params.endDate}
            </if>
<!--            <if test="params.startDate == params.endDate">-->
<!--                and DATE_FORMAT(insert_time,'%Y-%m-%d') = #{params.startDate}-->
<!--            </if>-->
        </if>
    </select>

</mapper>
