Search in sources :

Example 1 with Log

use of com.ruoyi.framework.aspectj.lang.annotation.Log in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysProfileController method updatePwd.

/**
 * 重置密码
 */
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) {
    LoginUser loginUser = getLoginUser();
    String userName = loginUser.getUsername();
    String password = loginUser.getPassword();
    if (!SecurityUtils.matchesPassword(oldPassword, password)) {
        return AjaxResult.error("修改密码失败,旧密码错误");
    }
    if (SecurityUtils.matchesPassword(newPassword, password)) {
        return AjaxResult.error("新密码不能与旧密码相同");
    }
    if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
        // 更新缓存用户密码
        loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
        tokenService.setLoginUser(loginUser);
        return AjaxResult.success();
    }
    return AjaxResult.error("修改密码异常,请联系管理员");
}
Also used : LoginUser(com.ruoyi.framework.security.LoginUser) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 2 with Log

use of com.ruoyi.framework.aspectj.lang.annotation.Log in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysProfileController method updateProfile.

/**
 * 修改用户
 */
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user) {
    LoginUser loginUser = getLoginUser();
    SysUser sysUser = loginUser.getUser();
    user.setUserName(sysUser.getUserName());
    if (StringUtils.isNotEmpty(user.getPhonenumber()) && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
        return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
    }
    if (StringUtils.isNotEmpty(user.getEmail()) && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
        return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
    }
    user.setUserId(sysUser.getUserId());
    user.setPassword(null);
    if (userService.updateUserProfile(user) > 0) {
        // 更新缓存用户信息
        sysUser.setNickName(user.getNickName());
        sysUser.setPhonenumber(user.getPhonenumber());
        sysUser.setEmail(user.getEmail());
        sysUser.setSex(user.getSex());
        tokenService.setLoginUser(loginUser);
        return AjaxResult.success();
    }
    return AjaxResult.error("修改个人信息异常,请联系管理员");
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser) LoginUser(com.ruoyi.framework.security.LoginUser) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 3 with Log

use of com.ruoyi.framework.aspectj.lang.annotation.Log in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysRoleController method edit.

/**
 * 修改保存角色
 */
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysRole role) {
    roleService.checkRoleAllowed(role);
    roleService.checkRoleDataScope(role.getRoleId());
    if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
        return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
    } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
        return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
    }
    role.setUpdateBy(getUsername());
    if (roleService.updateRole(role) > 0) {
        // 更新缓存用户权限
        LoginUser loginUser = getLoginUser();
        if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
            loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
            loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
            tokenService.setLoginUser(loginUser);
        }
        return AjaxResult.success();
    }
    return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
Also used : LoginUser(com.ruoyi.framework.security.LoginUser) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with Log

use of com.ruoyi.framework.aspectj.lang.annotation.Log in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysJobController method changeStatus.

/**
 * 定时任务状态修改
 */
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException {
    SysJob newJob = jobService.selectJobById(job.getJobId());
    newJob.setStatus(job.getStatus());
    return toAjax(jobService.changeStatus(newJob));
}
Also used : SysJob(com.ruoyi.project.monitor.domain.SysJob) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with Log

use of com.ruoyi.framework.aspectj.lang.annotation.Log in project RuoYi-Vue-fast by yangzongzhuan.

the class SysJobController method changeStatus.

/**
 * 定时任务状态修改
 */
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException {
    SysJob newJob = jobService.selectJobById(job.getJobId());
    newJob.setStatus(job.getStatus());
    return toAjax(jobService.changeStatus(newJob));
}
Also used : SysJob(com.ruoyi.project.monitor.domain.SysJob) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Log (com.ruoyi.framework.aspectj.lang.annotation.Log)10 LoginUser (com.ruoyi.framework.security.LoginUser)8 PutMapping (org.springframework.web.bind.annotation.PutMapping)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 AjaxResult (com.ruoyi.framework.web.domain.AjaxResult)2 SysJob (com.ruoyi.project.monitor.domain.SysJob)2 SysUser (com.ruoyi.project.system.domain.SysUser)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2