use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Oracle by yangzongzhuan.
the class SysUserServiceImpl method deleteUserByIds.
/**
* 批量删除用户信息
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteUserByIds(Long[] userIds) {
for (Long userId : userIds) {
checkUserAllowed(new SysUser(userId));
checkUserDataScope(userId);
}
// 删除用户与角色关联
userRoleMapper.deleteUserRole(userIds);
// 删除用户与岗位关联
userPostMapper.deleteUserPost(userIds);
return userMapper.deleteUserByIds(userIds);
}
use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysLoginService method register.
/**
* 注册
*/
public void register(RegisterBody registerBody) {
String username = registerBody.getUsername();
String password = registerBody.getPassword();
// 校验用户类型是否存在
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
// 注册用户信息
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPassword(BCrypt.hashpw(password));
sysUser.setUserType(userType);
boolean regFlag = remoteUserService.registerUserInfo(sysUser);
if (!regFlag) {
throw new UserException("user.register.error");
}
recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"));
}
use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysProfileController method updatePwd.
/**
* 重置密码
*/
@ApiOperation("重置密码")
@ApiImplicitParams({ @ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataTypeClass = String.class), @ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataTypeClass = String.class) })
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public R<Void> updatePwd(String oldPassword, String newPassword) {
SysUser user = userService.selectUserById(LoginHelper.getUserId());
String password = user.getPassword();
if (!BCrypt.checkpw(oldPassword, password)) {
return R.fail("修改密码失败,旧密码错误");
}
if (BCrypt.checkpw(newPassword, password)) {
return R.fail("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(user.getUserName(), BCrypt.hashpw(newPassword)) > 0) {
return R.ok();
}
return R.fail("修改密码异常,请联系管理员");
}
use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.
the class MultiService method multiServiceHandler.
/**
* 多服务调用
*/
@GlobalTransactional(rollbackFor = Exception.class)
@XxlJob("multiServiceHandler")
public void multiServiceHandler() throws Exception {
LoginUser admin = remoteUserService.getUserInfo("admin");
XxlJobHelper.log("XXL-JOB, multiServiceHandler result: {}", admin.toString());
SysUser sysUser = new SysUser();
sysUser.setUserName("test");
sysUser.setNickName("test");
remoteUserService.registerUserInfo(sysUser);
}
use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysUserImportListener method invoke.
@Override
public void invoke(SysUserImportVo userVo, AnalysisContext context) {
SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
try {
// 验证是否存在这个用户
if (ObjectUtil.isNull(user)) {
user = BeanUtil.toBean(userVo, SysUser.class);
ValidatorUtils.validate(user);
user.setPassword(password);
user.setCreateBy(operName);
userService.insertUser(user);
successNum++;
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
} else if (isUpdateSupport) {
ValidatorUtils.validate(user);
user.setUpdateBy(operName);
userService.updateUser(user);
successNum++;
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
failureMsg.append(msg).append(e.getMessage());
log.error(msg, e);
}
}
Aggregations