Skip to content

Commit

Permalink
Feat: get last chat #104
Browse files Browse the repository at this point in the history
  • Loading branch information
khw18 committed Jul 7, 2024
1 parent 2efe4d8 commit ac18cee
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 ac18cee

Please sign in to comment.