Skip to content

Commit 1bfff58

Browse files
authored
Merge pull request #155 from YAPP-Github/feature/#154-report_detail
[Feature/#154] 제보 상세조회 화면 구현
2 parents 62f0976 + faaf271 commit 1bfff58

File tree

22 files changed

+523
-2
lines changed

22 files changed

+523
-2
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import com.threegap.bitnagil.presentation.onboarding.OnBoardingScreenContainer
1414
import com.threegap.bitnagil.presentation.onboarding.OnBoardingViewModel
1515
import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg
1616
import com.threegap.bitnagil.presentation.report.ReportScreenContainer
17+
import com.threegap.bitnagil.presentation.reportdetail.ReportDetailScreenContainer
18+
import com.threegap.bitnagil.presentation.reportdetail.ReportDetailViewModel
19+
import com.threegap.bitnagil.presentation.reportdetail.model.navarg.ReportDetailScreenArg
1720
import com.threegap.bitnagil.presentation.reporthistory.ReportHistoryScreenContainer
1821
import com.threegap.bitnagil.presentation.routinelist.RoutineListScreenContainer
1922
import com.threegap.bitnagil.presentation.setting.SettingScreenContainer
@@ -319,7 +322,27 @@ fun MainNavHost(
319322
navigator.navController.popBackStack()
320323
}
321324
},
322-
navigateToReportDetail = {
325+
navigateToReportDetail = { reportId ->
326+
navigator.navController.navigate(Route.ReportDetail(reportId = reportId)) {
327+
launchSingleTop = true
328+
}
329+
},
330+
)
331+
}
332+
333+
composable<Route.ReportDetail> { navBackStackEntry ->
334+
val arg = navBackStackEntry.toRoute<Route.ReportDetail>()
335+
val reportDetailScreenArg = ReportDetailScreenArg(reportId = arg.reportId)
336+
val viewModel = hiltViewModel<ReportDetailViewModel, ReportDetailViewModel.Factory> { factory ->
337+
factory.create(reportDetailScreenArg)
338+
}
339+
340+
ReportDetailScreenContainer(
341+
viewModel = viewModel,
342+
navigateToBack = {
343+
if (navigator.navController.previousBackStackEntry != null) {
344+
navigator.navController.popBackStack()
345+
}
323346
},
324347
)
325348
}

app/src/main/java/com/threegap/bitnagil/Route.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ sealed interface Route {
5454

5555
@Serializable
5656
data object ReportHistory : Route
57+
58+
@Serializable
59+
data class ReportDetail(val reportId: String) : Route
5760
}

