Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/26 예비 착한 밥상 조회, 제보 등 #35

Merged
merged 11 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -5,12 +5,14 @@ import com.hackathon.alddeul_babsang.data.datasource.DetailDataSource
import com.hackathon.alddeul_babsang.data.datasource.ExampleDataSource
import com.hackathon.alddeul_babsang.data.datasource.MapDataSource
import com.hackathon.alddeul_babsang.data.datasource.ProfileDataSource
import com.hackathon.alddeul_babsang.data.datasource.ReportDataSource
import com.hackathon.alddeul_babsang.data.datasource.UserPreferencesDataSource
import com.hackathon.alddeul_babsang.data.datasourceimpl.BabsangDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.DetailDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.ExampleDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.MapDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.ProfileDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.ReportDataSourceImpl
import com.hackathon.alddeul_babsang.data.datasourceimpl.UserPreferencesDataSourceImpl
import dagger.Binds
import dagger.Module
Expand Down Expand Up @@ -45,4 +47,9 @@ abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindMapDataSource(mapDataSourceImpl: MapDataSourceImpl): MapDataSource

@Binds
@Singleton
abstract fun bindReportDataSource(reportDataSourceImpl: ReportDataSourceImpl): ReportDataSource

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import com.hackathon.alddeul_babsang.data.repositoryimpl.DetailRepositoryImpl
import com.hackathon.alddeul_babsang.data.repositoryimpl.ExampleRepositoryImpl
import com.hackathon.alddeul_babsang.data.repositoryimpl.MapRepositoryImpl
import com.hackathon.alddeul_babsang.data.repositoryimpl.ProfileRepositoryImpl
import com.hackathon.alddeul_babsang.data.repositoryimpl.ReportRepositoryImpl
import com.hackathon.alddeul_babsang.data.repositoryimpl.UserPreferencesRepositoryImpl
import com.hackathon.alddeul_babsang.domain.repository.BabsangRepository
import com.hackathon.alddeul_babsang.domain.repository.DetailRepository
import com.hackathon.alddeul_babsang.domain.repository.ExampleRepository
import com.hackathon.alddeul_babsang.domain.repository.MapRepository
import com.hackathon.alddeul_babsang.domain.repository.ProfileRepository
import com.hackathon.alddeul_babsang.domain.repository.ReportRepository
import com.hackathon.alddeul_babsang.domain.repository.UserPreferencesRepository
import dagger.Binds
import dagger.Module
Expand Down Expand Up @@ -42,6 +44,10 @@ abstract class RepositoryModule {
@Singleton
abstract fun bindDetailRepository(detailRepositoryImpl: DetailRepositoryImpl): DetailRepository

@Binds
@Singleton
abstract fun bindReportRepository(reportDataSourceImpl: ReportRepositoryImpl): ReportRepository

@Binds
@Singleton
abstract fun bindMapRepository(mapRepositoryImpl: MapRepositoryImpl): MapRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hackathon.alddeul_babsang.app.di

import com.hackathon.alddeul_babsang.data.service.BabsangApiService
import com.hackathon.alddeul_babsang.data.service.ReportApiService
import com.hackathon.alddeul_babsang.data.service.DetailApiService
import com.hackathon.alddeul_babsang.data.service.MapApiService
import com.hackathon.alddeul_babsang.data.service.ProfileApiService
Expand Down Expand Up @@ -45,4 +46,12 @@ object ServiceModule {
fun provideMapService(
@AlddeulRetrofit retrofit: Retrofit
): MapApiService = retrofit.create(MapApiService::class.java)

@Provides
@Singleton
fun provideReportService(
@AlddeulRetrofit retrofit: Retrofit
): ReportApiService = retrofit.create(ReportApiService::class.java)


}
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>
}
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)
}}
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
)
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ data class Review (
@SerialName("nickname") val nickname: String,
@SerialName("rate") val rate: Double,
@SerialName("content") val content: String,
@SerialName("image") val imageUrl: String,
@SerialName("date") val date: String
)
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
)

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 ?: ""
}
}
}
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>

}
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,
)
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,
)
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>

}

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.hackathon.alddeul_babsang.R
import com.hackathon.alddeul_babsang.core_ui.theme.AlddeulBabsangTheme
import com.hackathon.alddeul_babsang.core_ui.theme.Gray300
import com.hackathon.alddeul_babsang.core_ui.theme.Orange700
import com.hackathon.alddeul_babsang.core_ui.theme.Orange800
Expand All @@ -38,8 +36,6 @@ import com.hackathon.alddeul_babsang.core_ui.theme.body2Regular
import com.hackathon.alddeul_babsang.core_ui.theme.body4Regular
import com.hackathon.alddeul_babsang.core_ui.theme.head4Bold
import com.hackathon.alddeul_babsang.data.dto.response.ResponseBabsangDto
import com.hackathon.alddeul_babsang.domain.entity.LikesEntity
import com.hackathon.alddeul_babsang.presentation.profile.screen.LikeItem

@Composable
fun BabsangItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.hackathon.alddeul_babsang.data.dto.response.ResponseBabsangDto
import com.hackathon.alddeul_babsang.domain.entity.BabsangRecommendEntity
import com.hackathon.alddeul_babsang.domain.entity.LikesEntity
import com.hackathon.alddeul_babsang.domain.repository.BabsangRepository
import com.hackathon.alddeul_babsang.util.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -70,51 +69,4 @@ class BabsangViewModel @Inject constructor(
address = "용산구",
)
)
val mockBabsang = listOf(
LikesEntity(
id = 1,
avatar = null,
name = "송이네 밥상",
codeName = "기타외식업",
address = "서울특별시 용산구 청파동 81",
phone = "02-210-0120",
favorite = true
),
LikesEntity(
id = 2,
avatar = null,
name = "송이네 일식",
codeName = "경양식/일식",
address = "서울특별시 용산구 청파동 11",
phone = "02-210-0220",
favorite = true
),
LikesEntity(
id = 3,
avatar = null,
name = "송이네 한식",
codeName = "한식",
address = "서울특별시 용산구 청파동 31",
phone = "02-223-0220",
favorite = true
),
LikesEntity(
id = 4,
avatar = null,
name = "송이네 중식",
codeName = "중식",
address = "서울특별시 용산구 청파동 31",
phone = "02-223-0220",
favorite = true
),
LikesEntity(
id = 4,
avatar = "https://avatars.githubusercontent.com/u/166610834?s=400&u=568eacc2e4696d563a4fd732c148edba2196e4f6&v=4",
name = "송이네 밥상",
codeName = "중식",
address = "서울특별시 용산구 청파동 31",
phone = "02-223-0220",
favorite = true
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun ReviewItem(
verticalAlignment = Alignment.CenterVertically
) {
AsyncImage(
model = "",
model = data.imageUrl,
contentDescription = null,
placeholder = painterResource(id = R.drawable.ic_launcher_background),
modifier = Modifier
Expand Down
Loading
Loading