Skip to content

Commit ee587f1

Browse files
authored
[dev -> main] 2025.11.27 03:46
[dev -> main] 2025.11.27 03:46
2 parents 26c4232 + af3e561 commit ee587f1

40 files changed

Lines changed: 1341 additions & 4431 deletions

full_log.txt

Lines changed: 0 additions & 3154 deletions
This file was deleted.

src/main/java/DiffLens/back_end/domain/library/controller/LibraryController.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package DiffLens.back_end.domain.library.controller;
22

3+
import DiffLens.back_end.domain.library.dto.LibraryCreateResult;
34
import DiffLens.back_end.domain.library.dto.LibraryRequestDto;
45
import DiffLens.back_end.domain.library.dto.LibraryResponseDTO;
56
import DiffLens.back_end.domain.library.dto.LibraryCompareRequestDTO;
67
import DiffLens.back_end.domain.library.dto.LibraryCompareResponseDTO;
7-
import DiffLens.back_end.domain.library.service.LibraryService;
8+
import DiffLens.back_end.domain.library.service.analysis.LibraryAnalysisService;
9+
import DiffLens.back_end.domain.library.service.command.LibraryCommandService;
10+
import DiffLens.back_end.domain.library.service.query.LibraryQueryService;
811
import DiffLens.back_end.domain.members.entity.Member;
912
import DiffLens.back_end.domain.members.service.auth.CurrentUserService;
1013
import DiffLens.back_end.global.responses.exception.ApiResponse;
@@ -14,15 +17,15 @@
1417
import lombok.RequiredArgsConstructor;
1518
import org.springframework.web.bind.annotation.*;
1619

17-
import java.util.List;
18-
1920
@Tag(name = "라이브러리 API")
2021
@RestController
2122
@RequestMapping("/libraries")
2223
@RequiredArgsConstructor
2324
public class LibraryController {
2425

25-
private final LibraryService libraryService;
26+
private final LibraryAnalysisService libraryAnalysisService;
27+
private final LibraryQueryService libraryQueryService;
28+
private final LibraryCommandService libraryCommandService;
2629
private final CurrentUserService currentUserService;
2730

2831
@GetMapping
@@ -49,7 +52,7 @@ public class LibraryController {
4952
""")
5053
public ApiResponse<LibraryResponseDTO.ListResult> libraryList() {
5154
Member member = currentUserService.getCurrentUser();
52-
LibraryResponseDTO.ListResult result = libraryService.getLibrariesByMember(member);
55+
LibraryResponseDTO.ListResult result = libraryQueryService.getLibrariesByMember(member);
5356
return ApiResponse.onSuccess(result);
5457
}
5558

@@ -79,12 +82,12 @@ public ApiResponse<LibraryResponseDTO.ListResult> libraryList() {
7982
public ApiResponse<LibraryResponseDTO.CreateResult> createLibrary(
8083
@RequestBody @Valid LibraryRequestDto.Create request) {
8184
Member member = currentUserService.getCurrentUser();
82-
LibraryService.LibraryCreateResult createResult = libraryService.createLibrary(request, member);
85+
LibraryCreateResult createResult = libraryCommandService.createLibrary(request, member);
8386

8487
LibraryResponseDTO.CreateResult result = LibraryResponseDTO.CreateResult.from(
85-
createResult.getLibrary(),
88+
createResult.library(),
8689
request.getSearchHistoryId(),
87-
createResult.getPanelCount());
90+
createResult.panelCount());
8891
return ApiResponse.onSuccess(result);
8992
}
9093

@@ -107,7 +110,7 @@ public ApiResponse<LibraryResponseDTO.CreateResult> createLibrary(
107110
""")
108111
public ApiResponse<LibraryResponseDTO.LibraryDetail> getLibraryDetail(@PathVariable Long libraryId) {
109112
Member member = currentUserService.getCurrentUser();
110-
LibraryResponseDTO.LibraryDetail result = libraryService.getLibraryDetail(libraryId, member);
113+
LibraryResponseDTO.LibraryDetail result = libraryQueryService.getLibraryDetail(libraryId, member);
111114
return ApiResponse.onSuccess(result);
112115
}
113116

@@ -143,13 +146,13 @@ public ApiResponse<LibraryResponseDTO.CreateResult> addSearchHistoryToLibrary(
143146
@PathVariable Long libraryId,
144147
@PathVariable Long searchHistoryId) {
145148
Member member = currentUserService.getCurrentUser();
146-
LibraryService.LibraryCreateResult createResult = libraryService.addSearchHistoryToLibrary(libraryId,
147-
searchHistoryId, member);
149+
LibraryCreateResult createResult = libraryCommandService.addSearchHistoryToLibrary(libraryId, searchHistoryId, member);
148150

149151
LibraryResponseDTO.CreateResult result = LibraryResponseDTO.CreateResult.from(
150-
createResult.getLibrary(),
152+
createResult.library(),
151153
searchHistoryId,
152-
createResult.getPanelCount());
154+
createResult.panelCount()
155+
);
153156
return ApiResponse.onSuccess(result);
154157
}
155158