data/src/main/java/com/threegap/bitnagil/data/address/model/response/Coord2AddressResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ data class Meta(
2020
@Serializable
2121
data class Document(
2222
@SerialName("road_address")
23-
val roadAddress: RoadAddress,
23+
val roadAddress: RoadAddress?,
2424
@SerialName("address")
2525
val address: Address,
2626
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.threegap.bitnagil.data.report.datasource
22

33
import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
4+
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
45
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto
56

67
interface ReportDataSource {
78
suspend fun submitReport(reportRequestDto: ReportRequestDto): Result<Long>
89
suspend fun getReports(): Result<ReportHistoriesPerDateDto>
10+
suspend fun getReport(reportId: String): Result<ReportDetailDto>
911
}

data/src/main/java/com/threegap/bitnagil/data/report/datasourceImpl/ReportDataSourceImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.report.datasourceImpl
33
import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.report.datasource.ReportDataSource
55
import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
6+
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
67
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto
78
import com.threegap.bitnagil.data.report.service.ReportService
89
import javax.inject.Inject
@@ -17,4 +18,8 @@ class ReportDataSourceImpl @Inject constructor(
1718
override suspend fun getReports(): Result<ReportHistoriesPerDateDto> {
1819
return safeApiCall { reportService.getReports() }
1920
}
21+
22+
override suspend fun getReport(reportId: String): Result<ReportDetailDto> {
23+
return safeApiCall { reportService.getReport(reportId = reportId) }
24+
}
2025
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.threegap.bitnagil.data.report.model.response
2+
3+
import com.threegap.bitnagil.domain.report.model.ReportCategory
4+
import com.threegap.bitnagil.domain.report.model.ReportDetail
5+
import com.threegap.bitnagil.domain.report.model.ReportStatus
6+
import kotlinx.serialization.SerialName
7+
import kotlinx.serialization.Serializable
8+
import java.time.LocalDate
9+
10+
@Serializable
11+
class ReportDetailDto(
12+
@SerialName("reportDate")
13+
val reportDate: String,
14+
@SerialName("reportStatus")
15+
val reportStatus: String,
16+
@SerialName("reportTitle")
17+
val reportTitle: String,
18+
@SerialName("reportContent")
19+
val reportContent: String,
20+
@SerialName("reportCategory")
21+
val reportCategory: String,
22+
@SerialName("reportLocation")
23+
val reportLocation: String,
24+
@SerialName("reportImageUrls")
25+
val reportImageUrls: List<String>,
26+
)
27+
28+
fun ReportDetailDto.toDomain(id: String?): ReportDetail =
29+
ReportDetail(
30+
id = id ?: "",
31+
date = LocalDate.parse(this.reportDate),
32+
status = ReportStatus.fromString(this.reportStatus),
33+
title = this.reportTitle,
34+
content = this.reportContent,
35+
category = ReportCategory.fromString(this.reportCategory),
36+
address = this.reportLocation,
37+
imageUrls = this.reportImageUrls,
38+
)

data/src/main/java/com/threegap/bitnagil/data/report/repositoryImpl/ReportRepositoryImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package com.threegap.bitnagil.data.report.repositoryImpl
22

33
import com.threegap.bitnagil.data.report.datasource.ReportDataSource
44
import com.threegap.bitnagil.data.report.model.request.toDto
5+
import com.threegap.bitnagil.data.report.model.response.toDomain
56
import com.threegap.bitnagil.data.report.model.response.toDomainMap
67
import com.threegap.bitnagil.domain.report.model.Report
8+
import com.threegap.bitnagil.domain.report.model.ReportDetail
79
import com.threegap.bitnagil.domain.report.model.ReportItem
810
import com.threegap.bitnagil.domain.report.repository.ReportRepository
911
import java.time.LocalDate
@@ -19,4 +21,8 @@ class ReportRepositoryImpl @Inject constructor(
1921
override suspend fun getReportHistories(): Result<Map<LocalDate, List<ReportItem>>> {
2022
return reportDataSource.getReports().map { it.toDomainMap() }
2123
}
24+
25+
override suspend fun getReport(reportId: String): Result<ReportDetail> {
26+
return reportDataSource.getReport(reportId = reportId).map { it.toDomain(id = reportId) }
27+
}
2228
}

data/src/main/java/com/threegap/bitnagil/data/report/service/ReportService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.threegap.bitnagil.data.report.service
22

33
import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
4+
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
45
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto
56
import com.threegap.bitnagil.network.model.BaseResponse
67
import retrofit2.http.Body
78
import retrofit2.http.GET
89
import retrofit2.http.POST
10+
import retrofit2.http.Path
911

1012
interface ReportService {
1113
@POST("/api/v2/reports")
@@ -15,4 +17,9 @@ interface ReportService {
1517

1618
@GET("/api/v2/reports")
1719
suspend fun getReports(): BaseResponse<ReportHistoriesPerDateDto>
20+
21+
@GET("/api/v2/reports/{reportId}")
22+
suspend fun getReport(
23+
@Path("reportId") reportId: String,
24+
): BaseResponse<ReportDetailDto>
1825
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.threegap.bitnagil.domain.report.model
2+
3+
import java.time.LocalDate
4+
5+
data class ReportDetail(
6+
val id: String,
7+
val title: String,
8+
val content: String,
9+
val category: ReportCategory,
10+
val status: ReportStatus,
11+
val imageUrls: List<String>,
12+
val address: String,
13+
val date: LocalDate,
14+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.threegap.bitnagil.domain.report.repository
22

33
import com.threegap.bitnagil.domain.report.model.Report
4+
import com.threegap.bitnagil.domain.report.model.ReportDetail
45
import com.threegap.bitnagil.domain.report.model.ReportItem
56
import java.time.LocalDate
67

78
interface ReportRepository {
89
suspend fun submitReport(report: Report): Result<Long>
910
suspend fun getReportHistories(): Result<Map<LocalDate, List<ReportItem>>>
11+
suspend fun getReport(reportId: String): Result<ReportDetail>
1012
}

0 commit comments

Comments
 (0)