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("还原成功!");
}
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;
}
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("用户暂未登录");
}
}
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);
}
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;
}
Aggregations