Skip to content

Commit ad76809

Browse files
authored
[Feat/#102] 모집/참여 내역 리스트 api 연동
1 parent 0aa424d commit ad76809

File tree

20 files changed

+231
-65
lines changed

20 files changed

+231
-65
lines changed

app/src/main/java/com/poti/android/data/di/RepositoryModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import com.poti.android.data.repository.ArtistRepositoryImpl
44
import com.poti.android.data.repository.AuthRepositoryImpl
55
import com.poti.android.data.repository.HomeRepositoryImpl
66
import com.poti.android.data.repository.ImageRepositoryImpl
7+
import com.poti.android.data.repository.ParticipationRepositoryImpl
78
import com.poti.android.data.repository.PartyRepositoryImpl
89
import com.poti.android.data.repository.UserRepositoryImpl
910
import com.poti.android.domain.repository.ArtistRepository
1011
import com.poti.android.domain.repository.AuthRepository
1112
import com.poti.android.domain.repository.HomeRepository
1213
import com.poti.android.domain.repository.ImageRepository
14+
import com.poti.android.domain.repository.ParticipationRepository
1315
import com.poti.android.domain.repository.PartyRepository
1416
import com.poti.android.domain.repository.UserRepository
1517
import dagger.Binds
@@ -44,4 +46,8 @@ abstract class RepositoryModule {
4446
@Binds
4547
@Singleton
4648
abstract fun bindHomeRepository(homeRepositoryImpl: HomeRepositoryImpl): HomeRepository
49+
50+
@Binds
51+
@Singleton
52+
abstract fun bindParticipationRepository(participationRepositoryImpl: ParticipationRepositoryImpl): ParticipationRepository
4753
}

app/src/main/java/com/poti/android/data/di/ServiceModule.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.poti.android.data.remote.service.ArtistService
44
import com.poti.android.data.remote.service.AuthService
55
import com.poti.android.data.remote.service.HomeService
66
import com.poti.android.data.remote.service.ImageService
7+
import com.poti.android.data.remote.service.ParticipationService
78
import com.poti.android.data.remote.service.PartyService
89
import com.poti.android.data.remote.service.UserService
910
import dagger.Module
@@ -43,7 +44,11 @@ object ServiceModule {
4344

4445
@Provides
4546
@Singleton
46-
fun providePartyService(retrofit: Retrofit): PartyService {
47-
return retrofit.create(PartyService::class.java)
48-
}
47+
fun providePartyService(retrofit: Retrofit): PartyService =
48+
retrofit.create(PartyService::class.java)
49+
50+
@Provides
51+
@Singleton
52+
fun provideParticipationService(retrofit: Retrofit): ParticipationService =
53+
retrofit.create(ParticipationService::class.java)
4954
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.poti.android.data.mapper.participation
2+
3+
import com.poti.android.data.remote.dto.response.participant.MyPartyListDto
4+
import com.poti.android.data.remote.dto.response.participant.ParticipantDto
5+
import com.poti.android.domain.model.history.MyParticipation
6+
import com.poti.android.domain.model.history.MyPartyList
7+
import com.poti.android.domain.type.HistoryListType
8+
import com.poti.android.domain.type.PartyStatusType
9+
10+
fun MyPartyListDto.toDomain(): MyPartyList = MyPartyList(
11+
currentState = try {
12+
HistoryListType.valueOf(currentStatus)
13+
} catch (e: IllegalArgumentException) {
14+
HistoryListType.IN_PROGRESS
15+
},
16+
inProgressCount = inProgressCount,
17+
completedCount = completedCount,
18+
partyList = participations.map { it.toDomain() },
19+
)
20+
21+
fun ParticipantDto.toDomain(): MyParticipation = MyParticipation(
22+
participationId = participationId,
23+
groupBuyId = groupBuyId,
24+
artistName = artistName,
25+
productName = productName,
26+
thumbnailUrl = thumbnailUrl,
27+
postStatus = try {
28+
PartyStatusType.valueOf(postStatus)
29+
} catch (e: IllegalArgumentException) {
30+
PartyStatusType.COMPLETED
31+
},
32+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.poti.android.data.remote.datasource
2+
3+
import com.poti.android.core.network.model.BaseResponse
4+
import com.poti.android.data.remote.dto.response.participant.MyPartyListDto
5+
import com.poti.android.data.remote.service.ParticipationService
6+
import javax.inject.Inject
7+
8+
class ParticipantRemoteDataSource @Inject constructor(
9+
private val participationService: ParticipationService,
10+
) {
11+
suspend fun getMyPartyList(status: String): BaseResponse<MyPartyListDto> =
12+
participationService.getMyParticipationList(status)
13+
}

app/src/main/java/com/poti/android/data/remote/datasource/PartyRemoteDataSource.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.poti.android.core.network.model.BaseResponse
44
import com.poti.android.data.remote.dto.request.party.CreatePartyRequestDto
55
import com.poti.android.data.remote.dto.request.party.PartyJoinRequestDto
66
import com.poti.android.data.remote.dto.response.artist.ArtistSearchListResponseDto
7+
import com.poti.android.data.remote.dto.response.participant.MyPartyListDto
78
import com.poti.android.data.remote.dto.response.party.CreatePartyResponseDto
89
import com.poti.android.data.remote.dto.response.party.PartyDetailResponseDto
910
import com.poti.android.data.remote.dto.response.party.PartyJoinOptionsDto
@@ -39,4 +40,7 @@ class PartyRemoteDataSource @Inject constructor(
3940

4041
suspend fun postPartyJoin(partyJoinRequest: PartyJoinRequestDto): BaseResponse<PartyJoinResponseDto> =
4142
partyService.postPartyJoin(partyJoinRequest = partyJoinRequest)
43+
44+
suspend fun getMyRecruitList(status: String): BaseResponse<MyPartyListDto> =
45+
partyService.getMyRecruitList(status)
4246
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.poti.android.data.remote.dto.response.participant
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class MyPartyListDto(
8+
@SerialName("currentStatus")
9+
val currentStatus: String,
10+
@SerialName("inProgressCount")
11+
val inProgressCount: Int,
12+
@SerialName("completedCount")
13+
val completedCount: Int,
14+
@SerialName("participations")
15+
val participations: List<ParticipantDto>,
16+
)
17+
18+
@Serializable
19+
data class ParticipantDto(
20+
@SerialName("participationId")
21+
val participationId: Long,
22+
@SerialName("groupBuyId")
23+
val groupBuyId: Long,
24+
@SerialName("artistName")
25+
val artistName: String,
26+
@SerialName("productName")
27+
val productName: String,
28+
@SerialName("thumbnailUrl")
29+
val thumbnailUrl: String?,
30+
@SerialName("postStatus")
31+
val postStatus: String,
32+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.poti.android.data.remote.service
2+
3+
import com.poti.android.core.network.model.BaseResponse
4+
import com.poti.android.data.remote.dto.response.participant.MyPartyListDto
5+
import retrofit2.http.GET
6+
import retrofit2.http.Query
7+
8+
interface ParticipationService {
9+
@GET("/api/v1/participations")
10+
suspend fun getMyParticipationList(
11+
@Query("status") status: String,
12+
): BaseResponse<MyPartyListDto>
13+
}

app/src/main/java/com/poti/android/data/remote/service/PartyService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.poti.android.core.network.model.BaseResponse
44
import com.poti.android.data.remote.dto.request.party.CreatePartyRequestDto
55
import com.poti.android.data.remote.dto.request.party.PartyJoinRequestDto
66
import com.poti.android.data.remote.dto.response.artist.ArtistSearchListResponseDto
7+
import com.poti.android.data.remote.dto.response.participant.MyPartyListDto
78
import com.poti.android.data.remote.dto.response.party.CreatePartyResponseDto
89
import com.poti.android.data.remote.dto.response.party.PartyDetailResponseDto
910
import com.poti.android.data.remote.dto.response.party.PartyJoinOptionsDto
@@ -50,4 +51,9 @@ interface PartyService {
5051
suspend fun postPartyJoin(
5152
@Body partyJoinRequest: PartyJoinRequestDto,
5253
): BaseResponse<PartyJoinResponseDto>
54+
55+
@GET("/api/v1/posts/me")
56+
suspend fun getMyRecruitList(
57+
@Query("status") status: String,
58+
): BaseResponse<MyPartyListDto>
5359
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.poti.android.data.repository
2+
3+
import com.poti.android.core.network.model.handleApiResponse
4+
import com.poti.android.core.network.util.HttpResponseHandler
5+
import com.poti.android.data.mapper.participation.toDomain
6+
import com.poti.android.data.remote.datasource.ParticipantRemoteDataSource
7+
import com.poti.android.domain.model.history.MyPartyList
8+
import com.poti.android.domain.repository.ParticipationRepository
9+
import jakarta.inject.Inject
10+
11+
class ParticipationRepositoryImpl @Inject constructor(
12+
private val httpResponseHandler: HttpResponseHandler,
13+
private val participationRemoteDataSource: ParticipantRemoteDataSource,
14+
) : ParticipationRepository {
15+
override suspend fun getMyParticipationList(status: String): Result<MyPartyList> = httpResponseHandler.safeApiCall {
16+
participationRemoteDataSource.getMyPartyList(status)
17+
.handleApiResponse()
18+
.getOrThrow()
19+
.toDomain()
20+
}
21+
}

app/src/main/java/com/poti/android/data/repository/PartyRepositoryImpl.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import com.poti.android.data.mapper.artist.toDomain
66
import com.poti.android.data.mapper.artist.toDto
77
import com.poti.android.data.mapper.delivery.toDomain
88
import com.poti.android.data.mapper.delivery.toDto
9+
import com.poti.android.data.mapper.participation.toDomain
910
import com.poti.android.data.mapper.party.toDomain
1011
import com.poti.android.data.mapper.party.toRequestDto
1112
import com.poti.android.data.remote.datasource.PartyRemoteDataSource
1213
import com.poti.android.data.remote.dto.request.party.CreatePartyRequestDto
1314
import com.poti.android.domain.model.artist.ArtistSearchResult
1415
import com.poti.android.domain.model.artist.MemberPriceOption
1516
import com.poti.android.domain.model.delivery.DeliveryOption
17+
import com.poti.android.domain.model.history.MyPartyList
1618
import com.poti.android.domain.model.party.PartyDetail
1719
import com.poti.android.domain.model.party.PartyJoinInfo
1820
import com.poti.android.domain.model.party.PartyJoinOption
@@ -97,4 +99,11 @@ class PartyRepositoryImpl @Inject constructor(
9799
.getOrThrow()
98100
.participationId
99101
}
102+
103+
override suspend fun getMyRecruitList(status: String): Result<MyPartyList> = httpResponseHandler.safeApiCall {
104+
partyRemoteDataSource.getMyRecruitList(status)
105+
.handleApiResponse()
106+
.getOrThrow()
107+
.toDomain()
108+
}
100109
}

0 commit comments

Comments
 (0)