Skip to content

Commit b8586eb

Browse files
authored
6차 배포 (#159)
2 parents 709dfec + 0c8b4b3 commit b8586eb

13 files changed

Lines changed: 136 additions & 91 deletions

File tree

src/main/java/umc/codeplay/controller/AuthController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ public ApiResponse<MemberResponseDTO.LoginResultDTO> login(
6868
String token = jwtUtil.generateToken(authentication.getName(), authorities);
6969
String refreshToken =
7070
jwtUtil.generateRefreshToken(authentication.getName(), authorities);
71+
String profileImage = memberService.getMemberProfileImage(request.getEmail());
72+
7173
return ApiResponse.onSuccess(
7274
MemberConverter.toLoginResultDTO(
73-
request.getEmail(), token, refreshToken)); // 예시로 토큰만 문자열로 반환
75+
request.getEmail(),
76+
profileImage,
77+
token,
78+
refreshToken)); // 예시로 토큰만 문자열로 반환
7479
} catch (Exception e) {
7580
throw new GeneralHandler(ErrorStatus.ID_OR_PASSWORD_WRONG);
7681
}
@@ -113,9 +118,11 @@ public ApiResponse<MemberResponseDTO.LoginResultDTO> refresh(
113118

114119
// 새로운 액세스 토큰 생성
115120
String newAccessToken = jwtUtil.generateToken(usernameFromToken, authorities);
121+
String profileImage = memberService.getMemberProfileImage(email);
116122

117123
return ApiResponse.onSuccess(
118-
MemberConverter.toLoginResultDTO(usernameFromToken, newAccessToken, null));
124+
MemberConverter.toLoginResultDTO(
125+
usernameFromToken, profileImage, newAccessToken, null));
119126
} else {
120127
throw new GeneralHandler(ErrorStatus.INVALID_REFRESH_TOKEN);
121128
}

src/main/java/umc/codeplay/controller/FileController.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import umc.codeplay.dto.FileResponseDTO;
1616
import umc.codeplay.service.FileService;
1717

18-
import static umc.codeplay.service.FileService.buildFilename;
19-
2018
@RestController
2119
@RequestMapping("/files")
2220
@RequiredArgsConstructor
@@ -30,15 +28,9 @@ public class FileController {
3028
description = "업로드를 위한 Presigned URL 생성 - 유효시간 존재")
3129
@PostMapping("/upload")
3230
public ApiResponse<FileResponseDTO.UploadFile> generateUrl(
33-
@RequestParam(value = "fileType") FileType fileType,
34-
@RequestParam(value = "fileName") String fileName) {
31+
@RequestParam FileType fileType, @RequestParam String fileName) {
3532

3633
String username = SecurityContextHolder.getContext().getAuthentication().getName();
37-
String newFileName = fileType.getFolderName() + buildFilename(fileName);
38-
39-
Long id = fileType.processUpload(fileService, newFileName, username);
40-
String uploadUrl = fileService.generatePutPresignedUrl(newFileName);
41-
42-
return ApiResponse.onSuccess(fileType.createResponse(uploadUrl, id));
34+
return ApiResponse.onSuccess(fileService.getUploadUrl(username, fileName, fileType));
4335
}
4436
}

src/main/java/umc/codeplay/controller/TaskController.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package umc.codeplay.controller;
22

33
import org.springframework.validation.annotation.Validated;
4-
import org.springframework.web.bind.annotation.PostMapping;
5-
import org.springframework.web.bind.annotation.RequestBody;
6-
import org.springframework.web.bind.annotation.RequestMapping;
7-
import org.springframework.web.bind.annotation.RestController;
4+
import org.springframework.web.bind.annotation.*;
85

96
import lombok.RequiredArgsConstructor;
107

8+
import io.swagger.v3.oas.annotations.Hidden;
119
import io.swagger.v3.oas.annotations.Operation;
1210
import io.swagger.v3.oas.annotations.tags.Tag;
1311
import umc.codeplay.apiPayLoad.ApiResponse;
@@ -71,4 +69,17 @@ public ApiResponse<MemberResponseDTO.TaskProgressDTO> getTask(
7169
Task task = taskService.findById(request.getTaskId());
7270
return ApiResponse.onSuccess(MemberConverter.toTaskProgressDTO(task));
7371
}
72+
73+
@Hidden // TODO: 기능 완성시 @Hidden 태그만 삭제해주세요!
74+
@Operation(
75+
summary = "작업 진행 상황 조회",
76+
description = "작업 ID를 받아 완료될 때까지 기다린 후 결과를 반환합니다. 기본 대기시간 5분, 10초마다 작업 상태확인.")
77+
@GetMapping("/wait/{taskId}")
78+
public ApiResponse<MemberResponseDTO.TaskProgressDTO> waitTask(
79+
@PathVariable Long taskId,
80+
@RequestParam(defaultValue = "300000") long timeoutMillis // 기본 5분 대기시간 + 10초마다 작업상태 체크
81+
) {
82+
Task task = taskService.waitTask(taskId, timeoutMillis);
83+
return ApiResponse.onSuccess(MemberConverter.toTaskProgressDTO(task));
84+
}
7485
}

