Skip to content

Commit 14389bb

Browse files
authored
Merge pull request #137 from TeamMemeSphere/develop
Develop에서 main으로 변경사항 반영
2 parents d8c668d + 9711516 commit 14389bb

File tree

9 files changed

+32
-15
lines changed

9 files changed

+32
-15
lines changed

src/main/java/com/memesphere/domain/chat/controller/ChatController.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.memesphere.domain.chat.dto.request.ChatRequest;
44
import com.memesphere.domain.chat.dto.response.ChatResponse;
55
import com.memesphere.domain.chat.service.ChatService;
6+
import com.memesphere.domain.user.entity.User;
67
import com.memesphere.global.apipayload.ApiResponse;
78
import com.memesphere.global.jwt.CustomUserDetails;
89
import io.swagger.v3.oas.annotations.Operation;
@@ -36,20 +37,22 @@ public ChatResponse chat(@DestinationVariable("coin_id") Long coin_id,
3637
@Operation(summary = "코인별 채팅 전체 메시지 조회 API",
3738
description = "특정 코인의 채팅방의 전체 메시지를 보여줍니다.")
3839
public ApiResponse<Page<ChatResponse>> getChatList(@PathVariable("coin_id") Long coin_id,
39-
Pageable pageable) {
40+
Pageable pageable,
41+
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
42+
User user = (customUserDetails != null) ? customUserDetails.getUser() : null;
4043

41-
return ApiResponse.onSuccess(chatService.getChatList(coin_id, pageable));
44+
return ApiResponse.onSuccess(chatService.getChatList(coin_id, pageable, user));
4245
}
4346

4447
//최신 댓글 조회 Api
4548
@GetMapping("/chat/{coin_id}/latest")
4649
@Operation(summary = "코인별 최신 댓글 조회 API",
4750
description = "특정 코인에 대한 최신 댓글을 반환합니다. 요청 시 최신 댓글 하나만 가져옵니다.")
48-
public ApiResponse<ChatResponse> getLatestMessages(
49-
@PathVariable("coin_id") Long coin_id) {
50-
51+
public ApiResponse<ChatResponse> getLatestMessages(@PathVariable("coin_id") Long coin_id,
52+
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
53+
User user = customUserDetails.getUser();
5154
// 최신 댓글을 가져오는 서비스 메서드 호출
52-
ChatResponse latestMessage = chatService.getLatestMessages(coin_id);
55+
ChatResponse latestMessage = chatService.getLatestMessages(coin_id, user);
5356

5457
return ApiResponse.onSuccess(latestMessage);
5558
}

src/main/java/com/memesphere/domain/chat/converter/ChatConverter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.memesphere.domain.chat.dto.response.ChatResponse;
88
import com.memesphere.domain.user.entity.User;
99

10+
import java.util.Objects;
11+
import java.util.stream.Collectors;
12+
1013
public class ChatConverter {
1114

1215
public static Chat toChat(MemeCoin memeCoin, ChatRequest chatRequest, User user) {
@@ -18,7 +21,9 @@ public static Chat toChat(MemeCoin memeCoin, ChatRequest chatRequest, User user)
1821
.build();
1922
}
2023

21-
public static ChatResponse toChatResponse(Chat chat) {
24+
public static ChatResponse toChatResponse(Chat chat, User user) {
25+
boolean isLiked = user != null && chat.getChatLikeList().stream()
26+
.anyMatch(chatLike -> Objects.equals(chatLike.getUser().getId(), user.getId()));
2227

2328
return ChatResponse.builder()
2429
.id(chat.getId())
@@ -27,6 +32,7 @@ public static ChatResponse toChatResponse(Chat chat) {
2732
.likes(chat.getChatLikeList().size())
2833
.createdAt(chat.getCreatedAt())
2934
.nickname(chat.getUser().getNickname())
35+
.isLiked(isLiked)
3036
.build();
3137
}
3238

src/main/java/com/memesphere/domain/chat/dto/response/ChatResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class ChatResponse {
2525
@Schema(description = "좋아요 수", example = "17")
2626
private int likes;
2727

28+
@Schema(description = "좋아요 여부", example = "True")
29+
private boolean isLiked;
30+
2831
@Schema(description = "전송 시간", example = "2025-01-01T00:00:00")
2932
private LocalDateTime createdAt;
3033
}

src/main/java/com/memesphere/domain/chat/service/ChatService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ public ChatResponse saveMessage(Long coin_id, ChatRequest chatRequest) {
4141
Chat chat = ChatConverter.toChat(memeCoin, chatRequest, user);
4242
Chat savedChat = chatRepository.save(chat);
4343

44-
return ChatConverter.toChatResponse(savedChat);
44+
return ChatConverter.toChatResponse(savedChat, user);
4545
}
4646

4747
@Transactional
48-
public Page<ChatResponse> getChatList(Long coin_id, Pageable pageable) {
48+
public Page<ChatResponse> getChatList(Long coin_id, Pageable pageable, User user) {
4949

5050
Page<Chat> chatPage = chatRepository.findAllByMemeCoin_Id(coin_id, pageable);
51-
return chatPage.map(ChatConverter::toChatResponse);
51+
52+
return chatPage.map(chat -> ChatConverter.toChatResponse(chat, user));
5253
}
5354

5455
// 최신 댓글을 가져오는 메서드
5556
@Transactional
56-
public ChatResponse getLatestMessages(Long coin_id) {
57+
public ChatResponse getLatestMessages(Long coin_id, User user) {
5758

5859
MemeCoin memeCoin = memeCoinRepository.findById(coin_id)
5960
//id에 해당하는 밈코인 없을 때
@@ -68,7 +69,7 @@ public ChatResponse getLatestMessages(Long coin_id) {
6869
}
6970

7071
// 최신 댓글을 ChatResponse로 변환하여 반환
71-
return ChatConverter.toChatResponse(latestChat);
72+
return ChatConverter.toChatResponse(latestChat, user);
7273
}
7374

7475
@Transactional

src/main/java/com/memesphere/domain/collection/service/CollectionQueryServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CollectionQueryServiceImpl implements CollectionQueryService {
2828
public Page<Collection> getCollectionPage(Long userId, Integer pageNumber, ViewType viewType, SortType sortType) {
2929

3030
int pageSize = switch (viewType) {
31-
case GRID -> 9;
31+
case GRID -> 12;
3232
case LIST -> 20;
3333
default -> throw new GeneralException(ErrorStatus.UNSUPPORTED_VIEW_TYPE);
3434
};

src/main/java/com/memesphere/domain/dashboard/service/DashboardQueryServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public SearchPageResponse getChartPage(Long userId, ViewType viewType, SortType
7777
Collections.emptyList() : collectionQueryService.getUserCollectionIds(userId);
7878

7979
int pageSize = switch (viewType) {
80-
case GRID -> 9;
80+
case GRID -> 12;
8181
case LIST -> 20;
8282
default -> throw new GeneralException(ErrorStatus.UNSUPPORTED_VIEW_TYPE);
8383
};

src/main/java/com/memesphere/domain/notification/converter/NotificationConverter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static NotificationResponse toNotificationCreateResponse(Notification not
3131
.stTime(notification.getStTime())
3232
.isRising(notification.getIsRising())
3333
.isOn(notification.getIsOn())
34+
.coinId(memeCoin.getId())
3435
.build();
3536
}
3637

src/main/java/com/memesphere/domain/notification/dto/response/NotificationResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ public class NotificationResponse {
2828

2929
@Schema(description = "알림 켜기/끄기", example = "True")
3030
private Boolean isOn;
31+
32+
@Schema(description = "코인 아이디", example = "1")
33+
private Long coinId;
3134
}

src/main/java/com/memesphere/domain/search/service/SearchQueryServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Page<MemeCoin> getSearchPage(String searchWord, ViewType viewType, SortTy
2626
// sortType --> MKT_CAP, VOLUME_24H, PRICE
2727

2828
int pageSize = switch (viewType) {
29-
case GRID -> 9;
29+
case GRID -> 12;
3030
case LIST -> 20;
3131
default -> throw new GeneralException(ErrorStatus.UNSUPPORTED_VIEW_TYPE);
3232
};

0 commit comments

Comments
 (0)