Skip to content

Commit b7f852d

Browse files
authored
[T3-160] 감정 구슬 이미지 추가 및 조회 V2 API (#61)
* feat: 일자 기준 감정구슬 조회 V2 API * feat: 감정구슬 메세지 및 V2 이미지 추가
1 parent f7e2909 commit b7f852d

6 files changed

Lines changed: 104 additions & 18 deletions

File tree

src/main/java/bitnagil/bitnagil_backend/emotionMarble/controller/EmotionMarbleController.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import bitnagil.bitnagil_backend.emotionMarble.controller.spec.EmotionMarbleSpec;
44
import bitnagil.bitnagil_backend.emotionMarble.request.RegisterEmotionMarbleRequest;
55
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponse;
6+
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponseV2;
67
import bitnagil.bitnagil_backend.emotionMarble.response.RegisterEmotionMarbleResponse;
78
import bitnagil.bitnagil_backend.emotionMarble.service.EmotionMarbleService;
89
import bitnagil.bitnagil_backend.global.annotation.CurrentUser;
@@ -18,27 +19,38 @@
1819

1920
@RestController
2021
@RequiredArgsConstructor
21-
@RequestMapping(value = "/api/v1/emotion-marbles")
22+
@RequestMapping(value = "/api")
2223
public class EmotionMarbleController implements EmotionMarbleSpec {
2324
private final EmotionMarbleService emotionMarbleService;
2425

2526
// 감정구슬 조회 API
26-
@GetMapping("")
27+
@GetMapping("/v1/emotion-marbles")
2728
public CustomResponseDto<List<EmotionMarbleTypeResponse>> getEmotionMarbles() {
2829
return CustomResponseDto.from(emotionMarbleService.getEmotionMarbles());
2930
}
3031

3132
// 감정구슬 등록 API
32-
@PostMapping("")
33+
@PostMapping("/v1/emotion-marbles")
3334
public CustomResponseDto<RegisterEmotionMarbleResponse> registryEmotionMarble(
3435
@CurrentUser User user,
3536
@RequestBody RegisterEmotionMarbleRequest request) {
3637

3738
return CustomResponseDto.from(emotionMarbleService.registryEmotionMarble(user, request));
3839
}
3940

41+
// todo: 당일의 유저가 선택한 감정 구슬 조회 API V2로 변환
42+
@GetMapping("/v2/{searchDate}")
43+
public CustomResponseDto<EmotionMarbleTypeResponseV2> getEmotionMarbleBySearchDateV2(
44+
@CurrentUser User user,
45+
@PathVariable LocalDate searchDate) {
46+
47+
return CustomResponseDto.from(emotionMarbleService.getEmotionMarbleBySearchDateV2(user, searchDate));
48+
}
49+
4050
// 당일의 유저가 선택한 감정 구슬 조회 API
41-
@GetMapping("/{searchDate}")
51+
// TODO: v2로 전환 시 deprecated 처리
52+
@Deprecated()
53+
@GetMapping("/v1/{searchDate}")
4254
public CustomResponseDto<EmotionMarbleTypeResponse> getEmotionMarbleBySearchDate(
4355
@CurrentUser User user,
4456
@PathVariable @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate searchDate) {

src/main/java/bitnagil/bitnagil_backend/emotionMarble/controller/spec/EmotionMarbleSpec.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import bitnagil.bitnagil_backend.emotionMarble.request.RegisterEmotionMarbleRequest;
44
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponse;
5+
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponseV2;
56
import bitnagil.bitnagil_backend.emotionMarble.response.RegisterEmotionMarbleResponse;
6-
import bitnagil.bitnagil_backend.global.annotation.CurrentUser;
77
import bitnagil.bitnagil_backend.global.errorcode.ErrorCode;
88
import bitnagil.bitnagil_backend.global.response.CustomResponseDto;
99
import bitnagil.bitnagil_backend.global.swagger.ApiErrorCodeExamples;
@@ -14,14 +14,11 @@
1414
import io.swagger.v3.oas.annotations.Parameters;
1515
import io.swagger.v3.oas.annotations.enums.ParameterIn;
1616
import io.swagger.v3.oas.annotations.tags.Tag;
17-
import jakarta.validation.constraints.NotNull;
1817

1918
import java.time.LocalDate;
2019
import java.util.List;
2120

22-
import org.springframework.format.annotation.DateTimeFormat;
2321
import org.springframework.web.bind.annotation.PathVariable;
24-
import org.springframework.web.bind.annotation.RequestParam;
2522

2623
@Tag(name = ApiTags.EMOTION_MARBLE)
2724
public interface EmotionMarbleSpec {
@@ -34,6 +31,14 @@ public interface EmotionMarbleSpec {
3431
public CustomResponseDto<RegisterEmotionMarbleResponse> registryEmotionMarble(
3532
User user, RegisterEmotionMarbleRequest request);
3633

34+
@Operation(summary = "(V2) 검색 날짜 기준으로 대한 유저의 감정구슬 정보를 조회합니다.")
35+
@Parameters({
36+
@Parameter(name = "searchDate", description = "감정 구슬 조회 날짜", required = true, example = "2025-08-15",
37+
in = ParameterIn.PATH)
38+
})
39+
CustomResponseDto<EmotionMarbleTypeResponseV2> getEmotionMarbleBySearchDateV2(
40+
User user, @PathVariable LocalDate searchDate);
41+
3742
@Operation(summary = "검색 날짜 기준으로 대한 유저의 감정구슬 정보를 조회합니다.")
3843
@Parameters({
3944
@Parameter(name = "searchDate", description = "감정 구슬 조회 날짜", required = true, example = "2025-07-01",

src/main/java/bitnagil/bitnagil_backend/emotionMarble/domain/enums/EmotionMarbleType.java

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,42 @@
77
@RequiredArgsConstructor
88
@Getter
99
public enum EmotionMarbleType implements EnumType {
10-
CALM("평온함", 5L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_calm.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_calm.png"),
11-
VITALITY("활기참", 6L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_vitality.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_vitality.png"),
12-
LETHARGY("무기력함", 7L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_lethargy.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_lethargy.png"),
13-
ANXIETY("불안함", 8L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_anxiety.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_anxiety.png"),
14-
SATISFACTION("만족함", 9L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_satisfaction.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_satisfaction.png"),
15-
FATIGUE("피로함", 10L, "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_fatigue.png", "https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_fatigue.png")
10+
CALM("평온함", 5L,
11+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_calm.png",
12+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_calm_v2.png",
13+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_calm.png",
14+
"오늘은 평온하군요~"),
15+
VITALITY("활기참", 6L,
16+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_vitality.png",
17+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_vitality_v2.png",
18+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_vitality.png",
19+
"오늘은 활기차군요~"),
20+
LETHARGY("무기력함", 7L,
21+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_lethargy.png",
22+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_lethargy_v2.png",
23+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_lethargy.png",
24+
"오늘은 무기력한가요?"),
25+
ANXIETY("불안함", 8L,
26+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_anxiety.png",
27+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_anxiety_v2.png",
28+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_anxiety.png",
29+
"오늘은 불안한가요?"),
30+
SATISFACTION("만족함", 9L,
31+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_satisfaction.png",
32+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_satisfaction_v2.png",
33+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_satisfaction.png",
34+
"오늘은 만족하는군요~"),
35+
FATIGUE("피로함", 10L,
36+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_fatigue.png",
37+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/home_fatigue_v2.png",
38+
"https://bitnagil-s3.s3.ap-northeast-2.amazonaws.com/marble_fatigue.png",
39+
"오늘은 피곤한가요?"),
1640
;
1741

1842
private final String description;
1943
private final Long caseId;
20-
private final String homeMarbleImageUrl;
44+
private final String homeMarbleImageUrlV1;
45+
private final String homeMarbleImageUrlV2;
2146
private final String marbleImageUrl;
47+
private final String homeMessage;
2248
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package bitnagil.bitnagil_backend.emotionMarble.response;
2+
3+
import bitnagil.bitnagil_backend.emotionMarble.domain.enums.EmotionMarbleType;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Getter;
8+
9+
@Getter
10+
@AllArgsConstructor
11+
@Builder
12+
@Schema(description = "감정 구슬 조회 DTO")
13+
public class EmotionMarbleTypeResponseV2 {
14+
@Schema(description = "감정 구슬 타입", example = "CALM")
15+
private EmotionMarbleType emotionMarbleType;
16+
17+
@Schema(description = "감정 구슬 명칭", example = "평온함")
18+
private String emotionMarbleName;
19+
20+
@Schema(description = "감정 구슬 이미지 URL (홈/구슬 선택 화면 이미지 다름)", example = "https://example.com/image/calm.png")
21+
private String imageUrl;
22+
23+
@Schema(description = "감정 구슬 홈 화면 메시지", example = "오늘은 평온하군요~")
24+
private String emotionMarbleHomeMessage;
25+
}

src/main/java/bitnagil/bitnagil_backend/emotionMarble/service/EmotionMarbleMapper.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import bitnagil.bitnagil_backend.emotionMarble.domain.EmotionMarble;
44
import bitnagil.bitnagil_backend.emotionMarble.domain.enums.EmotionMarbleType;
55
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponse;
6+
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponseV2;
67
import org.springframework.stereotype.Component;
78

8-
import java.util.List;
9-
109
/**
1110
* 감정구슬에 대한 가공된 데이터를 DTO로 변환하는 Mapper 클래스입니다.
1211
*/
@@ -21,11 +20,22 @@ public EmotionMarbleTypeResponse toEmotionMarbleTypeResponse(EmotionMarbleType e
2120
.build();
2221
}
2322

23+
// todo: v2로 전환 시 deprecated 처리
24+
@Deprecated
2425
public EmotionMarbleTypeResponse toEmotionMarbleTypeResponse(EmotionMarble emotionMarble) {
2526
return EmotionMarbleTypeResponse.builder()
2627
.emotionMarbleType(emotionMarble == null ? null : emotionMarble.getEmotionMarbleType())
2728
.emotionMarbleName(emotionMarble == null ? null : emotionMarble.getEmotionMarbleType().getDescription())
28-
.imageUrl(emotionMarble == null ? null :emotionMarble.getEmotionMarbleType().getHomeMarbleImageUrl())
29+
.imageUrl(emotionMarble == null ? null :emotionMarble.getEmotionMarbleType().getHomeMarbleImageUrlV1())
2930
.build();
3031
}
32+
33+
public EmotionMarbleTypeResponseV2 toEmotionMarbleTypeResponseV2(EmotionMarble emotionMarble) {
34+
return EmotionMarbleTypeResponseV2.builder()
35+
.emotionMarbleType(emotionMarble == null ? null : emotionMarble.getEmotionMarbleType())
36+
.emotionMarbleName(emotionMarble == null ? null : emotionMarble.getEmotionMarbleType().getDescription())
37+
.imageUrl(emotionMarble == null ? null :emotionMarble.getEmotionMarbleType().getHomeMarbleImageUrlV2())
38+
.emotionMarbleHomeMessage(emotionMarble == null ? null : emotionMarble.getEmotionMarbleType().getHomeMessage())
39+
.build();
40+
}
3141
}

src/main/java/bitnagil/bitnagil_backend/emotionMarble/service/EmotionMarbleService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import bitnagil.bitnagil_backend.emotionMarble.repository.EmotionMarbleRepository;
66
import bitnagil.bitnagil_backend.emotionMarble.request.RegisterEmotionMarbleRequest;
77
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponse;
8+
import bitnagil.bitnagil_backend.emotionMarble.response.EmotionMarbleTypeResponseV2;
89
import bitnagil.bitnagil_backend.recommendedRoutine.response.RecommendedRoutineDto;
910
import bitnagil.bitnagil_backend.emotionMarble.response.RegisterEmotionMarbleResponse;
1011
import bitnagil.bitnagil_backend.global.errorcode.ErrorCode;
@@ -70,6 +71,13 @@ public RegisterEmotionMarbleResponse registryEmotionMarble(User user, RegisterEm
7071
.build();
7172
}
7273

74+
@Transactional(readOnly = true)
75+
public EmotionMarbleTypeResponseV2 getEmotionMarbleBySearchDateV2(User user, LocalDate searchDate) {
76+
EmotionMarble emotionMarble = emotionMarbleRepository.findByUserIdAndDateIs(user.getUserId(), searchDate);
77+
78+
return emotionMarbleMapper.toEmotionMarbleTypeResponseV2(emotionMarble);
79+
}
80+
7381
@Transactional(readOnly = true)
7482
public EmotionMarbleTypeResponse getEmotionMarbleBySearchDate(User user, LocalDate searchDate) {
7583
EmotionMarble emotionMarble = emotionMarbleRepository.findByUserIdAndDateIs(user.getUserId(), searchDate);

0 commit comments

Comments
 (0)