-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MATE-150 : [REFACTOR] 굿즈거래 채팅 엔티티 MongoDB로 마이그레이션 (#136)
* MATE-150 : [FEAT] 굿즈거래 채팅 엔티티를 MongoDB 도큐먼트로 변경 * MATE-150 : [FEAT] 굿즈거래 채팅 레포지토리 리팩토링 - MongoRepository 구현체로 변경 - 채팅 조회 메서드(쿼리) 구현 - Spring Data MongoDB 를 사용해 채팅 삭제 기능 구현 * MATE-150 : [REFACTOR] 엔티티 변경에 따른 DTO 및 Service 레이어 리팩토링 * MATE-150 : [FEAT] 테스트용 인메모리 MongoDB 사용을 위한 bwaldvogel 의존성 추가 * MATE-150 : [TEST] 인메모리 MongoDB 사용을 위한 설정 클래스 구현 - 가짜 MongoDB 서버 설정 정보를 담는 MongoTestServerConfig 클래스 구현 - MongoTestServerConfig 를 Import 하는 EnableMongoTestServer 어노테이션 구현 * MATE-150 : [TEST] MongoDB 통합테스트에 사용하는 AcceptanceTestWithMongo 추상 클래스 구현 * MATE-150 : [CHORE] 시큐리티 관련 테스트 설정 클래스를 securityConfig 패키지로 이관 * MATE-150 : [TEST] 패키지 이관 및 DB 변경에 따른 테스트 코드 수정 * MATE-150 : [REFACTOR] GoodsChatMessageService 클래스에서 GoodsParts 엔티티 의존성 제거 * MATE-150 : [TEST] 의존성 제거에 따른 테스트 코드 수정 * MATE-150 : [!BUGFIX] 코드 충돌 해결
- Loading branch information
Showing
37 changed files
with
284 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/example/mate/domain/goodsChat/document/GoodsChatMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.mate.domain.goodsChat.document; | ||
|
||
import com.example.mate.domain.constant.MessageType; | ||
import java.time.LocalDateTime; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
import org.springframework.data.mongodb.core.mapping.Field; | ||
|
||
@Getter | ||
@Builder | ||
@Document(collection = "goods_chat_message") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class GoodsChatMessage { | ||
|
||
@Id | ||
private String id; | ||
|
||
@Field(name = "chat_room_id") | ||
private Long chatRoomId; | ||
|
||
@Field(name = "member_id") | ||
private Long memberId; | ||
|
||
@Field(name = "content") | ||
private String content; | ||
|
||
@Field(name = "sent_at") | ||
private LocalDateTime sentAt; | ||
|
||
@Field(name = "message_type") | ||
private MessageType messageType; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
src/main/java/com/example/mate/domain/goodsChat/entity/GoodsChatMessage.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
src/main/java/com/example/mate/domain/goodsChat/repository/GoodsChatMessageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package com.example.mate.domain.goodsChat.repository; | ||
|
||
import com.example.mate.domain.goodsChat.entity.GoodsChatMessage; | ||
import com.example.mate.domain.goodsChat.document.GoodsChatMessage; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.mongodb.repository.Query; | ||
|
||
public interface GoodsChatMessageRepository extends JpaRepository<GoodsChatMessage, Long> { | ||
public interface GoodsChatMessageRepository extends MongoRepository<GoodsChatMessage, String> { | ||
|
||
@Query(""" | ||
SELECT cm | ||
FROM GoodsChatMessage cm | ||
WHERE cm.goodsChatPart.goodsChatRoom.id = :chatRoomId | ||
ORDER BY cm.sentAt DESC | ||
""") | ||
Page<GoodsChatMessage> getChatMessages(@Param("chatRoomId") Long chatRoomId, Pageable pageable); | ||
/** | ||
* 특정 채팅방의 메시지를 페이징 처리하여 조회합니다. | ||
* 메시지는 전송된 시간(sent_at) 기준으로 오름차순으로 정렬됩니다. | ||
*/ | ||
@Query(value = "{ 'chat_room_id': ?0 }", sort = "{ 'sent_at': -1 }") | ||
Page<GoodsChatMessage> getChatMessages(Long chatRoomId, Pageable pageable); | ||
|
||
void deleteAllByChatRoomId(Long chatRoomId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.