-
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.
Merge pull request #35 from DACOS-SOLUX-Hackathon-Team5/feature/26-pr…
…ebabsang-getapi Feature/26 예비 착한 밥상 조회, 제보 등
- Loading branch information
Showing
24 changed files
with
433 additions
and
98 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
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
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
package com.hackathon.alddeul_babsang.data.datasource | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportDto | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportWriteDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
|
||
interface ReportDataSource { | ||
suspend fun postReports( | ||
userId: Int | ||
): BaseResponse<List<ResponseReportDto>> | ||
|
||
suspend fun postReportWrite( | ||
requestReportWriteDto: RequestReportWriteDto | ||
): BaseResponse<String> | ||
} |
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
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.request.RequestReportDto | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportWriteDto | ||
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 postReports(userId : Int): BaseResponse<List<ResponseReportDto>> { | ||
return reportApiService.postReports(userId) | ||
} | ||
|
||
override suspend fun postReportWrite(requestReportWriteDto: RequestReportWriteDto): BaseResponse<String> { | ||
return reportApiService.postReportWrite(requestReportWriteDto) | ||
}} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/hackathon/alddeul_babsang/data/dto/request/RequestReportDto.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.data.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
|
||
class RequestReportDto ( | ||
@SerialName("userId") val userId: Long | ||
) |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/hackathon/alddeul_babsang/data/dto/request/RequestReportWriteDto.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.request | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestReportWriteDto ( | ||
val name : String, | ||
val category: String, | ||
val address: String, | ||
val contact: String, | ||
val menuName1: String, | ||
val menuPrice1: Int, | ||
val menuName2: String, | ||
val menuPrice2: Int, | ||
val imageUrl: String? = null | ||
) |
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
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("storeId") 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 favorite: Boolean | ||
) | ||
|
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
package com.hackathon.alddeul_babsang.data.repositoryimpl | ||
|
||
import com.hackathon.alddeul_babsang.data.datasource.ReportDataSource | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportWriteDto | ||
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 postReports( | ||
userId: Int | ||
): Result<List<ResponseReportDto>> { | ||
return runCatching { | ||
reportDataSource.postReports( | ||
userId = userId | ||
).result ?: emptyList() | ||
} | ||
} | ||
|
||
override suspend fun postReportWrite( | ||
name: String, | ||
category: String, | ||
address: String, | ||
contact: String, | ||
menuName1: String, | ||
menuPrice1: Int, | ||
menuName2: String, | ||
menuPrice2: Int, | ||
imageUrl: String | ||
): Result<String> { | ||
return runCatching { | ||
reportDataSource.postReportWrite( | ||
requestReportWriteDto = RequestReportWriteDto( | ||
name = name, | ||
category = category, | ||
address = address, | ||
contact = contact, | ||
menuName1 = menuName1, | ||
menuPrice1 = menuPrice1, | ||
menuName2 = menuName2, | ||
menuPrice2 = menuPrice2 | ||
) | ||
).result ?: "" | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
package com.hackathon.alddeul_babsang.data.service | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportDto | ||
import com.hackathon.alddeul_babsang.data.dto.request.RequestReportWriteDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
import com.sopt.data.service.ApiKeyStorage.POST | ||
import com.sopt.data.service.ApiKeyStorage.REPORTS | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
import retrofit2.http.Query | ||
|
||
interface ReportApiService { | ||
@POST("/$REPORTS/") | ||
suspend fun postReports( | ||
@Query("userId") userId: Int | ||
): BaseResponse<List<ResponseReportDto>> | ||
|
||
@POST("/$REPORTS/$POST") | ||
suspend fun postReportWrite( | ||
@Body requestReportWriteDto: RequestReportWriteDto | ||
): BaseResponse<String> | ||
|
||
} |
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, | ||
) |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/hackathon/alddeul_babsang/domain/entity/ReportEntity.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 ReportEntity( | ||
val id: Long, | ||
val avatar: String? = null, | ||
val name: String, | ||
val codeName: String, | ||
val address: String, | ||
val phone: String, | ||
val favorite: Boolean = false, | ||
) |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
package com.hackathon.alddeul_babsang.domain.repository | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseReportDto | ||
|
||
interface ReportRepository { | ||
suspend fun postReports( | ||
userId: Int | ||
): Result<List<ResponseReportDto>> | ||
|
||
suspend fun postReportWrite( | ||
name: String, | ||
category: String, | ||
address: String, | ||
contact: String, | ||
menuName1: String, | ||
menuPrice1: Int, | ||
menuName2: String, | ||
menuPrice2: Int, | ||
imageUrl: String, | ||
): Result<String> | ||
|
||
} | ||
|
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
Oops, something went wrong.