Skip to content

Commit

Permalink
Merge pull request #105 from Hanaemong/hyeonu
Browse files Browse the repository at this point in the history
Feat: get last chat #104
  • Loading branch information
khw18 authored Jul 7, 2024
2 parents a5d9a1f + ac18cee commit 77df747
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/api/v1/chat")
Expand All @@ -19,4 +20,9 @@ public class ChatRestController {
public Flux<Chat> getChatsByRoomId(@PathVariable String roomId) {
return chatService.getChatsByRoomId(roomId);
}

@GetMapping("/last/{roomId}")
public Mono<Chat> getLastChatByRoomId(@PathVariable String roomId) {
return chatService.getLastChatByRoomId(roomId);
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/hana/hanalink/chat/service/ChatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ public Mono<Chat> saveChat(Chat chat) {
public Flux<Chat> getChatsByRoomId(String roomId) {
return chatRepository.findByRoomId(roomId);
}

public Mono<Chat> getLastChatByRoomId(String roomId) {
return chatRepository.findByRoomId(roomId).last();
}
}

0 comments on commit 77df747

Please sign in to comment.