<?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.glxp.mipsdl.thirddao.cdxnnkyy.A001Mapper">
    <resultMap id="BaseResultMap" type="com.glxp.mipsdl.entity.cdxnnkyy.A001">
        <!--@mbg.generated-->
        <!--@Table udi_wms_ywj.a001-->
        <id column="UNITID" jdbcType="VARCHAR" property="unitid"/>
        <result column="NAME" jdbcType="VARCHAR" property="name"/>
        <result column="LASTUPDATETIME" jdbcType="TIMESTAMP" property="lastupdatetime"/>
        <result column="ADDR" jdbcType="VARCHAR" property="addr"/>
        <result column="CREDITNO" jdbcType="VARCHAR" property="creditno"/>
        <result column="SPELL" jdbcType="VARCHAR" property="spell"/>
        <result column="CONTACT" jdbcType="VARCHAR" property="contact"/>
        <result column="MOBILE" jdbcType="VARCHAR" property="mobile"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        UNITID, `NAME`, LASTUPDATETIME, ADDR, CREDITNO, SPELL, CONTACT, MOBILE
    </sql>

    <select id="filterList" resultType="com.glxp.mipsdl.entity.cdxnnkyy.A001">
        select *
        from a001
        <where>
            <if test="key != null and key != '' and databaseProductName == 'MySQL'">
                AND (
                            UNITID like concat('%', #{key}, '%') OR
                            NAME like concat('%', #{key}, '%') OR
                            ADDR like concat('%', #{key}, '%') OR
                            CREDITNO like concat('%', #{key}, '%') OR
                            SPELL like concat('%', #{key}, '%') OR
                            CONTACT like concat('%', #{key}, '%') OR
                            MOBILE like concat('%', #{key}, '%')
                            )
            </if>
            <if test="unitId != null and unitId != '' and databaseProductName == 'MySQL'">
                AND UNITID like concat('%', #{unitId}, '%')
            </if>
            <if test="name != null and name != '' and databaseProductName == 'MySQL'">
                AND NAME like concat('%', #{name}, '%')
            </if>





            <if test="key != null and key != '' and databaseProductName == 'Oracle'">
                AND (
                            UNITID LIKE '%' || #{key} || '%' OR
                            NAME LIKE '%' || #{key} || '%' OR
                            ADDR LIKE '%' || #{key} || '%' OR
                            CREDITNO LIKE '%' || #{key} || '%' OR
                            SPELL LIKE '%' || #{key} || '%' OR
                            CONTACT LIKE '%' || #{key} || '%' OR
                            MOBILE LIKE '%' || #{key} || '%' OR
                            )
            </if>
            <if test="unitId != null and unitId != ''  and databaseProductName == 'Oracle'">
                AND UNITID LIKE '%' || #{unitId} || '%'  OR
            </if>
            <if test="name != null and name != ''  and databaseProductName == 'Oracle'">
                AND NAME LIKE '%' || #{name} || '%'
            </if>
        </where>
        order by LASTUPDATETIME
    </select>
</mapper>