<?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.ruoyi.mall.mapper.AddressMapper">

    <resultMap type="Address" id="AddressResult">
        <result property="id" column="id"/>
        <result property="code" column="code"/>
        <result property="parentCode" column="parent_code"/>
        <result property="name" column="name"/>
        <result property="level" column="level"/>
        <result property="createdAt" column="created_at"/>
        <result property="updatedAt" column="updated_at"/>
        <result property="deletedAt" column="deleted_at"/>
    </resultMap>

    <sql id="selectAddressVo">
        select id, code, parent_code, name, level, created_at, updated_at, deleted_at  from address
    </sql>

    <select id="selectByEntity" parameterType="Address" resultMap="AddressResult">
        <include refid="selectAddressVo"/>
        <where>
            <if test="code != null "> and code = #{code}</if>
            <if test="parentCode != null "> and parent_code = #{parentCode}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="level != null "> and level = #{level}</if>
            <if test="createdAt != null  and createdAt != ''"> and created_at = #{createdAt}</if>
            <if test="updatedAt != null  and updatedAt != ''"> and updated_at = #{updatedAt}</if>
            <if test="deletedAt != null  and deletedAt != ''"> and deleted_at = #{deletedAt}</if>
        </where>
    </select>
</mapper>
