-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
14 changed files
with
123 additions
and
27 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/hackathon/alddeul_babsang/data/datasource/ReportDataSource.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.hackathon.alddeul_babsang.data.datasource | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
|
||
interface ReportDataSource { | ||
suspend fun getReports(): BaseResponse<List<ResponseReportDto>> | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/hackathon/alddeul_babsang/data/datasourceimpl/ReportDataSourceImpl.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,15 @@ | ||
package com.hackathon.alddeul_babsang.data.datasourceimpl | ||
|
||
import com.hackathon.alddeul_babsang.data.datasource.ReportDataSource | ||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
import com.hackathon.alddeul_babsang.data.service.ReportApiService | ||
import javax.inject.Inject | ||
|
||
class ReportDataSourceImpl @Inject constructor( | ||
private val reportApiService: ReportApiService | ||
) : ReportDataSource { | ||
override suspend fun getReports(): BaseResponse<List<ResponseReportDto>> { | ||
return reportApiService.getREPORTS() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/hackathon/alddeul_babsang/data/dto/response/ResponseReportDto.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,16 @@ | ||
package com.hackathon.alddeul_babsang.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseReportDto( | ||
@SerialName("id") val id: Long, | ||
@SerialName("name") val name: String, | ||
@SerialName("category") val category: String, | ||
@SerialName("address") val address: String, | ||
@SerialName("contact") val contact: String, | ||
@SerialName("imageUrl") val imageUrl: String? = null, | ||
@SerialName("favorite") val isFavorite: Boolean | ||
) | ||
|
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/hackathon/alddeul_babsang/data/mapper/toReportEntity.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.hackathon.alddeul_babsang.data.mapper | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
import com.hackathon.alddeul_babsang.domain.entity.ReportEntity | ||
|
||
class toLikesEntity { | ||
} | ||
|
||
fun ResponseReportDto.toLikesEntity() = ReportEntity( | ||
id, imageUrl, name, category, address, contact, isFavorite | ||
) | ||
|
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/hackathon/alddeul_babsang/data/repositoryimpl/ReportRepositoryImpl.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,16 @@ | ||
package com.hackathon.alddeul_babsang.data.repositoryimpl | ||
|
||
import com.hackathon.alddeul_babsang.data.datasource.ReportDataSource | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
import com.hackathon.alddeul_babsang.domain.repository.ReportRepository | ||
import javax.inject.Inject | ||
|
||
class ReportRepositoryImpl @Inject constructor( | ||
private val reportDataSource: ReportDataSource | ||
) : ReportRepository { | ||
override suspend fun getReports(): Result<List<ResponseReportDto>> { | ||
return runCatching { | ||
reportDataSource.getReports().result ?: emptyList() | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/hackathon/alddeul_babsang/data/service/ReportApiService.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.hackathon.alddeul_babsang.data.service | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
import com.sopt.data.service.ApiKeyStorage.REPORTS | ||
import retrofit2.http.GET | ||
|
||
interface ReportApiService { | ||
@GET("/$REPORTS") | ||
suspend fun getREPORTS(): BaseResponse<List<ResponseReportDto>> | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/hackathon/alddeul_babsang/domain/entity/BabsangEntity.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.hackathon.alddeul_babsang.domain.entity | ||
|
||
data class BabsangEntity( | ||
val id: Long, | ||
val avatar: String? = null, | ||
val name: String, | ||
val codeName: String, | ||
val address: String, | ||
val phone: String, | ||
val favorite: Boolean = false, | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/hackathon/alddeul_babsang/domain/repository/ReportRepository.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.hackathon.alddeul_babsang.domain.repository | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
|
||
interface ReportRepository { | ||
suspend fun getReports(): Result<List<ResponseReportDto>> | ||
} |
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
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
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