Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ dependencies {
// 이미지 EXIF 메타데이터(GPS 등) 판독 - 위험도 분석의 메타데이터 노출 항목에 사용
implementation 'com.drewnoakes:metadata-extractor:2.21.0'

// 신고 문서(PDF) 생성. 2.0.x 계열(보안 수정이 이어지는 안정판)을 쓰고, 로깅은 Spring의 spring-jcl이 맡는다.
implementation('org.apache.pdfbox:pdfbox:2.0.32') {
exclude group: 'commons-logging', module: 'commons-logging'
}

// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.signal.domain.agency.entity.ConnectionType;
import com.signal.domain.agency.repository.AgencyConnectionRepository;
import com.signal.domain.agency.repository.AgencyRepository;
import com.signal.domain.report.entity.Report;
import com.signal.domain.report.service.ReportDocuments;
import com.signal.domain.report.service.ReportService;
import com.signal.global.exception.ErrorCode;
import com.signal.global.exception.SignalException;
Expand Down Expand Up @@ -42,8 +42,8 @@ public AgencyConnection createConnection(Long userId, Long agencyId, Long report

String attachedReportUrl = null;
if (reportId != null) {
Report report = reportService.getReport(userId, reportId);
attachedReportUrl = report.getDocumentUrl();
reportService.getReport(userId, reportId); // 본인 신고서인지 확인
attachedReportUrl = ReportDocuments.pathFor(reportId);
}

AgencyConnection connection = AgencyConnection.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import com.signal.domain.report.service.ReportService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.CacheControl;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -81,6 +84,20 @@ public ResponseEntity<ReportResponse> updateReport(
return ResponseEntity.ok(ReportResponse.from(report));
}

/** 신고 문서(PDF). 파일로 저장하지 않고 요청할 때 신고서 내용으로 만든다. */
@GetMapping("/{reportId}/document")
public ResponseEntity<byte[]> getDocument(
@AuthenticationPrincipal Long userId,
@PathVariable Long reportId) {
byte[] pdf = reportService.renderDocument(userId, reportId);
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_PDF)
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment()
.filename("signal-report-" + reportId + ".pdf").build().toString())
.cacheControl(CacheControl.noStore())
.body(pdf);
}

@PostMapping("/{reportId}/finalize")
public ResponseEntity<ReportStatusResponse> finalizeReport(
@AuthenticationPrincipal Long userId,
Expand Down
Loading
Loading