-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[feat] 채팅 상세 조회 API
- Loading branch information
Showing
7 changed files
with
144 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/com/psr/psr/chat/dto/response/ChatMessageRes.kt
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,34 @@ | ||
package com.psr.psr.chat.dto.response | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat | ||
import com.psr.psr.chat.entity.ChatMessage | ||
import com.psr.psr.user.entity.User | ||
import com.querydsl.core.annotations.QueryProjection | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDateTime | ||
|
||
data class ChatMessageRes @QueryProjection constructor( | ||
|
||
@Schema(description = "본인이 보낸 메시지 여부", example = "false") | ||
val isSend: Boolean, | ||
|
||
@Schema(description = "메시지", example = "안녕하세요!") | ||
val message: String, | ||
|
||
@Schema(description = "메시지 보낸 시간", example = "11:30") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:MM") | ||
val date: LocalDateTime, | ||
|
||
) { | ||
companion object { | ||
fun toDto(user: User, chatMessage: ChatMessage): ChatMessageRes { | ||
val isSend: Boolean = chatMessage.senderUser == user | ||
return ChatMessageRes( | ||
isSend, | ||
chatMessage.message, | ||
chatMessage.createdAt | ||
) | ||
|
||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/psr/psr/chat/dto/response/ChatMessagesRes.kt
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,23 @@ | ||
package com.psr.psr.chat.dto.response | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDate | ||
|
||
data class ChatMessagesRes( | ||
@Schema(description = "최근 메시지 날짜", example = "11.30") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "YYYY년 MM월 dd일") | ||
val date: LocalDate? = null, | ||
|
||
@Schema(description = "메시지 리스트") | ||
val chatMessages: List<ChatMessageRes>? | ||
) { | ||
companion object { | ||
fun toDto(standardDate: LocalDate, messagesOfDate: List<ChatMessageRes>): ChatMessagesRes { | ||
return ChatMessagesRes( | ||
standardDate, | ||
messagesOfDate | ||
) | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/psr/psr/chat/dto/response/GetChatMessagesRes.kt
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.psr.psr.chat.dto.response | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class GetChatMessagesRes( | ||
@Schema(description = "채팅 시작된 게시글 이름", example = "목도리") | ||
val productName: String? = null, | ||
|
||
@Schema(description = "날짜별 리스트") | ||
val chatMessagesOfDate: List<ChatMessagesRes>? | ||
) { | ||
companion object { | ||
fun toDto(name: String, chatMessages: List<ChatMessagesRes>?): GetChatMessagesRes { | ||
return GetChatMessagesRes( | ||
name, | ||
chatMessages | ||
) | ||
} | ||
|
||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/com/psr/psr/chat/repository/ChatMessageCustom.kt
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,11 +1,13 @@ | ||
package com.psr.psr.chat.repository | ||
|
||
import com.psr.psr.chat.dto.response.GetChatRoomsRes | ||
import com.psr.psr.chat.dto.response.ChatMessagesRes | ||
import com.psr.psr.chat.entity.ChatRoom | ||
import com.psr.psr.user.entity.User | ||
|
||
|
||
interface ChatMessageCustom { | ||
fun getRecentChat(user: User, chatRooms: List<ChatRoom>): GetChatRoomsRes? | ||
fun getChatMessages(user: User, chatRoom: ChatRoom): List<ChatMessagesRes>? | ||
|
||
} |
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