<?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="cn.ezhizao.project.business.supplier.mapper.BizSupplierContactsMapper">

    <resultMap type="cn.ezhizao.project.business.supplier.domain.BizSupplierContacts" id="BizSupplierContactsResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizSupplierContacts" resultMap="BizSupplierContactsResult">
        SELECT * FROM biz_supplier_contacts t1 left join biz_supplier t2 on t1.supplier_id = t2.id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0 and t2.deleted = 0
            <if test="supplierName != null  and supplierName != ''"> AND t1.supplier_name like concat('%', #{supplierName}, '%')</if>
            <if test="name != null  and name != ''"> AND t1.name like concat('%', #{name}, '%')</if>
            <if test="supplierId != null  and supplierId != ''"> AND t1.supplier_id = #{supplierId}</if>
            <if test="email != null  and email != ''"> AND t1.email = #{email}</if>
            <if test="phoneNumber != null  and phoneNumber != ''"> AND t1.phone_number = #{phoneNumber}</if>
            <if test="isDefault != null "> AND t1.is_default = #{isDefault}</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_supplier_contacts
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