src/main/java/umc/codeplay/converter/MemberConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public static MemberResponseDTO.JoinResultDTO toJoinResultDTO(Member member) {
3333
}
3434

3535
public static MemberResponseDTO.LoginResultDTO toLoginResultDTO(
36-
String email, String token, String refreshToken) {
36+
String email, String profileUrl, String token, String refreshToken) {
3737

3838
return MemberResponseDTO.LoginResultDTO.builder()
3939
.email(email)
40+
.profileUrl(profileUrl)
4041
.token(token)
4142
.refreshToken(refreshToken)
4243
.build();

src/main/java/umc/codeplay/domain/Harmony.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Harmony extends BaseEntity {
4141

4242
@Builder
4343
private Harmony(String scale, String genre, Integer bpm, String voiceColor, Music music) {
44-
this.title = music.getTitle().split("-", 2)[1];
44+
this.title = music.getTitle() + "_화성분석 결과";
4545
this.scale = scale;
4646
this.genre = genre;
4747
this.bpm = bpm;

src/main/java/umc/codeplay/domain/Music.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class Music extends BaseEntity {
2626
@Column(nullable = false, length = 100)
2727
private String title;
2828

29-
@Column(columnDefinition = "TEXT", nullable = false)
29+
@Column(columnDefinition = "TEXT")
30+
@Setter
3031
private String musicUrl;
3132

3233
@ManyToOne(fetch = FetchType.LAZY)

src/main/java/umc/codeplay/domain/Remix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Remix(
6969
Boolean isChorusOn,
7070
String resultMusicUrl,
7171
Music music) {
72-
this.title = music.getTitle().split("-", 2)[1];
72+
this.title = music.getTitle() + "_리믹스 결과";
7373
this.scaleModulation = scaleModulation;
7474
this.tempoRatio = tempoRatio;
7575
this.reverbAmount = reverbAmount;

src/main/java/umc/codeplay/domain/Track.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Track extends BaseEntity {
4747
@Builder
4848
public Track(
4949
String vocalUrl, String instrumentalUrl, String bassUrl, String drumsUrl, Music music) {
50-
this.title = music.getTitle().split("-", 2)[1];
50+
this.title = music.getTitle() + "_스템분리 결과";
5151
this.vocalUrl = vocalUrl;
5252
this.instrumentalUrl = instrumentalUrl;
5353
this.bassUrl = bassUrl;
Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
11
package umc.codeplay.domain.enums;
22

33
import umc.codeplay.dto.FileResponseDTO;
4-
import umc.codeplay.service.FileService;
54

65
public enum FileType {
76
AUDIO {
8-
public String getFolderName() {
9-
return "requestFiles/";
10-
}
11-
12-
public Long processUpload(FileService fileService, String fileName, String username) {
13-
return fileService.uploadMusic(fileName, username);
14-
}
15-
16-
public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) {
17-
return new FileResponseDTO.UploadFile(uploadUrl, id, null);
7+
@Override
8+
public String buildStoragePath(Long id, String fileName) {
9+
return String.format("%s%d/%s", BASE_AUDIO_PATH, id, fileName);
1810
}
1911
},
2012
IMAGE {
21-
public String getFolderName() {
22-
return "profileImgs/";
23-
}
24-
25-
public Long processUpload(FileService fileService, String fileName, String username) {
26-
return fileService.uploadProfile(fileName, username);
27-
}
28-
29-
public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) {
30-
return new FileResponseDTO.UploadFile(uploadUrl, null, id);
13+
@Override
14+
public String buildStoragePath(Long id, String fileName) {
15+
return String.format("%s%d/%s", BASE_IMAGE_PATH, id, fileName);
3116
}
3217
};
3318

34-
public abstract String getFolderName();
19+
private static final String BASE_AUDIO_PATH = "requestFiles/";
20+
private static final String BASE_IMAGE_PATH = "profileImgs/";
3521

36-
public abstract Long processUpload(FileService fileService, String fileName, String username);
22+
public abstract String buildStoragePath(Long id, String fileName);
3723

38-
public abstract FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id);
24+
public FileResponseDTO.UploadFile createResponse(String uploadUrl, Long id) {
25+
return this == AUDIO
26+
? new FileResponseDTO.UploadFile(uploadUrl, id, null)
27+
: new FileResponseDTO.UploadFile(uploadUrl, null, id);
28+
}
3929
}

src/main/java/umc/codeplay/dto/MemberResponseDTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static class JoinResultDTO {
2424
@AllArgsConstructor
2525
public static class LoginResultDTO {
2626
String email;
27+
String profileUrl;
2728
String token;
2829
String refreshToken;
2930
}

0 commit comments

Comments
 (0)