<?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.willalp.yiqing.mapper.HsYiqingAddrMapper">

    <resultMap type="com.willalp.yiqing.domain.HsYiqingAddr" id="HsYiqingAddrResult">
        <result property="addrId" column="addr_id"/>
        <result property="addrTreeId" column="addr_tree_id"/>
        <result property="addrParentId" column="addr_parent_id"/>
        <result property="addrNo" column="addr_no"/>
        <result property="addrType" column="addr_type"/>
        <result property="addrName" column="addr_name"/>
        <result property="addrDetail" column="addr_detail"/>
        <result property="houseNo" column="house_no"/>
        <result property="belongName" column="belong_name"/>
        <result property="belongPhone" column="belong_phone"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsYiqingAddrVo">
        select addr_id,
               addr_tree_id,
               addr_parent_id,
               addr_no,
               addr_type,
               addr_name,
               addr_detail,
               house_no,
               belong_name,
               belong_phone,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_yiqing_addr
    </sql>

    <select id="selectHsYiqingAddrList" parameterType="HsYiqingAddr" resultMap="HsYiqingAddrResult">
        <include refid="selectHsYiqingAddrVo"/>
        <where>
            is_delete = 0
            <if test="addrParentId != null ">
                  and addr_parent_id = #{addrParentId}
            </if>
            <if test="addrNo != null  and addrNo != ''">
                  and addr_no like concat('%', #{addrNo}, '%')
            </if>
            <if test="addrType != null  and addrType != ''">
                  and addr_type = #{addrType}
            </if>
            <if test="addrName != null  and addrName != ''">
                  and addr_name like concat('%', #{addrName}, '%')
            </if>
            <if test="addrDetail != null  and addrDetail != ''">
                  and addr_detail like concat('%', #{addrDetail}, '%')
            </if>
            <if test="belongName != null  and belongName != ''">
                  and belong_name like concat('%', #{belongName}, '%')
            </if>
            <if test="belongPhone != null  and belongPhone != ''">
                  and belong_phone like concat('%', #{belongPhone}, '%')
            </if>
            <if test="isDelete != null ">
                  and is_delete = #{isDelete}
            </if>
        </where>
    </select>
</mapper>
