智慧保安后台管理-外网项目备份
zhongrj
2023-09-17 8853292babb2ad94de4a3207966f1e83b767cd2d
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -181,6 +181,7 @@
   @PostMapping("/put-file")
   public R<BladeFile> putFile(@RequestParam MultipartFile file) {
      BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream());
      bladeFile.setLink(bladeFile.getLink().replace("127.0.0.1","60.220.177.113"));
      return R.data(bladeFile);
   }
@@ -194,10 +195,10 @@
   @PostMapping("/put-file-user-avatar")
   public R putFileUserAvatar(@RequestParam MultipartFile file) {
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -225,10 +226,10 @@
            in, in.available(), -1)
            .headers(headers)
            .build());
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//      InputStream inputStream = file.getInputStream();
//      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://61.131.136.25:2081/zhba/" + newName;
      String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
      //数据封装
      Map<String, Object> map = new HashMap<>(2);
      map.put("name", newName);
@@ -246,10 +247,10 @@
   @PostMapping("put-file-app")
   public R putFileApp(@RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException {
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -277,10 +278,10 @@
            in, in.available(), -1)
            .headers(headers)
            .build());
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//      InputStream inputStream = file.getInputStream();
//      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://61.131.136.25:2081/zhba/" + newName;
      String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
      return R.data(urls);
   }
@@ -293,10 +294,10 @@
   @PostMapping("put-files")
   public R putFiles(@RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException {
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -324,10 +325,10 @@
            in, in.available(), -1)
            .headers(headers)
            .build());
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//      InputStream inputStream = file.getInputStream();
//      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://61.131.136.25:2081/zhba/" + newName;
      String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
      //数据封装
      Map<String, Object> map = new HashMap<>(2);
      map.put("name", newName);
@@ -346,10 +347,10 @@
   public R putFileZip(@RequestParam MultipartFile file) throws Exception {
      Map<String, Object> map = new HashMap<>(1);
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -367,8 +368,6 @@
      String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.US);
      //判断文件是不是zip类型
      if(!fileType.equals("zip")){
//         map.put("data","上传文件类型不符!");
//         return R.data(map);
         throw new ServiceException("上传文件类型不符!必须是 zip 压缩文件格式!");
      }
      //FileConfig.localtion是配置文件和config类生产的,测试demo可以直接把FileConfig.localtion替换成D:/test
@@ -402,7 +401,6 @@
            String idCardNo = compile.matcher(pictrueName).replaceAll("");
            //加入集合
            errorList.add(idCardNo);
         }
         if(multipartFile.getName().toLowerCase().endsWith(".png") || multipartFile.getName().toLowerCase().endsWith(".jpg")) {
            String newName = "upload/picture/" + UUID.randomUUID().toString().replaceAll("-", "") + multipartFile.getName().substring(multipartFile.getName().lastIndexOf("."));
@@ -419,7 +417,7 @@
                  .headers(headers)
                  .build());
            String urls = "http://61.131.136.25:2081/zhba/" + newName;
            String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
            //内网
            String inUrl = FtpConfig.ip + "/zhba/" + newName;
            //取出身份证号,查询用户信息,更新用户信息
@@ -437,13 +435,15 @@
               //内网数据推送
               //数据推送
               String s = "update blade_user set avatar = " + "'" + inUrl + "'" + "where id = " + "'" + user.getId() + "'";
               String s = "update blade_user set avatar = " + "'" + inUrl +
                  ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'" +
                  "'" + "where id = " + "'" + user.getId() + "'";
               //FtpUtil.sqlFileUpload(s);
               myAsyncService.FTP(s);
               myAsyncService.dataSync(s);
               //文件推送
               InputStream inputStream = multipartFile.getInputStream();
               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//               InputStream inputStream = multipartFile.getInputStream();
//               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               in.close();
            }
         }
@@ -471,10 +471,10 @@
   public R putFileExamPaymentZip(@RequestParam MultipartFile file) throws Exception {
      Map<String, Object> map = new HashMap<>(1);
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -525,7 +525,7 @@
                  .headers(headers)
                  .build());
            String urls = "http://61.131.136.25:2081/zhba/" + newName;
            String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
            //内网
            String inUrl = FtpConfig.ip +"/zhba/"+ newName;
            //取出身份证号,查询用户信息,更新用户信息
@@ -562,11 +562,11 @@
                  "," + "'" + examPayment.getPaymentStatus() + "'" +
                  "," +"'" + inUrl + "'" + ")";
               //FtpUtil.sqlFileUpload(s);
               myAsyncService.FTP(s);
               myAsyncService.dataSync(s);
               //文件推送
               InputStream inputStream = multipartFile.getInputStream();
               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//               InputStream inputStream = multipartFile.getInputStream();
//               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               in.close();
            }
         }
@@ -589,10 +589,10 @@
   @PostMapping("put-files-talk")
   public R putFilestak(@RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException {
      //填写你文件上传的地址以及相应信息
      String url = "http://61.131.136.25:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.apiUrl;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -622,10 +622,10 @@
            .build());
      //文件推送
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//      InputStream inputStream = file.getInputStream();
//      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://61.131.136.25:2081/zhba/" + newName;
      String urls = FileConfig.url + "/"+ FileConfig.bucket + "/" + newName;
      //数据封装
      Map<String, Object> map = new HashMap<>(2);
      map.put("name", newName);
@@ -759,7 +759,7 @@
         s1 += ")";
      }
      //FtpUtil.sqlFileUpload(s1);
      myAsyncService.FTP(s1);
      myAsyncService.dataSync(s1);
      return attach.getId();
   }