<?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.ozs.base.mapper.BaseSupplierMapper">
    <resultMap type="com.ozs.base.domain.BaseSupplier" id="BaseSupplierResult">
        <id property="id" column="id"/>
        <result property="supplierName" column="supplier_name"/>
        <result property="supplierResponsiblePerson" column="supplier_responsible_person"/>
        <result property="supplierAddress" column="supplier_address"/>
        <result property="supplierType" column="supplier_type"/>
        <result property="supplierState" column="supplier_state"/>
        <result property="supplierAdvancePurchase" column="supplier_advance_purchase"/>
        <result property="postalCode" column="postal_code"/>
        <result property="projectPerson" column="project_person"/>
        <result property="telephone" column="telephone"/>
        <result property="bankAccountName" column="bank_account_name"/>
        <result property="bankOfDeposit" column="bank_of_deposit"/>
        <result property="bankAccountNumber" column="bank_account_number"/>
        <result property="created" column="created"/>
        <result property="createTime" column="create_time"/>
        <result property="updated" column="updated"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <insert id="insertBaseSupplier" parameterType="com.ozs.base.domain.BaseSupplier">
        insert into base_supplier
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="supplierName != null">supplier_name,</if>
            <if test="supplierResponsiblePerson != null">supplier_responsible_person,</if>
            <if test="supplierAddress != null">supplier_address,</if>
            <if test="supplierType != null">supplier_type,</if>
            <if test="supplierState != null">supplier_state,</if>
            <if test="supplierAdvancePurchase != null">supplier_advance_purchase,</if>
            <if test="postalCode != null">postal_code,</if>
            <if test="projectPerson != null">project_person,</if>
            <if test="telephone != null">telephone,</if>
            <if test="bankAccountName != null">bank_account_name,</if>
            <if test="bankOfDeposit != null">bank_of_deposit,</if>
            <if test="bankAccountNumber != null">bank_account_number,</if>
            <if test="created != null">created,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updated != null">updated,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="supplierName != null">#{supplierName},</if>
            <if test="supplierResponsiblePerson != null">#{supplierResponsiblePerson},</if>
            <if test="supplierAddress != null">#{supplierAddress},</if>
            <if test="supplierType != null">#{supplierType},</if>
            <if test="supplierState != null">#{supplierState},</if>
            <if test="supplierAdvancePurchase != null">#{supplierAdvancePurchase},</if>
            <if test="postalCode != null">#{postalCode},</if>
            <if test="projectPerson != null">#{projectPerson},</if>
            <if test="telephone != null">#{telephone},</if>
            <if test="bankAccountName != null">#{bankAccountName},</if>
            <if test="bankOfDeposit != null">#{bankOfDeposit},</if>
            <if test="bankAccountNumber != null">#{bankAccountNumber},</if>
            <if test="created != null">#{created},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updated != null">#{updated},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <delete id="deleteBaseSupplier" parameterType="java.lang.Integer">
        delete
        from base_supplier
        where id = #{id}
    </delete>

    <update id="updateBaseSupplier" parameterType="com.ozs.base.domain.BaseSupplier">
        update base_supplier
        <trim prefix="SET" suffixOverrides=",">
            <if test="supplierName != null">supplier_name = #{supplierName},</if>
            <if test="supplierResponsiblePerson != null">supplier_responsible_person = #{supplierResponsiblePerson},</if>
            <if test="supplierAddress != null">supplier_address = #{supplierAddress},</if>
            <if test="supplierType != null">supplier_type = #{supplierType},</if>
            <if test="supplierState != null">supplier_state = #{supplierState},</if>
            <if test="supplierAdvancePurchase != null">supplier_advance_purchase = #{supplierAdvancePurchase},</if>
            <if test="postalCode != null">postal_code = #{postalCode},</if>
            <if test="projectPerson != null">project_person = #{projectPerson},</if>
            <if test="telephone != null">telephone = #{telephone},</if>
            <if test="bankAccountName != null">bank_account_name = #{bankAccountName},</if>
            <if test="bankOfDeposit != null">bank_of_deposit = #{bankOfDeposit},</if>
            <if test="bankAccountNumber != null">bank_account_number = #{bankAccountNumber},</if>
            <if test="created != null">created = #{created},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updated != null">updated = #{updated},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <select id="selectBaseSupplier" parameterType="com.ozs.base.domain.BaseSupplier" resultMap="BaseSupplierResult">
        select * from base_supplier
        <where>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
            <if test="supplierName != null and supplierName != ''">
                and supplier_name like '% +' #{supplierName} '+ %'
            </if>
            <if test="supplierResponsiblePerson != null and supplierResponsiblePerson != ''">
                and supplier_responsible_person like '% +' #{supplierResponsiblePerson} '+ %'
            </if>
            <if test="supplierAddress != null and supplierAddress != ''">
                and supplier_address like '% +' #{supplierAddress} '+ %'
            </if>
            <if test="supplierType != null and supplierType != ''">
                and supplier_type = #{supplierType}
            </if>
            <if test="supplierState != null and supplierState != ''">
                and supplier_state = #{supplierState}
            </if>
            <if test="supplierAdvancePurchase != null and supplierAdvancePurchase != '' ">
                and supplier_advance_purchase = #{supplierAdvancePurchase}
            </if>
            <if test="postalCode != null and postalCode != ''">
                and postal_code = #{postalCode}
            </if>
            <if test="projectPerson != null and projectPerson != ''">
                and project_person = #{projectPerson}
            </if>
            <if test="telephone != null and telephone != ''">
                and telephone = #{telephone}
            </if>
            <if test="bankAccountName != null and bankAccountName != ''">
                and bank_account_name = #{bankAccountName}
            </if>
            <if test="bankOfDeposit != null and bankOfDeposit != ''">
                and bank_of_deposit = #{bankOfDeposit}
            </if>
            <if test="bankAccountNumber != null and bankAccountNumber != ''">
                and bank_account_number = #{bankAccountNumber}
            </if>
            <if test="created != null and created != ''">
                and created = #{created}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updated != null and updated != ''">
                and updated = #{updated}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
        </where>
    </select>
</mapper>