-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
컨설팅 결과 PDF로 변환
- Loading branch information
Showing
8 changed files
with
97 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 3 additions & 9 deletions
12
src/main/java/com/swOnCampus/AIPlatform/domain/report/service/ReportService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
package com.swOnCampus.AIPlatform.domain.report.service; | ||
|
||
import com.swOnCampus.AIPlatform.domain.report.web.dto.ReportingSummaryRequest; | ||
import com.swOnCampus.AIPlatform.domain.report.web.dto.ReportingResponse; | ||
|
||
public interface ReportService { | ||
|
||
/** | ||
* 리포팅 요약된 내용을 html로 변환 하여 pdf를 생성하는 메서드 | ||
* | ||
* @param request : 리포팅 요약 데이터를 담은 request 객체 | ||
* @return : 생성된 PDF 파일의 바이트 배열 | ||
*/ | ||
byte[] createReportingSummaryPdf(ReportingSummaryRequest request); | ||
} | ||
ReportingResponse createReportingPdf(Long memberId, Long companyId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 39 additions & 16 deletions
55
src/main/java/com/swOnCampus/AIPlatform/domain/report/web/controller/ReportController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,59 @@ | ||
package com.swOnCampus.AIPlatform.domain.report.web.controller; | ||
|
||
import com.swOnCampus.AIPlatform.domain.member.entity.Member; | ||
import com.swOnCampus.AIPlatform.domain.report.service.ReportService; | ||
import com.swOnCampus.AIPlatform.domain.report.web.dto.ReportingSummaryRequest; | ||
import com.swOnCampus.AIPlatform.domain.report.web.dto.ReportingResponse; | ||
import com.swOnCampus.AIPlatform.global.annotation.LoginMember; | ||
import com.swOnCampus.AIPlatform.global.response.ApiResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "컨설팅 PDF 생성 API", description = "컨설팅 결과 PDF 생성 관련 API") | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/v1/report") | ||
public class ReportController { | ||
|
||
private final ReportService reportService; | ||
|
||
@Operation(summary = "컨설팅 PDF API 요청", description = "컨설팅 결과 PDF 생성 API 요청") | ||
@ApiResponses(value = { | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse( | ||
responseCode = "COMMON200", | ||
description = "요청 성공", | ||
content = { | ||
@Content( | ||
schema = @Schema( | ||
implementation = ReportingResponse.class | ||
) | ||
) | ||
} | ||
) | ||
}) | ||
@GetMapping() | ||
public ResponseEntity<byte[]> createReportingSummaryPdf(Model model) { | ||
model.addAttribute("title", "리포팅 요약"); | ||
model.addAttribute("content", "내용"); | ||
public ResponseEntity<ApiResponse<?>> createReportingPdf( | ||
@LoginMember Member member, | ||
@RequestParam Long companyId // 채팅방 id | ||
) { | ||
ReportingResponse reportingResponse = reportService.createReportingPdf( | ||
member.getMemberId(), companyId); | ||
|
||
ReportingSummaryRequest request = ReportingSummaryRequest.builder() | ||
.title(model.getAttribute("title").toString()) | ||
.content(model.getAttribute("content").toString()) | ||
.build(); | ||
ApiResponse<ReportingResponse> response = ApiResponse.createSuccess( | ||
HttpStatus.OK.value(), | ||
reportingResponse, | ||
"PDF 파일이 생성되었습니다." | ||
); | ||
|
||
byte[] pdfData = reportService.createReportingSummaryPdf(request); | ||
|
||
return ResponseEntity.ok() | ||
.contentType(MediaType.APPLICATION_PDF) | ||
.body(pdfData); | ||
return ResponseEntity.ok(response); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/swOnCampus/AIPlatform/domain/report/web/dto/ReportingResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.swOnCampus.AIPlatform.domain.report.web.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ReportingResponse( | ||
@Schema(description = "컨설팅 요약 내용", example = "컨설팅 요약") | ||
String summary, | ||
@Schema(description = "컨설팅 전체 내용 PDF 파일의 Base64 인코딩 데이터", example = "byte") | ||
String pdf | ||
) { | ||
|
||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/com/swOnCampus/AIPlatform/domain/report/web/dto/ReportingSummaryRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters