<?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.iemes.mapper.UserMapper">
	<!--mybatis ehcache缓存配置 -->
	<!-- 以下两个<cache>标签二选一,第一个可以输出日志,第二个不输出日志 <cache type="org.mybatis.caches.ehcache.LoggingEhcache" 
		/> -->
	<!-- <cache type="org.mybatis.caches.ehcache.EhcacheCache"/> -->
	<!-- 以下与实体类的中字段一致 -->
	<sql id="selectId">
		id,
		userName,
		accountName,
		(SELECT group_concat(name) from ly_role
		where ly_role.id
		in (SELECT roleId FROM ly_user_role WHERE
		userId=ly_user.id) ) roleName,
		password,
		description,
		site,
		locked,
		credentialsSalt,
		createTime
	</sql>

	<select id="findUserPage" resultType="com.iemes.entity.UserFormMap">
		SELECT
		<include refid="selectId" />
		from ly_user
		where 1 = 1
		<if test="accountName != null and accountName != ''">
		and accountName like '%${accountName}%'
		</if>
		<if test="site != null and site != ''">
		and site = '${site}'
		</if>
		<if test="column != null">
          order by ${column} ${sort}
        </if>
	</select>

	
</mapper>