Search in sources :

Example 6 with RestResult

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;
}
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 7 with 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;
}
Also used : RestResult(com.qiwenshare.common.result.RestResult) UserLoginVo(com.qiwenshare.file.vo.user.UserLoginVo) UserBean(com.qiwenshare.file.domain.user.UserBean) HashMap(java.util.HashMap) SimpleHash(org.apache.shiro.crypto.hash.SimpleHash) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 8 with 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));
        }
    }
}
Also used : RestResult(com.qiwenshare.common.result.RestResult) UserLoginVo(com.qiwenshare.file.vo.user.UserLoginVo) JwtUser(com.qiwenshare.common.util.security.JwtUser) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Aggregations

RestResult (com.qiwenshare.common.result.RestResult)8 Operation (io.swagger.v3.oas.annotations.Operation)7 JwtUser (com.qiwenshare.common.util.security.JwtUser)6 UserFile (com.qiwenshare.file.domain.UserFile)4 JSONObject (com.alibaba.fastjson.JSONObject)3 NotLoginException (com.qiwenshare.common.exception.NotLoginException)3 IOException (java.io.IOException)3 FileModel (com.qiwenshare.file.util.FileModel)2 UserLoginVo (com.qiwenshare.file.vo.user.UserLoginVo)2 MyLog (com.qiwenshare.common.anno.MyLog)1 FileBean (com.qiwenshare.file.domain.FileBean)1 Notice (com.qiwenshare.file.domain.Notice)1 UserBean (com.qiwenshare.file.domain.user.UserBean)1 TreeNode (com.qiwenshare.file.util.TreeNode)1 RecoveryFileListVo (com.qiwenshare.file.vo.file.RecoveryFileListVo)1 Copier (com.qiwenshare.ufop.operation.copy.Copier)1 CopyFile (com.qiwenshare.ufop.operation.copy.domain.CopyFile)1 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1