<?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.sy.coinage.sys.dao.UserDao">
  <sql id="Base_Column_List">
    id
    , status, dept_id, real_name, mobile, create_by, username, create_time, tenant_id
  </sql>

  <select id="selectByRoleId" parameterType="java.lang.Integer"
    resultType="com.sy.coinage.core.vo.OptVO">
    select distinct sys_user.id, sys_user.real_name as name
    from sys_user
           left join sys_user_role on sys_user_role.user_id = sys_user.id
    where sys_user_role.role_id = #{id,jdbcType=INTEGER}
      and sys_user.status = 1
      and sys_user.del_flag = 1
    group by id, name
  </select>
  <select id="queryPageList" resultType="com.sy.coinage.sys.vo.UserListVO">
    select
    <include refid="Base_Column_List"/>,
    (select group_concat(sys_role.name) from sys_user_role left join sys_role on
    sys_user_role.role_id = sys_role.id where sys_user_role.user_id= sys_user.id) as role_name
    from sys_user
    <if test="ew.emptyOfWhere == false">
      ${ew.customSqlSegment}
    </if>
  </select>
</mapper>
