-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from Geek-sasaeng/tomas
Tomas [feat]:채팅 전송 API(Chat, PartyChatRoomMember 엔티티 여러 필드 추가, createCha… …t메소드 세부 로직 모두 반영)
- Loading branch information
Showing
11 changed files
with
162 additions
and
78 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package shop.geeksasang.dto.chat; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import shop.geeksasang.domain.chat.Chat; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class PostChatRes { | ||
|
||
private String chatId; | ||
|
||
@NotEmpty | ||
private String content; | ||
|
||
@NotEmpty | ||
private String chatRoomId; | ||
|
||
private Boolean isSystemMessage; | ||
|
||
private int memberId; | ||
|
||
private String email; | ||
|
||
private String profileImgUrl; | ||
|
||
private List<Integer> readMembers = new ArrayList<>(); // 읽은 멤버 ID 리스트 | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") | ||
private LocalDateTime createdAt; | ||
|
||
public PostChatRes(String chatRoomId, String content, LocalDateTime createdAt, int memberId) { | ||
this.chatRoomId = chatRoomId; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
this.memberId = memberId; | ||
} | ||
|
||
public PostChatRes(String email, String chatRoomId, String content, LocalDateTime createdAt, int memberId) { | ||
this.email = email; | ||
this.chatRoomId = chatRoomId; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
this.memberId = memberId; | ||
} | ||
|
||
@Builder | ||
public PostChatRes(String chatId, String content, String chatRoomId, Boolean isSystemMessage, int memberId, String email, String profileImgUrl, List<Integer> readMembers, LocalDateTime createdAt) { | ||
this.chatId = chatId; | ||
this.content = content; | ||
this.chatRoomId = chatRoomId; | ||
this.isSystemMessage = isSystemMessage; | ||
this.memberId = memberId; | ||
this.email = email; | ||
this.profileImgUrl = profileImgUrl; | ||
this.readMembers = readMembers; | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public static PostChatRes toDto(Chat chat, String email){ | ||
return PostChatRes.builder() | ||
.chatId(chat.getId()) | ||
.content(chat.getContent()) | ||
.chatRoomId(chat.getPartyChatRoom().getId()) | ||
.isSystemMessage(chat.getIsSystemMessage()) | ||
.memberId(chat.getPartyChatRoomMember().getMemberId()) | ||
.email(chat.getPartyChatRoomMember().getEmail()) | ||
.profileImgUrl(chat.getProfileImgUrl()) | ||
.readMembers(chat.getReadMembers()) | ||
.createdAt(chat.getBaseEntityMongo().getCreatedAt()) | ||
.build(); | ||
} | ||
} |
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: 0 additions & 39 deletions
39
src/main/java/shop/geeksasang/dto/chat/PostChattingRes.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
19 changes: 19 additions & 0 deletions
19
src/main/java/shop/geeksasang/repository/chat/PartyChatRoomMemberRepository.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,19 @@ | ||
package shop.geeksasang.repository.chat; | ||
|
||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
import shop.geeksasang.domain.chat.PartyChatRoomMember; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface PartyChatRoomMemberRepository extends MongoRepository<PartyChatRoomMember, String> { | ||
|
||
|
||
@Query(value = "{ 'memberId' : ?0 , 'chatRoomId': ?1 , 'status' : 'ACTIVE'}") | ||
Optional<PartyChatRoomMember> findByMemberIdAndChatRoomId(int memberId, String chatRoomId); | ||
|
||
// @Query(value="{ 'firstname' : ?0 }", fields="{ 'firstname' : 1, 'lastname' : 1}") | ||
// List<Person> findByThePersonsFirstname(String firstname); | ||
} |
Oops, something went wrong.