<?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.testor.module.contractor.ledger.dao.TContractorInfoDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.contractor.ledger.model.domain.TContractorInfo">
                <id column="id" property="id"/>
                <id column="name" property="name"/>
                <id column="credit_code" property="creditCode"/>
                <id column="reg_capital" property="regCapital"/>
                <id column="province" property="province"/>
                <id column="city" property="city"/>
                <id column="addr" property="addr"/>
                <id column="legal_person" property="legalPerson"/>
                <id column="tel" property="tel"/>
                <id column="reg_date" property="regDate"/>
                <id column="valid_period" property="validPeriod"/>
                <id column="biz_scope" property="bizScope"/>
                <id column="is_blacklist" property="isBlacklist"/>
    </resultMap>

    <select id="selectAll" resultMap="BaseResultMap">
        SELECT DISTINCT ON (name, credit_code) *
        FROM t_contractor_info
        WHERE status = '0' and name !=''
        <if test="name!='' and name!=null">
            name like concat('%', #{name}, '%')
        </if>
        ORDER BY name, credit_code, id
    </select>

</mapper>