Skip to content

Commit

Permalink
Merge pull request #107 from Me1tingPot/feature/#104
Browse files Browse the repository at this point in the history
refactor : 요청 방식 변경
  • Loading branch information
yewonahn authored Jun 29, 2024
2 parents 97cfc71 + ee1cef6 commit ac55c0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ResponseEntity<ResponseData<ChatRoomsPageResponse>> getChatRooms(
return ResponseData.toResponseEntity(CHAT_ROOMS_LIST_GET_SUCCESS, chatRoomQueryService.getChatRooms(user.getId(), page, size));
}

@PostMapping("/alarm/{chatRoomId}")
@PostMapping("/alarm")
@Operation(summary = "채팅방 알림 설정 변경", description = "채팅방 전체 목록에서 각 채팅방의 알림 (ON / OFF) 설정")
@ApiResponses(value = {
@ApiResponse(responseCode = "OK", description = "채팅방 알림 설정 변경 성공"),
Expand All @@ -51,9 +51,9 @@ public ResponseEntity<ResponseData<ChatRoomsPageResponse>> getChatRooms(
})
public ResponseEntity<ResponseData> updateAlarmStatus(
@CurrentUser Account user,
@PathVariable("chatRoomId") Long chatRoomId
@RequestBody ChatRoomAlarmUpdateRequest request
) {
return ResponseData.toResponseEntity(chatRoomService.updateAlarmStatus(user.getId(), chatRoomId));
return ResponseData.toResponseEntity(chatRoomService.updateAlarmStatus(user.getId(), request));
}

// [CHECK] PageResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package meltingpot.server.chat.dto;

public record ChatRoomAlarmUpdateRequest(
Long chatRoomId
) {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package meltingpot.server.chat.service;

import lombok.RequiredArgsConstructor;
import meltingpot.server.chat.dto.ChatRoomAlarmUpdateRequest;
import meltingpot.server.domain.entity.chat.ChatRoomUser;
import meltingpot.server.domain.repository.chat.ChatRoomUserRepository;
import meltingpot.server.exception.ResourceNotFoundException;
Expand All @@ -16,8 +17,8 @@
public class ChatRoomService {
private final ChatRoomUserRepository chatRoomUserRepository;

public ResponseCode updateAlarmStatus(Long userId, Long chatRoomId) {
ChatRoomUser chatRoomUser = chatRoomUserRepository.findChatRoomUserByUserIdAndChatRoomId(userId, chatRoomId)
public ResponseCode updateAlarmStatus(Long userId, ChatRoomAlarmUpdateRequest request) {
ChatRoomUser chatRoomUser = chatRoomUserRepository.findChatRoomUserByUserIdAndChatRoomId(userId, request.chatRoomId())
.orElseThrow(() -> new ResourceNotFoundException(CHAT_ROOM_NOT_FOUND));
chatRoomUser.toggleAlarm();
chatRoomUserRepository.save(chatRoomUser);
Expand Down

0 comments on commit ac55c0f

Please sign in to comment.