Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#119 마일스톤 목록 데이터를 엑셀 파일로 다운로드하는 기능 #146

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
25 changes: 25 additions & 0 deletions backend/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,26 @@ include::{snippets}/milestone-history-cancel/http-response.adoc[]
.HTTP Request
include::{snippets}/milestone-history-find-all/http-request.adoc[]

.Path Parameters
include::{snippets}/milestone-history-find-all/query-parameters.adoc[]

.HTTP Response
include::{snippets}/milestone-history-find-all/http-response.adoc[]

.Response Body
include::{snippets}/milestone-history-find-all/response-fields.adoc[]

=== `GET` 전체 마일스톤 실적 목록 엑셀 파일로 다운로드

.HTTP Request
include::{snippets}/download-history-file/http-request.adoc[]

.Path Parameters
include::{snippets}/download-history-file/query-parameters.adoc[]

.HTTP Response
include::{snippets}/download-history-file/http-response.adoc[]

=== `GET` 전체 마일스톤 실적 단건 조회

.HTTP Request
Expand Down Expand Up @@ -207,3 +221,14 @@ include::{snippets}/milestone-history-score-find-all/http-response.adoc[]

.Response Body
include::{snippets}/milestone-history-score-find-all/response-fields.adoc[]

=== `GET` 전체 마일스톤 점수 목록 엑셀 파일로 다운로드

.HTTP Request
include::{snippets}/download-score-file/http-request.adoc[]

.Path Parameters
include::{snippets}/download-score-file/query-parameters.adoc[]

.HTTP Response
include::{snippets}/download-score-file/http-response.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import jakarta.validation.Valid;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -41,6 +45,21 @@ public ResponseEntity<Page<MilestoneHistoryResponse>> findAllMilestoneHistory(
return ResponseEntity.ok(milestoneHistoryAdminQueryService.findAllMilestoneHistories(field, keyword, pageable));
}

@GetMapping("/files")
public ResponseEntity<byte[]> downloadAllMilestoneHistoryExcelFile(
@RequestParam(value = "field", required = false) final Integer field,
@RequestParam(value = "keyword", required = false) final String keyword
) {
String filename = "마일스톤_내역_목록.xlsx";
String encodedFilename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + encodedFilename + "\"; filename*=UTF-8''" + encodedFilename)

.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(milestoneHistoryAdminQueryService.downloadMilestoneHistory(field, keyword));
}

@GetMapping("/{historyId}")
public ResponseEntity<MilestoneHistoryResponse> findAllMilestoneHistory(
@PathVariable("historyId") final Long historyId) {
Expand Down Expand Up @@ -81,4 +100,17 @@ public ResponseEntity<Page<MilestoneScoreResponse>> findAllMilestoneHistoryScore
return ResponseEntity.ok(
milestoneHistoryAdminQueryService.findAllMilestoneHistoryScores(startDate, endDate, pageable));
}

@GetMapping("/scores/files")
public ResponseEntity<byte[]> downloadMilestoneHistoryScoreExcelFile(
@RequestParam(value = "start_date") final String startDate,
@RequestParam(value = "end_date") final String endDate) {
String filename = "마일스톤_점수_현황.xlsx";
String encodedFilename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + encodedFilename + "\"; filename*=UTF-8''" + encodedFilename)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(milestoneHistoryAdminQueryService.downloadMilestoneHistoryScore(startDate, endDate));
}
}
Loading