use of com.jun.plugin.system.vo.req.UserRoleOperationReqVO in project jun_springboot_api_service by wujun728.
the class UserServiceImpl method addUser.
@Override
public void addUser(SysUser vo) {
SysUser sysUserOne = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, vo.getUsername()));
if (sysUserOne != null) {
throw new BusinessException("用户已存在,请勿重复添加!");
}
vo.setSalt(PasswordUtils.getSalt());
String encode = PasswordUtils.encode(vo.getPassword(), vo.getSalt());
vo.setPassword(encode);
vo.setStatus(1);
vo.setCreateWhere(1);
sysUserMapper.insert(vo);
if (!CollectionUtils.isEmpty(vo.getRoleIds())) {
UserRoleOperationReqVO reqVO = new UserRoleOperationReqVO();
reqVO.setUserId(vo.getId());
reqVO.setRoleIds(vo.getRoleIds());
userRoleService.addUserRoleInfo(reqVO);
}
}
use of com.jun.plugin.system.vo.req.UserRoleOperationReqVO in project jun_springboot_api_service by wujun728.
the class UserController method setUserOwnRole.
@PutMapping("/user/roles/{userId}")
@ApiOperation(value = "赋予角色-用户赋予角色接口")
@LogAnnotation(title = "用户管理", action = "赋予角色-用户赋予角色接口")
@RequiresPermissions("sys:user:update:role")
public DataResult setUserOwnRole(@PathVariable("userId") String userId, @RequestBody List<String> roleIds) {
LambdaQueryWrapper<SysUserRole> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SysUserRole::getUserId, userId);
userRoleService.remove(queryWrapper);
if (!CollectionUtils.isEmpty(roleIds)) {
UserRoleOperationReqVO reqVO = new UserRoleOperationReqVO();
reqVO.setUserId(userId);
reqVO.setRoleIds(roleIds);
userRoleService.addUserRoleInfo(reqVO);
}
// 刷新权限
httpSessionService.refreshUerId(userId);
return DataResult.success();
}
Aggregations