Skip to content

Commit

Permalink
Merge pull request #147 from Re-4aliens/#146_chat-room-open
Browse files Browse the repository at this point in the history
Feat/#146 채팅 시작 시간에 맞춰 대기중 상태의 채팅방을 열린 상태로 업데이트
  • Loading branch information
coke98 authored Aug 22, 2024
2 parents e3b3c2d + c4e39b9 commit 8852d98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
@Modifying
@Query("UPDATE ChatRoom c SET c.status = com.aliens.backend.chat.domain.ChatRoomStatus.CLOSED")
void expireAllChatRooms();

@Modifying
@Query("UPDATE ChatRoom c SET c.status = com.aliens.backend.chat.domain.ChatRoomStatus.OPENED WHERE c.status = com.aliens.backend.chat.domain.ChatRoomStatus.WAITING")
void openWaitingChatRooms();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.List;
Expand Down Expand Up @@ -174,4 +175,10 @@ private void expireAllChatRooms() {
private ChatRoom findChatRoomsById(final Long chatRoomId) {
return chatRoomRepository.findById(chatRoomId).orElseThrow(() -> new RestApiException(ChatError.CHAT_ROOM_NOT_FOUND));
}

@Scheduled(cron = "${matching.round.update-date}")
@Transactional
public void openWaitingChatRooms() {
chatRoomRepository.openWaitingChatRooms();
}
}

0 comments on commit 8852d98

Please sign in to comment.