@@ -179,7 +182,7 @@ public ApiResponse<LibraryResponseDTO.CreateResult> addSearchHistoryToLibrary(
179182
public ApiResponse<LibraryCompareResponseDTO.CompareResult> compareLibraries(
180183
@RequestBody @Valid LibraryCompareRequestDTO.Compare request) {
181184
Member member = currentUserService.getCurrentUser();
182-
LibraryCompareResponseDTO.CompareResult result = libraryService.compareLibraries(request, member);
185+
LibraryCompareResponseDTO.CompareResult result = libraryAnalysisService.compareLibraries(request, member);
183186
return ApiResponse.onSuccess(result);
184187
}
185188

@@ -208,7 +211,7 @@ public ApiResponse<LibraryCompareResponseDTO.CompareResult> compareLibraries(
208211
public ApiResponse<LibraryResponseDTO.LibraryDashboard> getLibraryDashboard(
209212
@PathVariable("libraryId") Long libraryId) {
210213
Member member = currentUserService.getCurrentUser();
211-
LibraryResponseDTO.LibraryDashboard result = libraryService.getLibraryDashboard(libraryId, member);
214+
LibraryResponseDTO.LibraryDashboard result = libraryAnalysisService.getLibraryDashboard(libraryId, member);
212215
return ApiResponse.onSuccess(result);
213216
}
214217

@@ -238,8 +241,7 @@ public ApiResponse<LibraryResponseDTO.LibraryPanels> getLibraryPanels(
238241
@RequestParam(value = "page", defaultValue = "1") Integer page,
239242
@RequestParam(value = "size", defaultValue = "20") Integer size) {
240243
Member member = currentUserService.getCurrentUser();
241-
LibraryResponseDTO.LibraryPanels result = libraryService.getLibraryPanels(libraryId, page, size,
242-
member);
244+
LibraryResponseDTO.LibraryPanels result = libraryQueryService.getLibraryPanels(libraryId, page, size, member);
243245
return ApiResponse.onSuccess(result);
244246
}
245247
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package DiffLens.back_end.domain.library.converter.dtoConvert;
2+
3+
import DiffLens.back_end.domain.library.dto.LibraryResponseDTO;
4+
import DiffLens.back_end.domain.library.entity.Library;
5+
import DiffLens.back_end.domain.library.entity.SearchHistoryLibrary;
6+
import DiffLens.back_end.domain.members.entity.Member;
7+
import DiffLens.back_end.domain.panel.entity.Panel;
8+
import DiffLens.back_end.domain.search.entity.SearchHistory;
9+
import DiffLens.back_end.global.dto.ResponsePageDTO;
10+
import DiffLens.back_end.global.responses.code.status.error.ErrorStatus;
11+
import DiffLens.back_end.global.responses.exception.handler.ErrorHandler;
12+
13+
import java.util.List;
14+
15+
public class LibraryQueryConverter {
16+
17+
public static List<LibraryResponseDTO.LibraryDetail.PanelInfo> toPanelInfos(List<Panel> panels) {
18+
return panels.stream()
19+
.map(panel -> LibraryResponseDTO.LibraryDetail.PanelInfo.builder()
20+
.panelId(panel.getId())
21+
.gender(panel.getGender() != null ? panel.getGender().toString() : null)
22+
.age(panel.getAge())
23+
.ageGroup(panel.getAgeGroup())
24+
.residence(panel.getRegion())
25+
.maritalStatus(panel.getMaritalStatus())
26+
.childrenCount(panel.getChildrenCount())
27+
.occupation(panel.getOccupation())
28+
.profileSummary(panel.getProfileSummary())
29+
.build())
30+
.toList();
31+
}
32+
33+
public static List<LibraryResponseDTO.LibraryDetail.SearchHistoryInfo> toSearchHistoryInfos(
34+
List<SearchHistoryLibrary> historyLinks
35+
) {
36+
return historyLinks.stream()
37+
.map(shl -> {
38+
SearchHistory history = shl.getHistory();
39+
return LibraryResponseDTO.LibraryDetail.SearchHistoryInfo.builder()
40+
.searchHistoryId(history.getId())
41+
.content(history.getContent())
42+
.date(toStringOrNull(history.getDate()))
43+
.panelCount(history.getPanelIds() != null ? history.getPanelIds().size() : 0)
44+
.createdAt(toStringOrNull(history.getCreatedDate()))
45+
.build();
46+
})
47+
.toList();
48+
}
49+
50+
public static LibraryResponseDTO.LibraryPanels emptyPanelResponse(Integer size) {
51+
return LibraryResponseDTO.LibraryPanels.builder()
52+
.keys(List.of("respondent_id", "gender", "age", "residence", "personal_income"))
53+
.values(List.of())
54+
.pageInfo(ResponsePageDTO.OffsetLimitPageInfo.builder()
55+
.offset(0)
56+
.currentPage(1)
57+
.currentPageCount(0)
58+
.totalPageCount(0)
59+
.limit(size)
60+
.totalCount(0L)
61+
.hasNext(false)
62+
.hasPrevious(false)
63+
.build())
64+
.build();
65+
}
66+
67+
private static String toStringOrNull(Object obj) {
68+
return obj != null ? obj.toString() : null;
69+
}
70+
71+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package DiffLens.back_end.domain.library.dto;
2+
3+
import DiffLens.back_end.domain.library.entity.Library;
4+
5+
public record LibraryCompareRedisKeySuffix(
6+
Long lib1Id,
7+
Long lib2Id
8+
) {
9+
10+
public static LibraryCompareRedisKeySuffix of(Library lib1, Library lib2) {
11+
return new LibraryCompareRedisKeySuffix(lib1.getId(), lib2.getId());
12+
}
13+
14+
public static LibraryCompareRedisKeySuffix of(Long lib1, Long lib2) {
15+
return new LibraryCompareRedisKeySuffix(lib1, lib2);
16+
}
17+
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package DiffLens.back_end.domain.library.dto;
2+
3+
import DiffLens.back_end.domain.library.entity.Library;
4+
5+
// 라이브러리 생성 결과를 담는 내부 레코드
6+
public record LibraryCreateResult(
7+
Library library,
8+
int panelCount
9+
) {
10+
11+
public static LibraryCreateResult of(Library library, int panelCount) {
12+
return new LibraryCreateResult(library, panelCount);
13+
}
14+
15+
}

0 commit comments

Comments
 (0)