-
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.
- Loading branch information
1 parent
8ea4621
commit 6ca0bd1
Showing
6 changed files
with
195 additions
and
1 deletion.
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/in/koreatech/koin/domain/coop/dto/ExcelResponseBuilder.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,26 @@ | ||
package in.koreatech.koin.domain.coop.dto; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.time.LocalDate; | ||
|
||
import org.springframework.core.io.InputStreamResource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
public class ExcelResponseBuilder { | ||
|
||
public static ResponseEntity<InputStreamResource> buildExcelResponse( | ||
ByteArrayInputStream excelFile, LocalDate startDate, LocalDate endDate | ||
) { | ||
String fileName = startDate.toString() + " ~ " + endDate.toString() + " menu.xlsx"; | ||
|
||
HttpHeaders headers = new HttpHeaders(); | ||
headers.add("Content-Disposition", "attachment; filename=" + fileName); | ||
|
||
return ResponseEntity.ok() | ||
.headers(headers) | ||
.contentType(MediaType.APPLICATION_OCTET_STREAM) | ||
.body(new InputStreamResource(excelFile)); | ||
} | ||
} |
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