Commit cd8a5094 authored by 0Tyler's avatar 0Tyler

defaultData

parent de22d29d
This diff is collapsed.
...@@ -50,7 +50,7 @@ jar { ...@@ -50,7 +50,7 @@ jar {
enabled = true enabled = true
} }
bootJar { bootJar {
enabled = false enabled = true
classifier = 'boot' classifier = 'boot'
manifest { manifest {
attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.cloud.CloudApplication' attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.cloud.CloudApplication'
......
...@@ -5,6 +5,7 @@ import edu.prlab.tyler.iotgateway.cloud.services.DocumentService; ...@@ -5,6 +5,7 @@ import edu.prlab.tyler.iotgateway.cloud.services.DocumentService;
import edu.prlab.tyler.iotgateway.cloud.services.PrivacyPolicyReportService; import edu.prlab.tyler.iotgateway.cloud.services.PrivacyPolicyReportService;
import edu.prlab.tyler.iotgateway.cloud.util.CodeTools; import edu.prlab.tyler.iotgateway.cloud.util.CodeTools;
import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -35,15 +36,14 @@ public class DocumentController { ...@@ -35,15 +36,14 @@ public class DocumentController {
//透過裝置ID取得檔案 //透過裝置ID取得檔案
@GetMapping("/{udn}") @GetMapping("/{udn}")
public ResponseEntity<ByteArrayResource> findFile(@PathVariable String udn) { public ResponseEntity<Resource> findFile(@PathVariable String udn) {
return privacyPolicyReportService.readByDevice(udn) return privacyPolicyReportService.readByDevice(udn)
.map(privacyReport -> privacyReport.getDocument().getId()) .map(privacyReport -> privacyReport.getDocument().getId())
.flatMap(id -> documentService.readFile(id)) .flatMap(id -> documentService.readFile(id))
.map(document -> ResponseEntity.ok() .map(document -> ResponseEntity.ok()
.contentType(MediaType.parseMediaType(document.getFileType())) .contentType(MediaType.parseMediaType(document.getFileType()))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename* = UTF-8''" + CodeTools.encode(document.getFileName())) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename* = UTF-8''" + CodeTools.encode(document.getFileName()))
.body(new ByteArrayResource(document.getBytes()))) .body((Resource) new ByteArrayResource(document.getBytes())))
.orElseGet(() -> ResponseEntity.noContent().build()); .orElseGet(() -> ResponseEntity.noContent().build());
} }
} }
...@@ -46,7 +46,7 @@ jar { ...@@ -46,7 +46,7 @@ jar {
enabled = true enabled = true
} }
bootJar { bootJar {
enabled = false enabled = true
classifier = 'boot' classifier = 'boot'
manifest { manifest {
attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.gateway.GatewayApplication' attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.gateway.GatewayApplication'
......
...@@ -2,7 +2,6 @@ package edu.prlab.tyler.iotgateway.gateway.controllers; ...@@ -2,7 +2,6 @@ package edu.prlab.tyler.iotgateway.gateway.controllers;
import edu.prlab.tyler.iotgateway.cloud.pojo.device.Device; import edu.prlab.tyler.iotgateway.cloud.pojo.device.Device;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyChoice; import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyChoice;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyPolicyReport;
import edu.prlab.tyler.iotgateway.gateway.model.PrivacyChoiceResponse; import edu.prlab.tyler.iotgateway.gateway.model.PrivacyChoiceResponse;
import edu.prlab.tyler.iotgateway.gateway.model.PrivacyPolicyReportResponse; import edu.prlab.tyler.iotgateway.gateway.model.PrivacyPolicyReportResponse;
import edu.prlab.tyler.iotgateway.gateway.services.DeviceService; import edu.prlab.tyler.iotgateway.gateway.services.DeviceService;
......
...@@ -19,8 +19,6 @@ import java.util.HashMap; ...@@ -19,8 +19,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
@Service @Service
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment