-
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.
- Loading branch information
Showing
21 changed files
with
758 additions
and
3 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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/hsu/shimpyoo/domain/chatbot/entity/Chat.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,37 @@ | ||
package com.hsu.shimpyoo.domain.chatbot.entity; | ||
|
||
import com.hsu.shimpyoo.domain.user.entity.User; | ||
import com.hsu.shimpyoo.global.entity.BaseEntity; | ||
import com.hsu.shimpyoo.global.enums.TFStatus; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name="CHAT") | ||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Chat extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "chat_id") | ||
private Long chatId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User userId; // 사용자 기본키 | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name="chatting_room_id", nullable = false) | ||
private ChatRoom chatRoomId; // 채팅방 기본키 | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name="is_send") | ||
private TFStatus isSend; // 수신 여부 (true -> 받은 메시지, false -> 보낸 메시지) | ||
|
||
@Column(name="content", columnDefinition = "TEXT") | ||
private String content; // 메시지의 내용 | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/hsu/shimpyoo/domain/chatbot/entity/ChatRoom.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,28 @@ | ||
package com.hsu.shimpyoo.domain.chatbot.entity; | ||
|
||
import com.hsu.shimpyoo.domain.user.entity.User; | ||
import com.hsu.shimpyoo.global.entity.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Table(name="CHAT_ROOM") | ||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ChatRoom extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "chat_room_id") | ||
private Long chatRoomId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User userId; // 사용자 기본키 | ||
|
||
@Column(name="chat_title") | ||
private String chatTitle; // 채팅방 제목 | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/hsu/shimpyoo/domain/chatbot/repository/ChatRepository.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 com.hsu.shimpyoo.domain.chatbot.repository; | ||
|
||
import com.hsu.shimpyoo.domain.chatbot.entity.Chat; | ||
import com.hsu.shimpyoo.domain.chatbot.entity.ChatRoom; | ||
import com.hsu.shimpyoo.domain.user.entity.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ChatRepository extends JpaRepository<Chat, Long> { | ||
// 사용자 기본키와 채팅방 기본키로 검색하여 가장 최근의 메시지 반환 | ||
Optional<Chat> findTopByUserIdAndChatRoomIdOrderByCreatedAtDesc(User user, ChatRoom chatRoom); | ||
|
||
// 채팅방에서 채팅 상세 조회 | ||
List<Chat> findChatByUserIdAndChatRoomId(User user, ChatRoom chatRoom); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hsu/shimpyoo/domain/chatbot/repository/ChatRoomRepository.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,21 @@ | ||
package com.hsu.shimpyoo.domain.chatbot.repository; | ||
|
||
import com.hsu.shimpyoo.domain.chatbot.entity.ChatRoom; | ||
import com.hsu.shimpyoo.domain.user.entity.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> { | ||
// 사용자의 모든 채팅방 조회 | ||
List<ChatRoom> findChatRoomByUserId(User user); | ||
|
||
// 채팅방 기본키로 채팅방 조회 | ||
Optional<ChatRoom> findChatRoomByChatRoomId(Long id); | ||
|
||
// 채팅방 제목에 키워드가 포함된 채팅방 조회 | ||
List<ChatRoom> findChatRoomByChatTitleContainingAndUserId(String keyword, User user); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/hsu/shimpyoo/domain/chatbot/service/ChatRoomService.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,22 @@ | ||
package com.hsu.shimpyoo.domain.chatbot.service; | ||
|
||
import com.hsu.shimpyoo.domain.chatbot.web.dto.ModifyChatRoomTitleDto; | ||
import com.hsu.shimpyoo.global.response.CustomAPIResponse; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
public interface ChatRoomService { | ||
// 채팅방 생성 | ||
ResponseEntity<CustomAPIResponse<?>> makeChatRoom(); | ||
|
||
// 채팅방 제목 수정 | ||
ResponseEntity<CustomAPIResponse<?>> modifyChatRoomTitle(ModifyChatRoomTitleDto requestDto); | ||
|
||
// 채팅방 목록 조회 | ||
ResponseEntity<CustomAPIResponse<?>> getAllChatRooms(); | ||
|
||
// 채팅방 대화 내역 조회 | ||
ResponseEntity<CustomAPIResponse<?>> getChat(Long chatRoomId); | ||
|
||
// 채팅방 제목으로 검색 | ||
ResponseEntity<CustomAPIResponse<?>> getChatRoomByKeyword(String keyword); | ||
} |
Oops, something went wrong.