<?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.cms.mapper.SysAreaMapper">

    <sql id="selectAreaVo">
        select id, code, name, parent_code, del_flag, create_by, create_time, update_by, update_time, remark from sys_area
    </sql>

    <select id="getList" resultType="com.ruoyi.common.core.domain.entity.SysArea" parameterType="com.ruoyi.common.core.domain.entity.SysArea">
        <include refid="selectAreaVo"/>
        <where>  del_flag = '0'
            <if test="name != null  and name != ''"> and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
            <if test="code != null  and code != ''"> and code =#{code}</if>
            <choose>
                <when test="parentCode != null  and parentCode != ''">
                 and parent_code =#{parentCode}
                </when>
                <otherwise>
                    and parent_code is null
                </otherwise>
            </choose>
        </where>
        order by code
    </select>

</mapper>
