Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#29 채팅 관련 로직 구현 #183

Merged
merged 15 commits into from
Jul 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
8fa3862
Feat: 채팅방 및 관련기능, 채팅 메세지 전송을 위한 웹소켓 설정
runtime-zer0 Jul 31, 2024
63714f3
Feat: 채팅방 관련 로직을 구현을 위한 레포지토리 및 DTO 구현
runtime-zer0 Jul 31, 2024
ee55eae
Feat: 채팅방에 참여한 사용자 정보 관리 로직 구현을 위한 레포지토리 및 DTO 구현
runtime-zer0 Jul 31, 2024
51fc1f9
Feat: 채팅 메세지 발행 및 전송, 메세지 수신 구현을 위한 레포지토리 및 DTO 구현
runtime-zer0 Jul 31, 2024
d0dee9a
Feat: 채팅방 입장, 퇴장 관련 로직을 구현하기 위한 비즈니스 로직 구현
runtime-zer0 Jul 31, 2024
ec84270
Feat: 메세지 발행 및 전송, 수신 관련 로직을 구현하기 위한 비즈니스 로직 및 유틸 클래스 구현
runtime-zer0 Jul 31, 2024
8392c8e
Feat: 채팅방 입장/퇴장 요청을 캐치하기 위한 컨트롤러 구현
runtime-zer0 Jul 31, 2024
8df6cef
Feat: 채팅 메세지 발행 및 전송, 채팅방 메세지 조회 요청을 캐치하기 위한 컨트롤러 구현
runtime-zer0 Jul 31, 2024
4686033
Feat: 채팅방 정보와 연관된 모집글 요약 정보 조희를 위한 로직 및 DTO 구현
runtime-zer0 Jul 31, 2024
c447551
Feat: 채팅방 입장/퇴장시 발생할 수 있는 예외 클래스 및 예외 핸들러 구현
runtime-zer0 Jul 31, 2024
84dafca
Feat: 채팅방에 입장한 사용자 관련 정보 관리시 발생할 수 있는 예외 클래스 및 예외 핸들러 구현
runtime-zer0 Jul 31, 2024
9db6afe
Feat: 채팅 메세지 발행 및 전송시 발생할 수 있는 예외 클래스 및 예외 핸들러 구현
runtime-zer0 Jul 31, 2024
b6cfb5d
Refactor: 클래스 이름 변경으로 인한 리팩토링 및 필드 이름 수정
runtime-zer0 Jul 31, 2024
7ac0dee
Refactor: 스프링의 단일 책임 원칙을 위한 리팩토링
runtime-zer0 Jul 31, 2024
42ff90c
Merge branch 'main' into feature/#29
runtime-zer0 Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feat: 채팅방 입장/퇴장 요청을 캐치하기 위한 컨트롤러 구현
- ChatRoom
- 채팅방 입장/퇴장 요청을 캐치하기 위한 ChatRoomController.java  구현

- ChatRoomController.java
- 필드: chatRoomService, gatherArticleService

- getChatRoomGatherArticleInfo() 메서드: 채팅방 정보와 연관된 모집글 정보 조회 요청 캐치
- 요청 URI: '/api/chat/rooms/{chatRoomId}/gather-articles/{gatherArticleId}'

- getChatRoomDetailsByUsername() 메서드: 특정 사용자가 참여한 채팅방 목록 조회 요청 캐치
- 요청 URI: '/api/chat/rooms'
runtime-zer0 committed Jul 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8392c8edc8b8b752a41012b9c770b3cb8157c0e1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package sumcoda.boardbuddy.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RestController;
import sumcoda.boardbuddy.dto.ChatRoomResponse;
import sumcoda.boardbuddy.dto.GatherArticleResponse;
import sumcoda.boardbuddy.dto.common.ApiResponse;
import sumcoda.boardbuddy.service.ChatRoomService;
import sumcoda.boardbuddy.service.GatherArticleService;

import java.util.List;
import java.util.Map;

import static sumcoda.boardbuddy.builder.ResponseBuilder.buildSuccessResponseWithPairKeyData;

@RestController
@RequiredArgsConstructor
public class ChatRoomController {

private final ChatRoomService chatRoomService;

private final GatherArticleService gatherArticleService;

/**
* 채팅방 정보와 연관된 모집글 정보 조회
*
* @param chatRoomId 채팅방 Id
* @param gatherArticleId 모집글 Id
* @return 채팅방과 연관된 모집글 정보
**/
@GetMapping("/api/chat/rooms/{chatRoomId}/gather-articles/{gatherArticleId}")
public ResponseEntity<ApiResponse<Map<String, GatherArticleResponse.SummaryInfoDTO>>> getChatRoomGatherArticleInfo(@PathVariable Long chatRoomId,
@PathVariable Long gatherArticleId,
@RequestAttribute String username) {

GatherArticleResponse.SummaryInfoDTO gatherArticleSimpleInfo = gatherArticleService.getChatRoomGatherArticleSimpleInfo(chatRoomId, gatherArticleId, username);

return buildSuccessResponseWithPairKeyData("gatherArticleSimpleInfo", gatherArticleSimpleInfo, "모집글 정보를 성공적으로 조회했습니다.", HttpStatus.OK);
}

/**
* 특정 사용자가 참여한 채팅방 목록 조회
*
* @param username 조회하려는 사용자의 아이디
* @return 사용자가 참여한 채팅방 목록
*/
@GetMapping("/api/chat/rooms")
public ResponseEntity<ApiResponse<Map<String, List<ChatRoomResponse.ChatRoomDetailsDTO>>>> getChatRoomDetailsByUsername(@RequestAttribute String username) {
List<ChatRoomResponse.ChatRoomDetailsDTO> chatRoomDetailsList = chatRoomService.getChatRoomDetailsListByUsername(username);

return buildSuccessResponseWithPairKeyData("chatRoomDetailsList", chatRoomDetailsList, "참여중인 채팅방 목록을 성공적으로 조회했습니다.", HttpStatus.OK);
}
}