<?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.kidgrow.usercenter.mapper.SysRoleMapper">
	<sql id="Column_List">
			id,
			code,
			name,
			create_time,
			update_time,
			is_del,
			enabled,
			tenant_id
	</sql>

	<sql id="where">
		<where>
			t.is_del=0
			<if test="r.enabled != null and r.enabled != ''">
				and t.enabled = #{r.enabled}
			</if>
			<if test="r.tenantId != null and r.tenantId != ''">
				and t.tenant_id = #{r.tenantId}
			</if>
			<if test="r.name != null and r.name != ''">
				and t.name like concat('%', #{r.name}, '%')
			</if>
			<if test="r.searchKey != null and r.searchKey != '' and r.searchKey=='name'">
				and t.name like concat('%', #{r.searchValue}, '%')
			</if>
		</where>
	</sql>

	<select id="findList" resultType="com.kidgrow.common.model.SysRole">
		select <include refid="Column_List"/>
		from sys_role t
		<include refid="where" />
		order by t.create_time desc
	</select>

	<select id="findAll" resultType="com.kidgrow.common.model.SysRole">
		select <include refid="Column_List"/>
		from sys_role
		order by create_time desc
	</select>
</mapper>