use of io.nerv.web.sys.role.entity.RoleUserEntity in project EVA-API by PKAQ-LAB.
the class RoleService method listUser.
/**
* 获取该角色绑定的所有用户
* @param roleId 权限条件
* @return
*/
public Map<String, Object> listUser(String roleId, String deptId) {
// 获取所有用户
UserEntity userEntity = new UserEntity();
if (StrUtil.isNotBlank(deptId)) {
userEntity.setDeptId(deptId);
}
userEntity.setLocked(LockEnumm.UNLOCK.getIndex());
List<UserEntity> users = this.userService.listUser(userEntity);
// 获取已选的模块
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setRoleId(roleId);
QueryWrapper<RoleUserEntity> wrapper = new QueryWrapper<>();
wrapper.setEntity(roleUserEntity);
// 只返回moduleId
List<RoleUserEntity> roleUserList = this.roleUserMapper.selectList(wrapper);
List<String> checked = null;
if (CollectionUtils.isNotEmpty(roleUserList)) {
checked = new ArrayList<>(roleUserList.size());
for (RoleUserEntity rue : roleUserList) {
checked.add(rue.getUserId());
}
}
Map<String, Object> map = new HashMap<>(2);
map.put("users", users);
map.put("checked", checked);
return map;
}
use of io.nerv.web.sys.role.entity.RoleUserEntity in project EVA-API by PKAQ-LAB.
the class UserService method saveRoles.
/**
* 保存用户权限
* @param user
*/
public void saveRoles(UserEntity user) {
// 保存权限
if (CollUtil.isNotEmpty(user.getRoles())) {
// 先删除该用户原有的权限
QueryWrapper<RoleUserEntity> deleteWrapper = new QueryWrapper<>();
deleteWrapper.eq("user_id", user.getId());
this.roleUserMapper.delete(deleteWrapper);
// 再插入更新后的权限
user.getRoles().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setRoleId(item.getId());
roleUserEntity.setUserId(user.getId());
roleUserMapper.insert(roleUserEntity);
});
}
}
use of io.nerv.web.sys.role.entity.RoleUserEntity in project EVA-API by PKAQ-LAB.
the class RoleService method saveUser.
/**
* 保存角色关系表
*/
public void saveUser(RoleEntity role) {
QueryWrapper<RoleUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq("role_id", role.getId());
// 删除原有角色
this.roleUserMapper.delete(wrapper);
// 插入新的权限信息
if (CollectionUtil.isNotEmpty(role.getUsers())) {
List<RoleUserEntity> users = role.getUsers();
for (RoleUserEntity user : users) {
user.setRoleId(role.getId());
this.roleUserMapper.insert(user);
}
}
}
Aggregations