Skip to content

Commit

Permalink
[BE] refactor: 채팅 패키지 분리 (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
takoyakimchi authored Nov 5, 2024
1 parent a2e29e1 commit 9fc6c9b
Show file tree
Hide file tree
Showing 51 changed files with 179 additions and 179 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.happy.friendogly.chat.controller;
package com.happy.friendogly.chatmessage.controller;

import com.happy.friendogly.auth.Auth;
import com.happy.friendogly.chat.dto.request.FindMessagesByTimeRangeRequest;
import com.happy.friendogly.chat.dto.response.FindChatMessagesResponse;
import com.happy.friendogly.chat.service.ChatQueryService;
import com.happy.friendogly.chatmessage.dto.request.FindMessagesByTimeRangeRequest;
import com.happy.friendogly.chatmessage.dto.response.FindChatMessagesResponse;
import com.happy.friendogly.chatmessage.service.ChatMessageQueryService;
import com.happy.friendogly.common.ApiResponse;
import jakarta.validation.Valid;
import java.util.List;
Expand All @@ -16,10 +16,10 @@
@RequestMapping("/chat-messages")
public class ChatMessageController {

private final ChatQueryService chatQueryService;
private final ChatMessageQueryService chatMessageQueryService;

public ChatMessageController(ChatQueryService chatQueryService) {
this.chatQueryService = chatQueryService;
public ChatMessageController(ChatMessageQueryService chatMessageQueryService) {
this.chatMessageQueryService = chatMessageQueryService;
}

// TODO: 전체 조회 API 필요성 논의 필요, 만약 필요하다면 페이징을 통한 성능 개선 필요
Expand All @@ -28,7 +28,7 @@ public ApiResponse<List<FindChatMessagesResponse>> findAllByChatRoomId(
@Auth Long memberId,
@PathVariable("chatRoomId") Long chatRoomId
) {
return ApiResponse.ofSuccess(chatQueryService.findAllByChatRoomId(memberId, chatRoomId));
return ApiResponse.ofSuccess(chatMessageQueryService.findAllByChatRoomId(memberId, chatRoomId));
}

@GetMapping("/{chatRoomId}/times")
Expand All @@ -37,6 +37,6 @@ public ApiResponse<List<FindChatMessagesResponse>> findAllByTimeRange(
@Valid FindMessagesByTimeRangeRequest request,
@PathVariable("chatRoomId") Long chatRoomId
) {
return ApiResponse.ofSuccess(chatQueryService.findByTimeRange(memberId, chatRoomId, request));
return ApiResponse.ofSuccess(chatMessageQueryService.findByTimeRange(memberId, chatRoomId, request));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatmessage.domain;

import com.happy.friendogly.chatsocket.domain.MessageType;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.member.domain.Member;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.request;
package com.happy.friendogly.chatmessage.dto.request;

import jakarta.validation.constraints.Past;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatmessage.dto.response;

import com.happy.friendogly.chat.domain.ChatMessage;
import com.happy.friendogly.chat.domain.MessageType;
import com.happy.friendogly.chatmessage.domain.ChatMessage;
import com.happy.friendogly.chatsocket.domain.MessageType;
import java.time.LocalDateTime;

public record FindChatMessagesResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.happy.friendogly.chat.repository;
package com.happy.friendogly.chatmessage.repository;

import com.happy.friendogly.chat.domain.ChatMessage;
import com.happy.friendogly.chatmessage.domain.ChatMessage;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.jpa.repository.EntityGraph;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.happy.friendogly.chat.service;
package com.happy.friendogly.chatmessage.service;

import static org.springframework.http.HttpStatus.FORBIDDEN;

import com.happy.friendogly.chat.domain.ChatMessage;
import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chat.dto.request.FindMessagesByTimeRangeRequest;
import com.happy.friendogly.chat.dto.response.FindChatMessagesResponse;
import com.happy.friendogly.chat.repository.ChatMessageRepository;
import com.happy.friendogly.chat.repository.ChatRoomRepository;
import com.happy.friendogly.chatmessage.domain.ChatMessage;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.chatmessage.dto.request.FindMessagesByTimeRangeRequest;
import com.happy.friendogly.chatmessage.dto.response.FindChatMessagesResponse;
import com.happy.friendogly.chatmessage.repository.ChatMessageRepository;
import com.happy.friendogly.chatroom.repository.ChatRoomRepository;
import com.happy.friendogly.exception.FriendoglyException;
import com.happy.friendogly.member.domain.Member;
import com.happy.friendogly.member.repository.MemberRepository;
Expand All @@ -18,13 +18,13 @@

@Service
@Transactional(readOnly = true)
public class ChatQueryService {
public class ChatMessageQueryService {

private final ChatMessageRepository chatMessageRepository;
private final MemberRepository memberRepository;
private final ChatRoomRepository chatRoomRepository;

public ChatQueryService(
public ChatMessageQueryService(
ChatMessageRepository chatMessageRepository,
MemberRepository memberRepository,
ChatRoomRepository chatRoomRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.happy.friendogly.chat.controller;
package com.happy.friendogly.chatroom.controller;

import com.happy.friendogly.auth.Auth;
import com.happy.friendogly.chat.dto.request.SaveChatRoomRequest;
import com.happy.friendogly.chat.dto.response.FindChatRoomMembersInfoResponse;
import com.happy.friendogly.chat.dto.response.FindClubDetailsResponse;
import com.happy.friendogly.chat.dto.response.FindMyChatRoomResponse;
import com.happy.friendogly.chat.dto.response.SaveChatRoomResponse;
import com.happy.friendogly.chat.service.ChatRoomCommandService;
import com.happy.friendogly.chat.service.ChatRoomQueryService;
import com.happy.friendogly.chatroom.dto.request.SaveChatRoomRequest;
import com.happy.friendogly.chatroom.dto.response.FindChatRoomMembersInfoResponse;
import com.happy.friendogly.chatroom.dto.response.FindClubDetailsResponse;
import com.happy.friendogly.chatroom.dto.response.FindMyChatRoomResponse;
import com.happy.friendogly.chatroom.dto.response.SaveChatRoomResponse;
import com.happy.friendogly.chatroom.service.ChatRoomCommandService;
import com.happy.friendogly.chatroom.service.ChatRoomQueryService;
import com.happy.friendogly.common.ApiResponse;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatroom.domain;

import com.happy.friendogly.exception.FriendoglyException;
import com.happy.friendogly.member.domain.Member;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatroom.domain;

import com.happy.friendogly.member.domain.Member;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatroom.domain;

public enum ChatRoomType {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatroom.domain;

import com.happy.friendogly.exception.FriendoglyException;
import jakarta.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.request;
package com.happy.friendogly.chatroom.dto.request;

public record InviteToChatRoomRequest(
Long receiverMemberId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.request;
package com.happy.friendogly.chatroom.dto.request;

public record SaveChatRoomRequest(Long otherMemberId) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chatroom.domain.ChatRoom;

public record ChatRoomDetail(
Long chatRoomId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

import com.happy.friendogly.member.domain.Member;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

import com.happy.friendogly.club.domain.Club;
import com.happy.friendogly.pet.domain.Gender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

public record InviteToChatRoomResponse(Long chatRoomId) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.response;
package com.happy.friendogly.chatroom.dto.response;

public record SaveChatRoomResponse(Long chatRoomId) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.happy.friendogly.chat.repository;
package com.happy.friendogly.chatroom.repository;

import com.happy.friendogly.chat.domain.ChatRoomMember;
import com.happy.friendogly.chatroom.domain.ChatRoomMember;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ChatRoomMemberRepository extends JpaRepository<ChatRoomMember, Long> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.happy.friendogly.chat.repository;
package com.happy.friendogly.chatroom.repository;

import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.exception.FriendoglyException;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.happy.friendogly.chat.service;
package com.happy.friendogly.chatroom.service;

import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chat.dto.request.SaveChatRoomRequest;
import com.happy.friendogly.chat.dto.response.SaveChatRoomResponse;
import com.happy.friendogly.chat.repository.ChatRoomRepository;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.chatroom.dto.request.SaveChatRoomRequest;
import com.happy.friendogly.chatroom.dto.response.SaveChatRoomResponse;
import com.happy.friendogly.chatroom.repository.ChatRoomRepository;
import com.happy.friendogly.chatsocket.service.ChatSocketCommandService;
import com.happy.friendogly.member.domain.Member;
import com.happy.friendogly.member.repository.MemberRepository;
import java.util.List;
Expand All @@ -18,16 +19,16 @@ public class ChatRoomCommandService {
private final ChatRoomRepository chatRoomRepository;
private final MemberRepository memberRepository;

private final ChatCommandService chatCommandService;
private final ChatSocketCommandService chatSocketCommandService;

public ChatRoomCommandService(
ChatRoomRepository chatRoomRepository,
MemberRepository memberRepository,
ChatCommandService chatCommandService
ChatSocketCommandService chatSocketCommandService
) {
this.chatRoomRepository = chatRoomRepository;
this.memberRepository = memberRepository;
this.chatCommandService = chatCommandService;
this.chatSocketCommandService = chatSocketCommandService;
}

public SaveChatRoomResponse savePrivate(Long memberId, SaveChatRoomRequest request) {
Expand All @@ -52,6 +53,6 @@ public void leave(Long memberId, Long chatRoomId) {
Member member = memberRepository.getById(memberId);
chatRoom.removeMember(member);

chatCommandService.sendLeave(memberId, chatRoomId);
chatSocketCommandService.sendLeave(memberId, chatRoomId);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.happy.friendogly.chat.service;
package com.happy.friendogly.chatroom.service;

import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chat.dto.request.InviteToChatRoomRequest;
import com.happy.friendogly.chat.dto.response.ChatRoomDetail;
import com.happy.friendogly.chat.dto.response.FindChatRoomMembersInfoResponse;
import com.happy.friendogly.chat.dto.response.FindClubDetailsResponse;
import com.happy.friendogly.chat.dto.response.FindMyChatRoomResponse;
import com.happy.friendogly.chat.repository.ChatRoomRepository;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.chatroom.dto.request.InviteToChatRoomRequest;
import com.happy.friendogly.chatroom.dto.response.ChatRoomDetail;
import com.happy.friendogly.chatroom.dto.response.FindChatRoomMembersInfoResponse;
import com.happy.friendogly.chatroom.dto.response.FindClubDetailsResponse;
import com.happy.friendogly.chatroom.dto.response.FindMyChatRoomResponse;
import com.happy.friendogly.chatroom.repository.ChatRoomRepository;
import com.happy.friendogly.club.domain.Club;
import com.happy.friendogly.club.repository.ClubRepository;
import com.happy.friendogly.exception.FriendoglyException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.config;
package com.happy.friendogly.chatsocket.config;

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.config;
package com.happy.friendogly.chatsocket.config;

import static com.happy.friendogly.common.ErrorCode.DEFAULT_ERROR_CODE;
import static org.springframework.messaging.simp.stomp.StompCommand.ERROR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.happy.friendogly.config;
package com.happy.friendogly.chatsocket.config;

import static org.springframework.http.HttpHeaders.AUTHORIZATION;
import static org.springframework.messaging.simp.stomp.StompCommand.SUBSCRIBE;

import com.happy.friendogly.auth.service.jwt.JwtProvider;
import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chat.repository.ChatRoomMemberRepository;
import com.happy.friendogly.chat.repository.ChatRoomRepository;
import com.happy.friendogly.chatroom.domain.ChatRoom;
import com.happy.friendogly.chatroom.repository.ChatRoomMemberRepository;
import com.happy.friendogly.chatroom.repository.ChatRoomRepository;
import com.happy.friendogly.club.repository.ClubRepository;
import com.happy.friendogly.exception.FriendoglyException;
import com.happy.friendogly.exception.FriendoglyWebSocketException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.config;
package com.happy.friendogly.chatsocket.config;

import com.happy.friendogly.auth.WebSocketArgumentResolver;
import com.happy.friendogly.auth.service.jwt.JwtProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.config;
package com.happy.friendogly.chatsocket.config;

import com.happy.friendogly.auth.WebSocketArgumentResolver;
import com.happy.friendogly.auth.service.jwt.JwtProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.happy.friendogly.chat.controller;
package com.happy.friendogly.chatsocket.controller;

import com.happy.friendogly.auth.WebSocketAuth;
import com.happy.friendogly.chat.dto.request.ChatMessageSocketRequest;
import com.happy.friendogly.chat.dto.request.InviteToChatRoomRequest;
import com.happy.friendogly.chat.dto.response.InviteToChatRoomResponse;
import com.happy.friendogly.chat.service.ChatCommandService;
import com.happy.friendogly.chat.service.ChatRoomQueryService;
import com.happy.friendogly.chatsocket.dto.request.ChatMessageSocketRequest;
import com.happy.friendogly.chatroom.dto.request.InviteToChatRoomRequest;
import com.happy.friendogly.chatsocket.service.ChatSocketCommandService;
import com.happy.friendogly.chatroom.service.ChatRoomQueryService;
import com.happy.friendogly.common.ApiResponse;
import com.happy.friendogly.common.ErrorCode;
import com.happy.friendogly.common.ErrorResponse;
Expand All @@ -21,14 +20,14 @@
@RestController
public class ChatSocketController {

private final ChatCommandService chatCommandService;
private final ChatSocketCommandService chatSocketCommandService;
private final ChatRoomQueryService chatRoomQueryService;

public ChatSocketController(
ChatCommandService chatCommandService,
ChatSocketCommandService chatSocketCommandService,
ChatRoomQueryService chatRoomQueryService
) {
this.chatCommandService = chatCommandService;
this.chatSocketCommandService = chatSocketCommandService;
this.chatRoomQueryService = chatRoomQueryService;
}

Expand All @@ -50,7 +49,7 @@ public void sendMessage(
@DestinationVariable(value = "chatRoomId") Long chatRoomId,
@Payload ChatMessageSocketRequest request
) {
chatCommandService.sendChat(memberId, chatRoomId, request);
chatSocketCommandService.sendChat(memberId, chatRoomId, request);
}

@MessageExceptionHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.domain;
package com.happy.friendogly.chatsocket.domain;

public enum MessageType {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.happy.friendogly.chat.dto.request;
package com.happy.friendogly.chatsocket.dto.request;

public record ChatMessageSocketRequest(String content) {

Expand Down
Loading

0 comments on commit 9fc6c9b

Please sign in to comment.