use of com.qiwenshare.common.result.RestResult 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.result.RestResult in project qiwen-file by qiwenshare.
the class UserController method userLogin.
@Operation(summary = "用户登录", description = "用户登录认证后才能进入系统", tags = { "user" })
@GetMapping("/login")
@MyLog(operation = "用户登录", module = CURRENT_MODULE)
@ResponseBody
public RestResult<UserLoginVo> userLogin(@Parameter(description = "登录手机号") String telephone, @Parameter(description = "登录密码") String password) {
RestResult<UserLoginVo> restResult = new RestResult<UserLoginVo>();
String salt = userService.getSaltByTelephone(telephone);
String hashPassword = new SimpleHash("MD5", password, salt, 1024).toHex();
UserBean result = userService.selectUserByTelephoneAndPassword(telephone, hashPassword);
if (result == null) {
return RestResult.fail().message("手机号或密码错误!");
}
Map<String, Object> param = new HashMap<>();
param.put("userId", result.getUserId());
String token = "";
try {
token = jwtComp.createJWT(JSON.toJSONString(param));
} catch (Exception e) {
log.info("登录失败:{}", e);
return RestResult.fail().message("创建token失败!");
}
UserBean sessionUserBean = userService.findUserInfoByTelephone(telephone);
if (sessionUserBean.getAvailable() != null && sessionUserBean.getAvailable() == 0) {
return RestResult.fail().message("用户已被禁用");
}
UserLoginVo userLoginVo = new UserLoginVo();
BeanUtil.copyProperties(sessionUserBean, userLoginVo);
userLoginVo.setToken("Bearer " + token);
restResult.setData(userLoginVo);
restResult.setSuccess(true);
restResult.setCode(200001);
return restResult;
}
use of com.qiwenshare.common.result.RestResult in project qiwen-file by qiwenshare.
the class WebLogAcpect method doAfterReturning.
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable {
if (ret instanceof RestResult) {
boolean isSuccess = ((RestResult) ret).getSuccess();
String errorMessage = ((RestResult) ret).getMessage();
JwtUser sessionUser = SessionUtil.getSession();
Long userId = 0L;
if (sessionUser != null) {
userId = sessionUser.getUserId();
}
Integer code = ((RestResult) ret).getCode();
if (code != null && code == 200001) {
UserLoginVo data = (UserLoginVo) ((RestResult) ret).getData();
userId = data.getUserId();
}
if (isSuccess) {
operationLogService.insertOperationLog(OperationLogUtil.getOperationLogObj(request, userId, "成功", module, operation, "操作成功"));
} else {
operationLogService.insertOperationLog(OperationLogUtil.getOperationLogObj(request, userId, "失败", module, operation, errorMessage));
}
}
}
Aggregations