Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.moive.app.data.voting.remote.datasource

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.voting.remote.dto.PlaceVoteRequest
import com.moive.app.data.voting.remote.dto.RecommendedAreaListResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceDetailResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceListResponse
Expand All @@ -24,4 +25,9 @@ interface VotingRemoteDataSource {
meetingId: Long,
recommendedPlaceId: Long,
): BaseResponse<RecommendedPlaceRouteResponse>

suspend fun postPlaceVotes(
meetingId: Long,
request: PlaceVoteRequest,
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.moive.app.data.voting.remote.datasource

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.voting.remote.dto.PlaceVoteRequest
import com.moive.app.data.voting.remote.dto.RecommendedAreaListResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceDetailResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceListResponse
Expand Down Expand Up @@ -33,4 +34,10 @@ class VotingRemoteDataSourceImpl @Inject constructor(
recommendedPlaceId: Long,
): BaseResponse<RecommendedPlaceRouteResponse> =
votingService.getRecommendedPlaceRoute(meetingId, recommendedPlaceId)

override suspend fun postPlaceVotes(
meetingId: Long,
request: PlaceVoteRequest,
): BaseResponse<Unit> =
votingService.postPlaceVotes(meetingId, request)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.moive.app.data.voting.remote.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PlaceVoteRequest(
@SerialName("recommendedPlaceIds")
val recommendedPlaceIds: List<Long>,
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.moive.app.data.voting.remote.service

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.voting.remote.dto.PlaceVoteRequest
import com.moive.app.data.voting.remote.dto.RecommendedAreaListResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceDetailResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceListResponse
import com.moive.app.data.voting.remote.dto.RecommendedPlaceRouteResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface VotingService {
Expand Down Expand Up @@ -33,4 +36,10 @@ interface VotingService {
@Path("meetingId") meetingId: Long,
@Path("recommendedPlaceId") recommendedPlaceId: Long,
): BaseResponse<RecommendedPlaceRouteResponse>

@POST("meetings/{meetingId}/place-votes")
suspend fun postPlaceVotes(
@Path("meetingId") meetingId: Long,
@Body request: PlaceVoteRequest,
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ interface VotingRepository {
recommendedPlaceId: Long,
current: PlaceDetailModel,
): Result<PlaceDetailModel>

suspend fun postPlaceVotes(
meetingId: Long,
recommendedPlaceIds: List<Long>,
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.moive.app.data.voting.repository

import com.moive.app.core.utils.suspendRunCatching
import com.moive.app.data.common.dto.checkData
import com.moive.app.data.common.dto.checkSuccess
import com.moive.app.data.voting.mapper.applyTo
import com.moive.app.data.voting.mapper.toModel
import com.moive.app.data.voting.model.PlaceDetailModel
import com.moive.app.data.voting.model.PlaceRecommendedPlaceCardItemModel
import com.moive.app.data.voting.model.RegionPinModel
import com.moive.app.data.voting.remote.datasource.VotingRemoteDataSource
import com.moive.app.data.voting.remote.dto.PlaceVoteRequest
import javax.inject.Inject

class VotingRepositoryImpl @Inject constructor(
Expand Down Expand Up @@ -55,4 +57,13 @@ class VotingRepositoryImpl @Inject constructor(
.checkData()
.applyTo(current)
}

override suspend fun postPlaceVotes(
meetingId: Long,
recommendedPlaceIds: List<Long>,
): Result<Unit> =
suspendRunCatching {
votingRemoteDataSource.postPlaceVotes(meetingId, PlaceVoteRequest(recommendedPlaceIds))
.checkSuccess()
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.moive.app.data.votingstatus.di

import com.moive.app.data.votingstatus.remote.datasource.VoteStatusRemoteDataSource
import com.moive.app.data.votingstatus.remote.datasource.VoteStatusRemoteDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class VoteStatusDataSourceModule {

@Binds
@Singleton
abstract fun bindVoteStatusRemoteDataSource(
voteStatusRemoteDataSourceImpl: VoteStatusRemoteDataSourceImpl,
): VoteStatusRemoteDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.moive.app.data.votingstatus.di

import com.moive.app.data.votingstatus.repository.VoteStatusRepository
import com.moive.app.data.votingstatus.repository.VoteStatusRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class VoteStatusRepositoryModule {

@Binds
@Singleton
abstract fun bindVoteStatusRepository(
voteStatusRepositoryImpl: VoteStatusRepositoryImpl,
): VoteStatusRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.moive.app.data.votingstatus.di

import com.moive.app.core.network.di.Auth
import com.moive.app.data.votingstatus.remote.service.VoteStatusService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object VoteStatusServiceModule {

@Provides
@Singleton
fun provideVoteStatusService(
@Auth retrofit: Retrofit,
): VoteStatusService = retrofit.create()
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.moive.app.data.votingstatus.mapper

import com.moive.app.data.votingstatus.model.PlaceVoteCandidateModel
import com.moive.app.data.votingstatus.model.PlaceVoteResultModel
import com.moive.app.data.votingstatus.model.ScheduleVoteCandidateModel
import com.moive.app.data.votingstatus.model.ScheduleVoteResultModel
import com.moive.app.data.votingstatus.remote.dto.PlaceVoteCandidateItem
import com.moive.app.data.votingstatus.remote.dto.PlaceVoteResultResponse
import com.moive.app.data.votingstatus.remote.dto.ScheduleVoteCandidateItem
import com.moive.app.data.votingstatus.remote.dto.ScheduleVoteResultResponse

fun ScheduleVoteResultResponse.toModel(): ScheduleVoteResultModel =
ScheduleVoteResultModel(
isVoteSkipped = isVoteSkipped,
totalVoterCount = totalVoterCnt,
candidates = candidates.map { it.toModel() },
)

fun ScheduleVoteCandidateItem.toModel(): ScheduleVoteCandidateModel =
ScheduleVoteCandidateModel(
meetingDate = meetingDate,
meetingTime = meetingTime,
voterCount = voterCnt,
isVotedByMe = isVotedByMe,
)

fun PlaceVoteResultResponse.toModel(): PlaceVoteResultModel =
PlaceVoteResultModel(
isFinished = isFinished,
totalVoterCount = totalVoterCnt,
candidates = candidates.map { it.toModel() },
)

fun PlaceVoteCandidateItem.toModel(): PlaceVoteCandidateModel =
PlaceVoteCandidateModel(
id = placeId,
placeName = placeName,
voterCount = voterCnt,
isVotedByMe = isVotedByMe,
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.moive.app.data.votingstatus.model

data class PlaceVoteResultModel(
val isFinished: Boolean,
val totalVoterCount: Int,
val candidates: List<PlaceVoteCandidateModel>,
)

data class PlaceVoteCandidateModel(
val id: Long,
val placeName: String?,
val voterCount: Int,
val isVotedByMe: Boolean,
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.moive.app.data.votingstatus.model

import androidx.compose.runtime.Immutable

@Immutable
data class ScheduleVoteResultModel(
val isVoteSkipped: Boolean,
val totalVoterCount: Int?,
val candidates: List<ScheduleVoteCandidateModel>,
)

@Immutable
data class ScheduleVoteCandidateModel(
val meetingDate: String,
val meetingTime: String,
val voterCount: Int?,
val isVotedByMe: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.moive.app.data.votingstatus.remote.datasource

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.votingstatus.remote.dto.PlaceVoteResultResponse
import com.moive.app.data.votingstatus.remote.dto.ScheduleVoteResultResponse

interface VoteStatusRemoteDataSource {
suspend fun getScheduleVoteResult(meetingId: Long): BaseResponse<ScheduleVoteResultResponse>

suspend fun getPlaceVoteResult(meetingId: Long): BaseResponse<PlaceVoteResultResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.moive.app.data.votingstatus.remote.datasource

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.votingstatus.remote.dto.PlaceVoteResultResponse
import com.moive.app.data.votingstatus.remote.dto.ScheduleVoteResultResponse
import com.moive.app.data.votingstatus.remote.service.VoteStatusService
import javax.inject.Inject

class VoteStatusRemoteDataSourceImpl @Inject constructor(
private val voteStatusService: VoteStatusService,
) : VoteStatusRemoteDataSource {

override suspend fun getScheduleVoteResult(meetingId: Long): BaseResponse<ScheduleVoteResultResponse> =
voteStatusService.getScheduleVoteResult(meetingId)

override suspend fun getPlaceVoteResult(meetingId: Long): BaseResponse<PlaceVoteResultResponse> =
voteStatusService.getPlaceVoteResult(meetingId)
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.moive.app.data.votingstatus.remote.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PlaceVoteResultResponse(
@SerialName("isFinished")
val isFinished: Boolean,
@SerialName("totalVoterCnt")
val totalVoterCnt: Int,
@SerialName("candidates")
val candidates: List<PlaceVoteCandidateItem>,
)

@Serializable
data class PlaceVoteCandidateItem(
@SerialName("placeId")
val placeId: Long,
@SerialName("placeName")
val placeName: String?,
@SerialName("voterCnt")
val voterCnt: Int,
@SerialName("isVotedByMe")
val isVotedByMe: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.moive.app.data.votingstatus.remote.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ScheduleVoteResultResponse(
@SerialName("isVoteSkipped")
val isVoteSkipped: Boolean,
@SerialName("totalVoterCnt")
val totalVoterCnt: Int?,
@SerialName("candidates")
val candidates: List<ScheduleVoteCandidateItem>,
)

@Serializable
data class ScheduleVoteCandidateItem(
@SerialName("meetingDate")
val meetingDate: String,
@SerialName("meetingTime")
val meetingTime: String,
@SerialName("voterCnt")
val voterCnt: Int?,
@SerialName("isVotedByMe")
val isVotedByMe: Boolean,
)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.moive.app.data.votingstatus.remote.service

import com.moive.app.data.common.dto.BaseResponse
import com.moive.app.data.votingstatus.remote.dto.PlaceVoteResultResponse
import com.moive.app.data.votingstatus.remote.dto.ScheduleVoteResultResponse
import retrofit2.http.GET
import retrofit2.http.Path

interface VoteStatusService {
@GET("meetings/{meetingId}/date-votes/result")
suspend fun getScheduleVoteResult(
@Path("meetingId") meetingId: Long,
): BaseResponse<ScheduleVoteResultResponse>

@GET("meetings/{meetingId}/place-votes/result")
suspend fun getPlaceVoteResult(
@Path("meetingId") meetingId: Long,
): BaseResponse<PlaceVoteResultResponse>
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.moive.app.data.votingstatus.repository

import com.moive.app.data.votingstatus.model.PlaceVoteResultModel
import com.moive.app.data.votingstatus.model.ScheduleVoteResultModel

interface VoteStatusRepository {
suspend fun getScheduleVoteResult(meetingId: Long): Result<ScheduleVoteResultModel>

suspend fun getPlaceVoteResult(meetingId: Long): Result<PlaceVoteResultModel>
}
Loading
Loading