Search in sources :

Example 11 with SysUser

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);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with SysUser

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"));
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) UserException(com.ruoyi.common.core.exception.user.UserException)

Example 13 with SysUser

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("修改密码异常,请联系管理员");
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) Log(com.ruoyi.common.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 14 with SysUser

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);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) LoginUser(com.ruoyi.system.api.model.LoginUser) GlobalTransactional(io.seata.spring.annotation.GlobalTransactional) XxlJob(com.xxl.job.core.handler.annotation.XxlJob)

Example 15 with 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);
    }
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) ServiceException(com.ruoyi.common.core.exception.ServiceException)

Aggregations

SysUser (com.ruoyi.system.api.domain.SysUser)37 LoginUser (com.ruoyi.system.api.model.LoginUser)13 Log (com.ruoyi.common.log.annotation.Log)12 ServiceException (com.ruoyi.common.core.exception.ServiceException)10 GetMapping (org.springframework.web.bind.annotation.GetMapping)8 PutMapping (org.springframework.web.bind.annotation.PutMapping)8 UserConstants (com.ruoyi.common.core.constant.UserConstants)6 R (com.ruoyi.common.core.domain.R)6 StringUtils (com.ruoyi.common.core.utils.StringUtils)6 BaseController (com.ruoyi.common.core.web.controller.BaseController)6 AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)6 BusinessType (com.ruoyi.common.log.enums.BusinessType)6 InnerAuth (com.ruoyi.common.security.annotation.InnerAuth)6 SysRole (com.ruoyi.system.api.domain.SysRole)6 ISysPermissionService (com.ruoyi.system.service.ISysPermissionService)6 ISysPostService (com.ruoyi.system.service.ISysPostService)6 ISysRoleService (com.ruoyi.system.service.ISysRoleService)6 ISysUserService (com.ruoyi.system.service.ISysUserService)6 IOException (java.io.IOException)6 Collectors (java.util.stream.Collectors)6