<?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.cloud.user.dao.UserRoleDao">
|
|
<delete id="deleteUserRole">
|
delete from sys_role_user WHERE 1=1 and userId = #{id}
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</delete>
|
|
<delete id="deleteUserRoleByParams" >
|
delete from sys_role_user WHERE 1=1
|
<if test="id != null">
|
and roleId = #{id}
|
</if>
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
</delete>
|
|
<select id="findRolesByUserId" resultType="com.cloud.model.sys.SysRole">
|
select r.* from sys_role_user ru inner join sys_role r on r.id = ru.roleId where ru.userId = #{userId}
|
<if test="orgId != null and orgId != ''">
|
and ru.orgId= #{orgId}
|
</if>
|
</select>
|
|
<select id="findRolesIdsByUserId" resultType="Integer">
|
select r.id from sys_role_user ru inner join sys_role r on r.id = ru.roleId where ru.userId = #{id}
|
<!--<if test="orgId != null and orgId != ''">
|
and r.orgId= #{orgId}
|
</if>-->
|
</select>
|
|
<select id="findRolesIds" resultType="Integer">
|
select roleId from sys_role_user where userId = #{id}
|
</select>
|
|
<insert id="saveUserRoles">
|
INSERT INTO sys_role_user
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="userId != null">
|
userId,
|
</if>
|
<if test="roleId != null">
|
roleId,
|
</if>
|
<if test="orgId != null">
|
orgId,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="userId != null">
|
#{userId,jdbcType=INTEGER},
|
</if>
|
<if test="roleId != null">
|
#{roleId,jdbcType=INTEGER},
|
</if>
|
<if test="orgId != null">
|
#{orgId,jdbcType=INTEGER},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="findUserRoleCount" resultType="int">
|
SELECT count(roleId) from sys_role_user where roleId = #{id}
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
</mapper>
|