<?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.huatek.frame.base.mapper.GroupMapper">
	<sql id="Base_Column_List">
		c.id as id , c.group_name as groupName,
		c.group_code as groupCode,
		c.deleted as deleted, 
		c.create_date as createDate,
		p.group_name as groupParentName, 
		c.group_parent_id as groupParentId
	</sql>

	<select id="selectGroupPage" parameterType="com.huatek.frame.base.dto.GroupDTO"
		resultType="com.huatek.frame.base.vo.GroupVO">
		select
		<include refid="Base_Column_List" />
		from
			sys_group c
		left join
			sys_group p
		on
			p.id=c.group_parent_id
		where 
			c.deleted = #{deleted}
		AND c.group_code <![CDATA[!=]]> 'GROUP001'
		<if test="groupName != null  and  groupName != '' ">
			and c.group_name like concat('%',#{groupName},'%')
		</if>
		<if test="groupCode != null  and  groupCode != '' ">
			and c.group_code like concat('%',#{groupCode},'%')
		</if>
		ORDER BY c.create_date desc
	</select>

</mapper>