AfmsBasicCustomerMapper.xml 7.4 KB
<?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.zhonglai.luhui.afms.mapper.AfmsBasicCustomerMapper">
    
    <resultMap type="AfmsBasicCustomer" id="AfmsBasicCustomerResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="customer_type_id"    column="customer_type_id"    />
        <result property="contact_person"    column="contact_person"    />
        <result property="contact_phone"    column="contact_phone"    />
        <result property="contact_address"    column="contact_address"    />
        <result property="taxpayer_identification_number"    column="taxpayer_identification_number"    />
        <result property="bank"    column="bank"    />
        <result property="account_name"    column="account_name"    />
        <result property="account_number"    column="account_number"    />
        <result property="business_license"    column="business_license"    />
        <result property="create_time"    column="create_time"    />
    </resultMap>

    <sql id="selectAfmsBasicCustomerVo">
        select `id`, `name`, `customer_type_id`, `contact_person`, `contact_phone`, `contact_address`, `taxpayer_identification_number`, `bank`, `account_name`, `account_number`, `business_license`, `create_time` from afms_basic_customer
    </sql>

    <select id="selectAfmsBasicCustomerList" parameterType="AfmsBasicCustomer" resultMap="AfmsBasicCustomerResult">
        <include refid="selectAfmsBasicCustomerVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="customer_type_id != null "> and customer_type_id = #{customer_type_id}</if>
            <if test="contact_person != null  and contact_person != ''"> and contact_person like concat('%', #{contact_person}, '%')</if>
            <if test="contact_phone != null  and contact_phone != ''"> and contact_phone like concat('%', #{contact_phone}, '%')</if>
            <if test="contact_address != null  and contact_address != ''"> and contact_address like concat('%', #{contact_address}, '%')</if>
            <if test="taxpayer_identification_number != null  and taxpayer_identification_number != ''"> and taxpayer_identification_number like concat('%', #{taxpayer_identification_number}, '%')</if>
            <if test="bank != null  and bank != ''"> and bank like concat('%', #{bank}, '%')</if>
            <if test="account_name != null  and account_name != ''"> and account_name like concat('%', #{account_name}, '%')</if>
            <if test="account_number != null  and account_number != ''"> and account_number like concat('%', #{account_number}, '%')</if>
            <if test="business_license != null  and business_license != ''"> and business_license like concat('%', #{business_license}, '%')</if>
            <if test="params.beginCreate_time != null and params.beginCreate_time != '' and params.endCreate_time != null and params.endCreate_time != ''"> and create_time between #{params.beginCreate_time} and #{params.endCreate_time}</if>
        </where>
    </select>
    
    <select id="selectAfmsBasicCustomerById" parameterType="Integer" resultMap="AfmsBasicCustomerResult">
        <include refid="selectAfmsBasicCustomerVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAfmsBasicCustomer" parameterType="AfmsBasicCustomer" useGeneratedKeys="true" keyProperty="id">
        insert into afms_basic_customer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="customer_type_id != null">customer_type_id,</if>
            <if test="contact_person != null and contact_person != ''">contact_person,</if>
            <if test="contact_phone != null and contact_phone != ''">contact_phone,</if>
            <if test="contact_address != null and contact_address != ''">contact_address,</if>
            <if test="taxpayer_identification_number != null and taxpayer_identification_number != ''">taxpayer_identification_number,</if>
            <if test="bank != null and bank != ''">bank,</if>
            <if test="account_name != null and account_name != ''">account_name,</if>
            <if test="account_number != null and account_number != ''">account_number,</if>
            <if test="business_license != null and business_license != ''">business_license,</if>
            <if test="create_time != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="customer_type_id != null">#{customer_type_id},</if>
            <if test="contact_person != null and contact_person != ''">#{contact_person},</if>
            <if test="contact_phone != null and contact_phone != ''">#{contact_phone},</if>
            <if test="contact_address != null and contact_address != ''">#{contact_address},</if>
            <if test="taxpayer_identification_number != null and taxpayer_identification_number != ''">#{taxpayer_identification_number},</if>
            <if test="bank != null and bank != ''">#{bank},</if>
            <if test="account_name != null and account_name != ''">#{account_name},</if>
            <if test="account_number != null and account_number != ''">#{account_number},</if>
            <if test="business_license != null and business_license != ''">#{business_license},</if>
            <if test="create_time != null">#{create_time},</if>
         </trim>
    </insert>

    <update id="updateAfmsBasicCustomer" parameterType="AfmsBasicCustomer">
        update afms_basic_customer
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="customer_type_id != null">customer_type_id = #{customer_type_id},</if>
            <if test="contact_person != null and contact_person != ''">contact_person = #{contact_person},</if>
            <if test="contact_phone != null and contact_phone != ''">contact_phone = #{contact_phone},</if>
            <if test="contact_address != null and contact_address != ''">contact_address = #{contact_address},</if>
            <if test="taxpayer_identification_number != null and taxpayer_identification_number != ''">taxpayer_identification_number = #{taxpayer_identification_number},</if>
            <if test="bank != null and bank != ''">bank = #{bank},</if>
            <if test="account_name != null and account_name != ''">account_name = #{account_name},</if>
            <if test="account_number != null and account_number != ''">account_number = #{account_number},</if>
            <if test="business_license != null and business_license != ''">business_license = #{business_license},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAfmsBasicCustomerById" parameterType="Integer">
        delete from afms_basic_customer where id = #{id}
    </delete>

    <delete id="deleteAfmsBasicCustomerByIds" parameterType="String">
        delete from afms_basic_customer where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>