<?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.tamguo.modules.sys.dao.SysAreaMapper">
	
	<select id="listData" resultType="SysAreaEntity">
		SELECT
			a.area_code,
			a.parent_code,
			a.parent_codes,
			a.tree_sort,
			a.tree_sorts,
			a.tree_leaf,
			a.tree_level,
			a.tree_names,
			a.area_name,
			a.area_type,
			a.`status` , 
			a.create_by,
			a.create_date,
			a.update_by,
			a.update_date,
			a.remarks
		FROM
			sys_area a
		<where>
			1 = 1
			<choose>
		        <when test="parentCode != null and parentCode != ''">
		          	and a.parent_code = #{parentCode}
		        </when>
		        <otherwise>
		            and a.tree_level = 0
		        </otherwise>
		    </choose>
		</where>
	</select>
</mapper>