use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.
the class SysLoginController method getInfo.
/**
* 获取用户信息
*
* @return 用户信息
*/
@ApiOperation("获取用户信息")
@GetMapping("getInfo")
public R<Map<String, Object>> getInfo() {
SysUser user = userService.selectUserById(LoginHelper.getUserId());
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
Map<String, Object> ajax = new HashMap<>();
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return R.ok(ajax);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.
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);
}
List<Long> ids = Arrays.asList(userIds);
// 删除用户与角色关联
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
// 删除用户与岗位表
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
return baseMapper.deleteBatchIds(ids);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.
the class SysRegisterService method register.
/**
* 注册
*/
public void register(RegisterBody registerBody) {
HttpServletRequest request = ServletUtils.getRequest();
String username = registerBody.getUsername();
String password = registerBody.getPassword();
// 校验用户类型是否存在
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
boolean captchaOnOff = configService.selectCaptchaOnOff();
// 验证码开关
if (captchaOnOff) {
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid(), request);
}
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
throw new UserException("user.register.save.error", username);
}
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPassword(BCrypt.hashpw(password));
sysUser.setUserType(userType);
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag) {
throw new UserException("user.register.error");
}
asyncService.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"), request);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-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);
}
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Flowable-Plus by KonBAI-Q.
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 userName = user.getUserName();
String password = user.getPassword();
if (!BCrypt.checkpw(oldPassword, password)) {
return R.fail("修改密码失败,旧密码错误");
}
if (BCrypt.checkpw(newPassword, password)) {
return R.fail("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, BCrypt.hashpw(newPassword)) > 0) {
return R.ok();
}
return R.fail("修改密码异常,请联系管理员");
}
Aggregations