管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-30 e5d341086b634f9ac0345b576e6497f978a53941
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -21,6 +21,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@@ -39,6 +42,8 @@
    @Autowired
    DownloadService downloadService;
    private final static String EQ = "=";
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
@@ -274,15 +279,62 @@
            if (null == reqEntity.getIds() || reqEntity.getIds().isEmpty()) {
                return fail("请选择要下载的文件");
            }
            if (!downloadService.validatePwd(reqEntity)) {
            if (!downloadService.decryptPwd(reqEntity)) {
                return fail("密码解密失败", null);
            }
            if (!StringHelper.checkPwdValid(reqEntity.getPwd())) {
                return fail("密码不符合要求");
            }
            List<MetaFileEntity> list = metaService.selectMetaFiles(reqEntity.getIds());
            if (null == list || list.isEmpty()) {
                return fail("没有找到元数据");
            }
            return success(true);
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd());
            return success(guid);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "pwd", value = "密码", dataType = "String", paramType = "query")
    })
    @GetMapping(value = "/selectDownloadFile")
    public ResponseMsg<Boolean> selectDownloadFile(String guid, String pwd) {
        try {
            if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) {
                return fail("文件ID和密码不能为空", null);
            }
            if (!pwd.endsWith(EQ)) {
                pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name());
            }
            String password = downloadService.decryptPwd(pwd);
            if (null == password) {
                return fail("密码解密失败", null);
            }
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (null == de) {
                return fail("文件不存在", null);
            }
            if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) {
                return fail("密码不正确", null);
            }
            String filePath = downloadService.getDownloadFilePath(de);
            File file = new File(filePath);
            return success(file.exists());
        } catch (Exception ex) {
            return fail(ex.getMessage(), false);
        }
    }
@@ -299,6 +351,9 @@
            if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "文件ID和密码不能为空", res);
            }
            if (!pwd.endsWith(EQ)) {
                pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name());
            }
            String password = downloadService.decryptPwd(pwd);
            if (null == password) {