Search in sources :

Example 16 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class RecoveryFileController method restoreFile.

@Operation(summary = "还原文件", description = "还原文件", tags = { "recoveryfile" })
@RequestMapping(value = "/restorefile", method = RequestMethod.POST)
@MyLog(operation = "还原文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult restoreFile(@RequestBody RestoreFileDTO restoreFileDto) {
    JwtUser sessionUserBean = SessionUtil.getSession();
    recoveryFileService.restorefile(restoreFileDto.getDeleteBatchNum(), restoreFileDto.getFilePath(), sessionUserBean.getUserId());
    return RestResult.success().message("还原成功!");
}
Also used : JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 17 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class RecoveryFileController method getRecoveryFileList.

@Operation(summary = "回收文件列表", description = "回收文件列表", tags = { "recoveryfile" })
@RequestMapping(value = "/list", method = RequestMethod.POST)
@ResponseBody
public RestResult<List<RecoveryFileListVo>> getRecoveryFileList() {
    JwtUser sessionUserBean = SessionUtil.getSession();
    RestResult<List<RecoveryFileListVo>> restResult = new RestResult<List<RecoveryFileListVo>>();
    List<RecoveryFileListVo> recoveryFileList = recoveryFileService.selectRecoveryFileList(sessionUserBean.getUserId());
    restResult.setData(recoveryFileList);
    restResult.setSuccess(true);
    return restResult;
}
Also used : RestResult(com.qiwenshare.common.result.RestResult) JwtUser(com.qiwenshare.common.util.security.JwtUser) List(java.util.List) RecoveryFileListVo(com.qiwenshare.file.vo.file.RecoveryFileListVo) Operation(io.swagger.v3.oas.annotations.Operation)

Example 18 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class UserController method checkUserLoginInfo.

@Operation(summary = "检查用户登录信息", description = "验证token的有效性", tags = { "user" })
@GetMapping("/checkuserlogininfo")
@ResponseBody
public RestResult<UserLoginVo> checkUserLoginInfo() {
    UserLoginVo userLoginVo = new UserLoginVo();
    JwtUser sessionUserBean = SessionUtil.getSession();
    if (sessionUserBean != null && !"anonymousUser".equals(sessionUserBean.getUsername())) {
        LambdaQueryWrapper<UserLoginInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UserLoginInfo::getUserId, sessionUserBean.getUserId());
        lambdaQueryWrapper.likeRight(UserLoginInfo::getUserloginDate, DateUtil.getCurrentTime().substring(0, 10));
        userLoginInfoService.remove(lambdaQueryWrapper);
        UserLoginInfo userLoginInfo = new UserLoginInfo();
        userLoginInfo.setUserId(sessionUserBean.getUserId());
        userLoginInfo.setUserloginDate(DateUtil.getCurrentTime());
        userLoginInfoService.save(userLoginInfo);
        UserBean user = userService.getById(sessionUserBean.getUserId());
        BeanUtil.copyProperties(user, userLoginVo);
        return RestResult.success().data(userLoginVo);
    } else {
        return RestResult.fail().message("用户暂未登录");
    }
}
Also used : UserLoginVo(com.qiwenshare.file.vo.user.UserLoginVo) UserBean(com.qiwenshare.file.domain.user.UserBean) JwtUser(com.qiwenshare.common.util.security.JwtUser) UserLoginInfo(com.qiwenshare.file.domain.UserLoginInfo) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Operation(io.swagger.v3.oas.annotations.Operation)

Example 19 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class UserFileService method userFileList.

@Override
public IPage<FileListVo> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {
    Page<FileListVo> page = new Page<>(currentPage, pageCount);
    UserFile userFile = new UserFile();
    JwtUser sessionUserBean = SessionUtil.getSession();
    if (userId == null) {
        userFile.setUserId(sessionUserBean.getUserId());
    } else {
        userFile.setUserId(userId);
    }
    userFile.setFilePath(UFOPUtils.urlDecode(filePath));
    return userFileMapper.selectPageVo(page, userFile, null);
}
Also used : UserFile(com.qiwenshare.file.domain.UserFile) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) JwtUser(com.qiwenshare.common.util.security.JwtUser) FileListVo(com.qiwenshare.file.vo.file.FileListVo)

Example 20 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class UserService method loadUserByUsername.

@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
    UserBean user = userMapper.selectById(Long.valueOf(s));
    if (user == null) {
        throw new UsernameNotFoundException(String.format("用户不存在"));
    }
    List<Role> roleList = selectRoleListByUserId(user.getUserId());
    List<SimpleGrantedAuthority> authorities = new ArrayList<>();
    for (Role role : roleList) {
        SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority("ROLE_" + role.getRoleName());
        authorities.add(simpleGrantedAuthority);
    }
    JwtUser jwtUser = new JwtUser(user.getUserId(), user.getUsername(), user.getPassword(), user.getAvailable(), authorities);
    return jwtUser;
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) Role(com.qiwenshare.file.domain.user.Role) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) UserBean(com.qiwenshare.file.domain.user.UserBean) ArrayList(java.util.ArrayList) JwtUser(com.qiwenshare.common.util.security.JwtUser)

Aggregations

JwtUser (com.qiwenshare.common.util.security.JwtUser)30 Operation (io.swagger.v3.oas.annotations.Operation)26 MyLog (com.qiwenshare.common.anno.MyLog)16 UserFile (com.qiwenshare.file.domain.UserFile)13 RestResult (com.qiwenshare.common.result.RestResult)6 IOException (java.io.IOException)4 JSONObject (com.alibaba.fastjson.JSONObject)3 NotLoginException (com.qiwenshare.common.exception.NotLoginException)3 UploadFileVo (com.qiwenshare.file.vo.file.UploadFileVo)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 FileBean (com.qiwenshare.file.domain.FileBean)2 RecoveryFile (com.qiwenshare.file.domain.RecoveryFile)2 ShareFile (com.qiwenshare.file.domain.ShareFile)2 UserBean (com.qiwenshare.file.domain.user.UserBean)2 FileModel (com.qiwenshare.file.util.FileModel)2 FileListVo (com.qiwenshare.file.vo.file.FileListVo)2 UserLoginVo (com.qiwenshare.file.vo.user.UserLoginVo)2 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1