<?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.SysCompanyMapper">
	
	<select id="listData" resultType="SysCompanyEntity">
		SELECT
			c.company_code,
			c.parent_code,
			c.parent_codes,
			c.tree_sort,
			c.tree_sorts,
			c.tree_leaf,
			c.tree_level,
			c.tree_names,
			c.view_code,
			c.company_name,
			c.full_name,
			c.area_code,
			c.`status`,
			c.create_by,
			c.create_date,
			c.update_by,
			c.update_date,
			c.remarks,
			c.corp_code,
			c.corp_name
		FROM
			sys_company c
		<where>
			1 = 1
			<choose>
		        <when test="parentCode != null and parentCode != ''">
		          	and c.parent_code = #{parentCode}
		        </when>
		        <otherwise>
		            and c.tree_level = 0
		        </otherwise>
		    </choose>
		</where>
	</select>
	
	<select id="selectByCode" resultType="SysCompanyEntity">
		SELECT
			c.*
		FROM
			sys_company c
		WHERE
			c.company_code = #{id}
	</select>
</mapper>