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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ dependencies {
// Apache POI의 XWPF(XML Word Processing Format)
implementation 'org.apache.poi:poi-ooxml:5.2.5'

//thymeleaf
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

// audio encoder
implementation "ws.schild:jave-all-deps:3.5.0"

}

dependencyManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class UserDocumentLastOpened {
@Column(name = "last_opened")
private LocalDateTime lastOpened;

@Column(columnDefinition = "TEXT")
private String thumbnailKeyName;

public void updateLastOpened(LocalDateTime lastOpened) {
this.lastOpened = lastOpened;
}
Expand All @@ -48,4 +51,8 @@ public void updateTitle(String title) {
this.title = title;
}

public void updateThumbnailKeyName(String thumbnailKeyName) {
this.thumbnailKeyName = thumbnailKeyName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,30 +131,30 @@ public ApiResponse<SnsEventResponseDTO.GetSnsEventRequest> getSnsEvent(
" 참여자 및 당첨자 리스트 다운로드 API입니다. Header에 access token을 넣고 Path Variable에는 snsEventId를 넣어 요청해주세요. Query String에는 다운로드 형식을 넣어주시고 다운로드 형식이 docx라면 리스트의 HTML을 Request Body에 넣어주세요."
)
@PostMapping("/{snsEventId}/list/download")
public ResponseEntity<byte[]> downloadList(
public ApiResponse<SnsEventResponseDTO.ListDownLoadLinkResponse> downloadList(
@PathVariable String snsEventId,
@RequestParam ListType listType,
@RequestParam Format format,
@RequestBody SnsEventRequestDTO.DownloadListRequest request
@RequestParam Format format
) {
Long userId = SecurityUtil.getCurrentUserId();
byte[] fileBytes = snsEventCommandService.downloadList(
userId,
Long.parseLong(snsEventId),
listType,
format,
request
return ApiResponse.onSuccess(
snsEventCommandService.downloadList(
userId,
Long.parseLong(snsEventId),
listType,
format
)
);

String listTypefileName = listType == ListType.PARTICIPANT ? "참여자" : "당첨자";
String filename = format == Format.PDF ? listTypefileName + ".pdf" : listTypefileName + ".docx";
String contentType = format == Format.PDF
? MediaType.APPLICATION_PDF_VALUE
: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";

return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
.contentType(MediaType.parseMediaType(contentType))
.body(fileBytes);
// String listTypefileName = listType == ListType.PARTICIPANT ? "참여자" : "당첨자";
// String filename = format == Format.PDF ? listTypefileName + ".pdf" : listTypefileName + ".docx";
// String contentType = format == Format.PDF
// ? MediaType.APPLICATION_PDF_VALUE
// : "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
//
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
// .contentType(MediaType.parseMediaType(contentType))
// .body(fileBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ public static class SnsCondition {
public static class UpdateSnsEventRequest {
private String title;
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class DownloadListRequest {
private String listHtml;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,12 @@ public static class ParticipantResponse {
public static class WinnerResponse {
private String account;
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ListDownLoadLinkResponse {
private String downloadLink;
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/haru/api/domain/snsEvent/entity/SnsEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ public class SnsEvent extends BaseEntity {
@JoinColumn(name = "workspace_id")
private Workspace workspace;

@Column(columnDefinition = "TEXT")
private String keyNameParticipantPdf;

@Column(columnDefinition = "TEXT")
private String keyNameParticipantWord;

@Column(columnDefinition = "TEXT")
private String keyNameWinnerPdf;

@Column(columnDefinition = "TEXT")
private String keyNameWinnerWord;

@Column(columnDefinition = "TEXT")
private String thumbnailKey;

@OneToMany(mappedBy = "snsEvent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Participant> participantList = new ArrayList<>();

Expand All @@ -59,4 +74,19 @@ public void setWorkspace(Workspace workspace) {
public void updateTitle(String title) {
this.title = title;
}

public void updateKeyNameParticipantPdf(
String keyNameParticipantPdf,
String keyNameParicipantWord,
String keyNameWinnerPdf,
String keyNameWinnerWord) {
this.keyNameParticipantPdf = keyNameParticipantPdf;
this.keyNameParticipantWord = keyNameParicipantWord;
this.keyNameWinnerPdf = keyNameWinnerPdf;
this.keyNameWinnerWord = keyNameWinnerWord;
}

public void updateThumbnailKey(String thumbnailKey) {
this.thumbnailKey = thumbnailKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface SnsEventCommandService {

void deleteSnsEvent(Long userId, Long snsEventId);

byte[] downloadList(Long userId, Long snsEventId, ListType listType, Format format, SnsEventRequestDTO.DownloadListRequest request);
SnsEventResponseDTO.ListDownLoadLinkResponse downloadList(Long userId, Long snsEventId, ListType listType, Format format);
}
Loading