<?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.ruili.wcp.dao.management.UserMapper">
|
|
<resultMap id="withUserMap" type="com.ruili.wcp.data.entity.management.User">
|
<id column="user_id" jdbcType="BIGINT" property="userId"/>
|
<result column="user_name" property="userName"/>
|
<result column="true_name" property="trueName"/>
|
<result column="dept_name" property="deptName"/>
|
<result column="dept_id" property="deptId"/>
|
<result column="mobile_phone" property="mobilePhone"/>
|
<result column="enable_login" property="enableLogin"/>
|
<result column="employee_num" property="employeeNum"/>
|
<result column="security_level" property="securityLevel"/>
|
<result column="create_time" property="createTime"/>
|
</resultMap>
|
|
<!-- 获取某个用户所有的角色 -->
|
<select id="getRoles" parameterType="String" resultType="String">
|
select role_name
|
FROM sys_role a,
|
sys_role_user b,
|
sys_account c
|
WHERE a.role_id = b.role_id
|
and b.user_id = c.user_id
|
and c.user_name = #{userName}
|
</select>
|
|
<!-- 获取某个用户所有的权限 -->
|
<select id="getPermissions" parameterType="String" resultType="String">
|
select permission_name
|
FROM sys_role a,
|
sys_role_user b,
|
sys_account c,
|
sys_permission_setting d
|
WHERE a.role_id = b.role_id
|
and b.user_id = c.user_id
|
and c.user_name = #{userName}
|
and (a.role_id = d.role_id or c.user_id = d.user_id)
|
</select>
|
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="mysql">
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
limit #{currIndex} , #{pageSize}
|
</select>
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="oracle">
|
SELECT * FROM (
|
SELECT t.*, ROWNUM AS rn FROM (
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
) t
|
) WHERE rn BETWEEN ${currIndex} AND (${currIndex} + ${pageSize})
|
</select>
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="kingbasees">
|
SELECT * FROM (
|
SELECT t.*, ROWNUM AS rn FROM (
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
) t
|
) WHERE rn BETWEEN ${currIndex} AND (${currIndex} + ${pageSize})
|
</select>
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="dameng">
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
limit #{currIndex} , #{pageSize}
|
</select>
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="xugu">
|
SELECT * FROM (
|
SELECT t.*, ROWNUM AS rn FROM (
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
) t
|
) WHERE rn BETWEEN ${currIndex} AND (${currIndex} + ${pageSize})
|
</select>
|
<select id="selectUserPage" parameterType="map" resultMap="withUserMap" databaseId="sqlServer">
|
SELECT * FROM (
|
select ROW_NUMBER() OVER(
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
</if>
|
) AS rn,
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
) t
|
WHERE rn BETWEEN ${currIndex} AND (${currIndex} + ${pageSize})
|
</select>
|
|
<select id="selectUserCount" parameterType="String" resultType="Integer">
|
select
|
count(1)
|
from sys_account a ,sys_dept b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where
|
a.user_id=c.user_id and b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
<!--若启用三元管理,不显示静态角色下的用户-->
|
<if test="enableThreeMemberManagement!=null">
|
and a.user_name!='admin' and a.user_id not in(select q.user_id from sys_role p,sys_role_user q where
|
p.is_static=1 and p.role_id=q.role_id)
|
</if>
|
</select>
|
|
<select id="selectUserList" parameterType="map" resultMap="withUserMap">
|
select
|
a.user_id,a.user_name,a.true_name,a.dept_name,a.dept_id,a.mobile_phone,a.enable_login,a.employee_num,a.security_level,a.create_time
|
from sys_account a ,sys_dept
|
b where (a.dept_id = b.dept_id or exists(select 1 from sys_dept_user c where a.user_id=c.user_id and
|
b.dept_id=c.dept_id))
|
<if test="deptCode!=null">
|
and b.dept_code like '${deptCode}%'
|
</if>
|
<if test="classificationCode!=null">
|
and a.security_level >= '${classificationCode}'
|
</if>
|
<if test="searchText!=null">
|
and (a.user_name like '%${searchText}%' or
|
a.true_name like
|
'%${searchText}%')
|
</if>
|
|
<if test="sort!=null">
|
order by a.${sort} ${order}
|
|
</if>
|
<if test="sort==null">
|
order by a.sort_num asc
|
|
</if>
|
</select>
|
</mapper>
|