fix 修复 用户绑定角色 与 角色绑定用户 异常 编写错误
parent
3ded50ca60
commit
487f18a930
|
|
@ -3,6 +3,8 @@ package com.ruoyi.system.mapper;
|
||||||
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户与角色关联表 数据层
|
* 用户与角色关联表 数据层
|
||||||
*
|
*
|
||||||
|
|
@ -10,6 +12,6 @@ import com.ruoyi.system.domain.SysUserRole;
|
||||||
*/
|
*/
|
||||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, SysUserRole, SysUserRole> {
|
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, SysUserRole, SysUserRole> {
|
||||||
|
|
||||||
Long selectUserIdByRoleId(Long roleId);
|
List<Long> selectUserIdsByRoleId(Long roleId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,11 +115,11 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysUser> selectUnallocatedList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> selectUnallocatedList(SysUser user, PageQuery pageQuery) {
|
||||||
Long userId = userRoleMapper.selectUserIdByRoleId(user.getRoleId());
|
List<Long> userIds = userRoleMapper.selectUserIdsByRoleId(user.getRoleId());
|
||||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||||
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
||||||
.and(w -> w.ne("r.role_id", user.getRoleId()).or().isNull("r.role_id"))
|
.and(w -> w.ne("r.role_id", user.getRoleId()).or().isNull("r.role_id"))
|
||||||
.notIn("u.user_id", userId)
|
.notIn("u.user_id", userIds)
|
||||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||||
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber());
|
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber());
|
||||||
Page<SysUser> page = baseMapper.selectUnallocatedList(pageQuery.build(), wrapper);
|
Page<SysUser> page = baseMapper.selectUnallocatedList(pageQuery.build(), wrapper);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="roleId" column="role_id" />
|
<result property="roleId" column="role_id" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectUserIdByRoleId" resultType="Long">
|
<select id="selectUserIdsByRoleId" resultType="Long">
|
||||||
select u.user_id from sys_user u
|
select u.user_id from sys_user u
|
||||||
inner join sys_user_role ur
|
inner join sys_user_role ur
|
||||||
on u.user_id = ur.user_id and ur.role_id = #{roleId}
|
on u.user_id = ur.user_id and ur.role_id = #{roleId}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ export default {
|
||||||
if (userId) {
|
if (userId) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
getAuthRole(userId).then((response) => {
|
getAuthRole(userId).then((response) => {
|
||||||
this.form = response.user;
|
this.form = response.data.user;
|
||||||
this.roles = response.roles;
|
this.roles = response.data.roles;
|
||||||
this.total = this.roles.length;
|
this.total = this.roles.length;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.roles.forEach((row) => {
|
this.roles.forEach((row) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue