zhangherong
12 小时以前 35f7901210de45eefaa58b38db23405c561f9484
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.jeecg.modules.system.mapper;
 
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.entity.SysUserRole;
import org.jeecg.modules.system.vo.SysUserRoleExitVo;
 
import java.util.List;
 
/**
 * <p>
 * 用户角色表 Mapper 接口
 * </p>
 *
 * @Author scott
 * @since 2018-12-21
 */
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
 
    /**
     * 通过用户账号查询角色集合
     * @param username 用户账号名称
     * @return List<String>
     */
    @Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
    List<String> getRoleByUserName(@Param("username") String username);
 
    /**
     * 通过用户账号查询角色Id集合
     * @param username 用户账号名称
     * @return List<String>
     */
    @Select("select id from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
    List<String> getRoleIdByUserName(@Param("username") String username);
 
    /**
     * 根据角色查询用户
     * @param roleList role_code集合
     * */
    List<SysUser> getUsersByRoles(@Param("roleList") List<String> roleList);
 
 
    /**
     * 通过角色id获取用户username
     * @param roleId
     */
    @Select("select username from sys_user where id in (select user_id from sys_user_role where role_id = #{roleId})")
    List<String> getUserNameByRoleId(@Param("roleId") String roleId);
 
    /**
     * 通过用户id集合获取用户和角色关系
     * @param userIds
     * @return
     */
    @InterceptorIgnore(tenantLine = "true") // 跳过租户插件解析
    List<SysUserRoleExitVo> queryRoleNamesByUserIds(@Param("userIds") List<String> userIds);
}