Search in sources :

Example 11 with Log

use of com.ruoyi.common.log.annotation.Log in project RuoYi-Cloud by yangzongzhuan.

the class SysProfileController method updatePwd.

/**
 * 重置密码
 */
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) {
    String username = SecurityUtils.getUsername();
    SysUser user = userService.selectUserByUserName(username);
    String password = user.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 loginUser = SecurityUtils.getLoginUser();
        loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
        tokenService.setLoginUser(loginUser);
        return AjaxResult.success();
    }
    return AjaxResult.error("修改密码异常,请联系管理员");
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) LoginUser(com.ruoyi.system.api.model.LoginUser) Log(com.ruoyi.common.log.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 12 with Log

use of com.ruoyi.common.log.annotation.Log in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysOssController method upload.

/**
 * 上传OSS对象存储
 */
@ApiOperation("上传OSS对象存储")
@ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true) })
@SaCheckPermission("system:oss:upload")
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
@PostMapping("/upload")
public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
    if (ObjectUtil.isNull(file)) {
        throw new ServiceException("上传文件不能为空");
    }
    SysOss oss = iSysOssService.upload(file);
    Map<String, String> map = new HashMap<>(2);
    map.put("url", oss.getUrl());
    map.put("fileName", oss.getOriginalName());
    map.put("ossId", oss.getOssId().toString());
    return R.ok(map);
}
Also used : SysOss(com.ruoyi.resource.domain.SysOss) ServiceException(com.ruoyi.common.core.exception.ServiceException) HashMap(java.util.HashMap) Log(com.ruoyi.common.log.annotation.Log) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 13 with Log

use of com.ruoyi.common.log.annotation.Log in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysUserController method export.

@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:user:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user) {
    List<SysUser> list = userService.selectUserList(user);
    List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
    for (int i = 0; i < list.size(); i++) {
        SysDept dept = list.get(i).getDept();
        SysUserExportVo vo = listVo.get(i);
        if (ObjectUtil.isNotEmpty(dept)) {
            vo.setDeptName(dept.getDeptName());
            vo.setLeader(dept.getLeader());
        }
    }
    ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) SysDept(com.ruoyi.system.api.domain.SysDept) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) Log(com.ruoyi.common.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Aggregations

Log (com.ruoyi.common.log.annotation.Log)13 LoginUser (com.ruoyi.system.api.model.LoginUser)7 SysUser (com.ruoyi.system.api.domain.SysUser)6 PutMapping (org.springframework.web.bind.annotation.PutMapping)6 ApiOperation (io.swagger.annotations.ApiOperation)4 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)3 AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)2 RequiresPermissions (com.ruoyi.common.security.annotation.RequiresPermissions)2 SysJob (com.ruoyi.job.domain.SysJob)2 SysFile (com.ruoyi.system.api.domain.SysFile)2 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)2 HashMap (java.util.HashMap)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ServiceException (com.ruoyi.common.core.exception.ServiceException)1 SysFile (com.ruoyi.resource.api.domain.SysFile)1 SysOss (com.ruoyi.resource.domain.SysOss)1 SysDept (com.ruoyi.system.api.domain.SysDept)1 SysUserExportVo (com.ruoyi.system.domain.vo.SysUserExportVo)1 GlobalTransactional (io.seata.spring.annotation.GlobalTransactional)1