-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
c806f25
commit f5db1c9
Showing
46 changed files
with
775 additions
and
62 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
29 changes: 29 additions & 0 deletions
29
android/app/src/main/java/com/happy/friendogly/data/mapper/ChatMemberMapper.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,29 @@ | ||
package com.happy.friendogly.data.mapper | ||
|
||
import com.happy.friendogly.data.model.ChatMemberDto | ||
import com.happy.friendogly.data.model.ChatRoomListDto | ||
import com.happy.friendogly.domain.model.ChatMember | ||
import com.happy.friendogly.domain.model.ChatRoom | ||
import com.happy.friendogly.domain.model.ChatRooms | ||
|
||
fun ChatMemberDto.toDomain(): ChatMember = | ||
ChatMember( | ||
isOwner = isOwner, | ||
memberId = memberId, | ||
memberName = memberName, | ||
memberProfileImageUrl = memberProfileImageUrl, | ||
) | ||
|
||
fun ChatRoomListDto.toDomain(): ChatRooms = | ||
ChatRooms( | ||
myMemberId = myMemberId, | ||
chatRooms = | ||
chatRooms.map { | ||
ChatRoom( | ||
chatRoomId = it.chatRoomId, | ||
clubName = it.clubName, | ||
memberCount = it.memberCount, | ||
clubImageUrl = it.clubImageUrl, | ||
) | ||
}, | ||
) |
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/com/happy/friendogly/data/mapper/MessageMapper.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,30 @@ | ||
package com.happy.friendogly.data.mapper | ||
|
||
import com.happy.friendogly.data.model.MessageDto | ||
import com.happy.friendogly.domain.model.ChatComponent | ||
import com.happy.friendogly.domain.model.Message | ||
|
||
fun MessageDto.toOther(): Message.Other = | ||
Message.Other( | ||
memberId = senderMemberId, | ||
name = senderName, | ||
content = content!!, | ||
dateTime = createdAt, | ||
profileUrl = profilePictureUrl, | ||
) | ||
|
||
fun MessageDto.toMine(): Message.Mine = | ||
Message.Mine( | ||
content = content!!, | ||
dateTime = createdAt, | ||
) | ||
|
||
fun MessageDto.toEnter(): ChatComponent.Enter = | ||
ChatComponent.Enter( | ||
name = senderName, | ||
) | ||
|
||
fun MessageDto.toLeave(): ChatComponent.Leave = | ||
ChatComponent.Leave( | ||
name = senderName, | ||
) |
8 changes: 8 additions & 0 deletions
8
android/app/src/main/java/com/happy/friendogly/data/model/ChatMemberDto.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,8 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
data class ChatMemberDto( | ||
val isOwner: Boolean, | ||
val memberId: Long, | ||
val memberName: String, | ||
val memberProfileImageUrl: String, | ||
) |
8 changes: 8 additions & 0 deletions
8
android/app/src/main/java/com/happy/friendogly/data/model/ChatRoomDto.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,8 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
data class ChatRoomDto( | ||
val chatRoomId: Long, | ||
val clubName: String, | ||
val memberCount: Int, | ||
val clubImageUrl: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/happy/friendogly/data/model/ChatRoomListDto.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,6 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
data class ChatRoomListDto( | ||
val myMemberId: Long, | ||
val chatRooms: List<ChatRoomDto>, | ||
) |
12 changes: 12 additions & 0 deletions
12
android/app/src/main/java/com/happy/friendogly/data/model/MessageDto.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,12 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class MessageDto( | ||
val messageType: MessageTypeDto, | ||
val senderMemberId: Long, | ||
val senderName: String, | ||
val content: String?, | ||
val createdAt: LocalDateTime, | ||
val profilePictureUrl: String?, | ||
) |
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/com/happy/friendogly/data/model/MessageTypeDto.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,7 @@ | ||
package com.happy.friendogly.data.model | ||
|
||
enum class MessageTypeDto { | ||
ENTER, | ||
CHAT, | ||
LEAVE, | ||
} |
20 changes: 20 additions & 0 deletions
20
android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.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,20 @@ | ||
package com.happy.friendogly.data.repository | ||
|
||
import com.happy.friendogly.data.mapper.toDomain | ||
import com.happy.friendogly.domain.model.ChatMember | ||
import com.happy.friendogly.domain.model.ChatRooms | ||
import com.happy.friendogly.domain.repository.ChatRepository | ||
import com.happy.friendogly.remote.api.ChatService | ||
import com.happy.friendogly.remote.mapper.toData | ||
|
||
class ChatRepositoryImpl(private val service: ChatService) : ChatRepository { | ||
override suspend fun getChatList(): Result<ChatRooms> = | ||
runCatching { | ||
service.getChatList().data.toData().toDomain() | ||
} | ||
|
||
override suspend fun getMembers(chatRoomId: Long): Result<List<ChatMember>> = | ||
runCatching { | ||
service.getChatMembers(chatRoomId).data.map { it.toData() }.map { it.toDomain() } | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
android/app/src/main/java/com/happy/friendogly/data/repository/WebSocketRepositoryImpl.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,31 @@ | ||
package com.happy.friendogly.data.repository | ||
|
||
import com.happy.friendogly.data.mapper.toEnter | ||
import com.happy.friendogly.data.mapper.toLeave | ||
import com.happy.friendogly.data.mapper.toOther | ||
import com.happy.friendogly.data.model.MessageTypeDto | ||
import com.happy.friendogly.data.source.WebSocketDataSource | ||
import com.happy.friendogly.domain.model.ChatComponent | ||
import com.happy.friendogly.domain.repository.WebSocketRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
|
||
class WebSocketRepositoryImpl(private val source: WebSocketDataSource) : WebSocketRepository { | ||
override suspend fun publishInvite(memberId: Long) = source.publishInvite(memberId) | ||
|
||
override suspend fun publishSend( | ||
chatRoomId: Long, | ||
content: String, | ||
) = source.publishSend(chatRoomId, content) | ||
|
||
override suspend fun publishLeave(chatRoomId: Long) = source.publishLeave(chatRoomId) | ||
|
||
override suspend fun subscribeMessage(chatRoomId: Long): Flow<ChatComponent> = | ||
source.subscribeMessage(chatRoomId).map { | ||
when (it.messageType) { | ||
MessageTypeDto.ENTER -> it.toEnter() | ||
MessageTypeDto.LEAVE -> it.toLeave() | ||
MessageTypeDto.CHAT -> it.toOther() | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
android/app/src/main/java/com/happy/friendogly/data/source/WebSocketDataSource.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,17 @@ | ||
package com.happy.friendogly.data.source | ||
|
||
import com.happy.friendogly.data.model.MessageDto | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface WebSocketDataSource { | ||
suspend fun publishInvite(memberId: Long) | ||
|
||
suspend fun publishSend( | ||
chatRoomId: Long, | ||
content: String, | ||
) | ||
|
||
suspend fun publishLeave(chatRoomId: Long) | ||
|
||
suspend fun subscribeMessage(chatRoomId: Long): Flow<MessageDto> | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/happy/friendogly/domain/model/ChatComponent.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,11 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
import java.time.LocalDate | ||
|
||
sealed interface ChatComponent { | ||
data class Date(val created: LocalDate) : ChatComponent | ||
|
||
data class Enter(val name: String) : ChatComponent | ||
|
||
data class Leave(val name: String) : ChatComponent | ||
} |
8 changes: 8 additions & 0 deletions
8
android/app/src/main/java/com/happy/friendogly/domain/model/ChatMember.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,8 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
data class ChatMember( | ||
val isOwner: Boolean, | ||
val memberId: Long, | ||
val memberName: String, | ||
val memberProfileImageUrl: String, | ||
) |
8 changes: 8 additions & 0 deletions
8
android/app/src/main/java/com/happy/friendogly/domain/model/ChatRoom.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,8 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
data class ChatRoom( | ||
val chatRoomId: Long, | ||
val clubName: String, | ||
val memberCount: Int, | ||
val clubImageUrl: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/happy/friendogly/domain/model/ChatRooms.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,6 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
data class ChatRooms( | ||
val myMemberId: Long, | ||
val chatRooms: List<ChatRoom>, | ||
) |
20 changes: 20 additions & 0 deletions
20
android/app/src/main/java/com/happy/friendogly/domain/model/Message.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,20 @@ | ||
package com.happy.friendogly.domain.model | ||
|
||
import java.time.LocalDateTime | ||
|
||
sealed interface Message : ChatComponent { | ||
val content: String | ||
|
||
data class Mine( | ||
override val content: String, | ||
val dateTime: LocalDateTime, | ||
) : Message | ||
|
||
data class Other( | ||
val memberId: Long, | ||
val name: String, | ||
override val content: String, | ||
val dateTime: LocalDateTime, | ||
val profileUrl: String?, | ||
) : Message | ||
} |
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/happy/friendogly/domain/repository/ChatRepository.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,10 @@ | ||
package com.happy.friendogly.domain.repository | ||
|
||
import com.happy.friendogly.domain.model.ChatMember | ||
import com.happy.friendogly.domain.model.ChatRooms | ||
|
||
interface ChatRepository { | ||
suspend fun getChatList(): Result<ChatRooms> | ||
|
||
suspend fun getMembers(chatRoomId: Long): Result<List<ChatMember>> | ||
} |
17 changes: 17 additions & 0 deletions
17
android/app/src/main/java/com/happy/friendogly/domain/repository/WebSocketRepository.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,17 @@ | ||
package com.happy.friendogly.domain.repository | ||
|
||
import com.happy.friendogly.domain.model.ChatComponent | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface WebSocketRepository { | ||
suspend fun publishInvite(chatRoomId: Long) | ||
|
||
suspend fun publishSend( | ||
chatRoomId: Long, | ||
content: String, | ||
) | ||
|
||
suspend fun publishLeave(chatRoomId: Long) | ||
|
||
suspend fun subscribeMessage(chatRoomId: Long): Flow<ChatComponent> | ||
} |
Oops, something went wrong.