Skip to content

Commit

Permalink
[Feature] #32 포킷 상세 및 포킷 추가/수정화면 API 연결 (#35)
Browse files Browse the repository at this point in the history
* [FEATURE] #32 포킷 목록 조회 API 구현 (useCase, repository, datasource, api)

* [FIX] 포킷 상세 화면에서 포킷 수정과 링크 수정의 이벤트 호출부가 서로 바뀌어 있던 현상 수정

* [BASE] #32 RemotePokitDataSource, PokitRepositoryImpl 관련 테스트코드 작성

* [BASE] #32 pokitDetail 모듈에 domain의존성 추가 및 매핑 함수 구현

* [BASE] #32 포킷 상세 화면 포킷 목록 조회 useCase 연결 및 포킷 목록 페이지네이션 구현

* [FEATURE] #32 포킷 상세 화면 포킷 목록 조회 useCase 연결 및 포킷 목록 페이지네이션 구현

* [FEATURE] #32 포킷 수정/포킷 추가 API, repository, useCase 구현

* [UI] #32 포킷 상세 화면에서 링크 아이템의 날짜+도메인을 표시하는 텍스트의 최대 라인을 1로 변경 및 해당 케이스 preview 추가

* [FEATURE] #32 카테고리 내 링크 목록 조회 API, repository, useCase 구현

* [UI] #32 카테고리 상세 화면에서 필터의 정렬 기준값 2개가 모두 "최신순"으로 되어있던 부분 수정

* [FEATURE] #32 카테고리 상세 화면에서 링크 페이지네이션 적용 및 기존 카테고리 내 링크 목록 조회에서 필터 옵션 적용가능하도록 수정 + 테스트코드 추가

* [FIX] #32 포킷 목록 페이징에서 새로고침시 기존 데이터를 지우지 않던 문제 수정

* [FIX] #32 포킷 내 링크 목록 조회의 response 변경내역 적용 및 포킷 상세 화면에 진입할 때마다 새로고침되는 현상 수정

* [FEATURE] #32 포킷 상세조회, 포킷 이미지 목록 조회 API, Datasource, Repository, UseCase 구현

* [FEATURE] #32 포킷 상세 화면에 포킷 상세조회 UseCase연결

* [FEATURE] #32 포킷 추가/수정 화면에 API 연결 및 포킷 목록 리스트 페이지네이션 적용

* [FIX] #32 포킷 추가 모듈에 누락된 coil 라이브러리 의존성 추가

* [FEATURE] #32 포킷 추가 화면에 추가/수정 API 연결 및 포킷 도메인과 관련된 에러 코드 매핑 로직 구현

* [FEATURE] #32 포킷 삭제, 포킷 개수 조회 API, datasource, repository, useCase 구현

* [FEATURE] #32 포킷 상세 화면에 포킷 삭제 API 연결

* [FEATURE] #32 포킷 수정 후 포킷 상세 화면에서 포킷 명 변경 반영

* [CHORE] #32 ktlint 적용, 오타 수정

* [CHORE] #32 코드리뷰 반영
  • Loading branch information
l5x5l authored Aug 11, 2024
1 parent eb85794 commit 7c8a411
Show file tree
Hide file tree
Showing 73 changed files with 2,169 additions and 135 deletions.
14 changes: 13 additions & 1 deletion app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pokitmons.pokit.navigation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -62,7 +63,13 @@ fun RootNavHost(
val viewModel: AddPokitViewModel = hiltViewModel()
AddPokitScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack
onBackPressed = navHostController::popBackStack,
onBackWithModifySuccess = { modifiedPokitId ->
navHostController.popBackStack()
navHostController.currentBackStackEntry
?.savedStateHandle
?.set("modified_pokit_id", modifiedPokitId)
}
)
}

Expand All @@ -71,6 +78,11 @@ fun RootNavHost(
arguments = PokitDetail.arguments
) {
val viewModel: PokitDetailViewModel = hiltViewModel()
LaunchedEffect(it) {
val pokitId = navHostController.currentBackStackEntry?.savedStateHandle?.get<Int>("modified_pokit_id") ?: return@LaunchedEffect
viewModel.getPokit(pokitId)
}

PokitDetailScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ fun<T> LinkCard(

Text(
text = sub,
style = PokitTheme.typography.detail2.copy(color = PokitTheme.colors.textTertiary)
style = PokitTheme.typography.detail2.copy(color = PokitTheme.colors.textTertiary),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun LinkCardPreview() {
) {
LinkCard(
title = "타이틀\n컴포스는 왜 이런가",
sub = "2024.06.25. youtube.com",
sub = "2024.06.25. youtube.comyoutube.comyoutube.comyoutube",
badgeText = "텍스트",
painter = painterResource(id = R.drawable.icon_24_link),
notRead = true,
Expand Down
4 changes: 4 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ dependencies {
implementation(libs.logging.interceptor)

implementation(project(":domain"))

// mockk
testImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
}
22 changes: 22 additions & 0 deletions data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package pokitmons.pokit.data.api

import pokitmons.pokit.data.model.link.response.GetLinksResponse
import pokitmons.pokit.domain.model.link.LinksSort
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface LinkApi {
@GET("content/{categoryId}")
suspend fun getLinks(
@Path("categoryId") categoryId: Int = 0,
@Query("page") page: Int = 0,
@Query("size") size: Int = 10,
@Query("sort") sort: List<String> = listOf(LinksSort.RECENT.value),
@Query("isRead") isRead: Boolean = false,
@Query("favorites") favorites: Boolean = false,
@Query("startDate") startDate: String? = null,
@Query("endDate") endDate: String? = null,
@Query("categoryIds") categoryIds: List<Int>? = null,
): GetLinksResponse
}
55 changes: 55 additions & 0 deletions data/src/main/java/pokitmons/pokit/data/api/PokitApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package pokitmons.pokit.data.api

import pokitmons.pokit.data.model.pokit.request.CreatePokitRequest
import pokitmons.pokit.data.model.pokit.request.ModifyPokitRequest
import pokitmons.pokit.data.model.pokit.response.CreatePokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitCountResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitImagesResponseItem
import pokitmons.pokit.data.model.pokit.response.GetPokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitsResponse
import pokitmons.pokit.data.model.pokit.response.ModifyPokitResponse
import pokitmons.pokit.domain.model.pokit.PokitsSort
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface PokitApi {
@GET("category")
suspend fun getPokits(
@Query("filterUncategorized") filterUncategorized: Boolean = true,
@Query("size") size: Int = 10,
@Query("page") page: Int = 0,
@Query("sort") sort: String = PokitsSort.RECENT.value,
): GetPokitsResponse

@POST("category")
suspend fun createPokit(
@Body createPokitRequest: CreatePokitRequest,
): CreatePokitResponse

@PATCH("category/{categoryId}")
suspend fun modifyPokit(
@Path("categoryId") categoryId: Int,
@Body modifyPokitRequest: ModifyPokitRequest,
): ModifyPokitResponse

@GET("category/images")
suspend fun getPokitImages(): List<GetPokitImagesResponseItem>

@GET("category/{categoryId}")
suspend fun getPokit(
@Path("categoryId") categoryId: Int,
): GetPokitResponse

@PUT("category/{categoryId}")
suspend fun deletePokit(
@Path("categoryId") categoryId: Int,
)

@GET("category/count")
suspend fun getPokitCount(): GetPokitCountResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pokitmons.pokit.data.datasource.remote.link

import pokitmons.pokit.data.model.link.response.GetLinksResponse
import pokitmons.pokit.domain.model.link.LinksSort

interface LinkDataSource {
suspend fun getLinks(
categoryId: Int = 0,
page: Int = 0,
size: Int = 10,
sort: List<String> = listOf(LinksSort.RECENT.value),
isRead: Boolean = false,
favorites: Boolean = false,
startDate: String? = null,
endDate: String? = null,
categoryIds: List<Int>? = null,
): GetLinksResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package pokitmons.pokit.data.datasource.remote.link

import pokitmons.pokit.data.api.LinkApi
import pokitmons.pokit.data.model.link.response.GetLinksResponse
import javax.inject.Inject

class RemoteLinkDataSource @Inject constructor(
private val linkApi: LinkApi,
) : LinkDataSource {
override suspend fun getLinks(
categoryId: Int,
page: Int,
size: Int,
sort: List<String>,
isRead: Boolean,
favorites: Boolean,
startDate: String?,
endDate: String?,
categoryIds: List<Int>?,
): GetLinksResponse {
return linkApi.getLinks(
categoryId = categoryId,
page = page,
size = size,
sort = sort,
isRead = isRead,
favorites = favorites,
startDate = startDate,
endDate = endDate,
categoryIds = categoryIds
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pokitmons.pokit.data.datasource.remote.pokit

import pokitmons.pokit.data.model.pokit.request.CreatePokitRequest
import pokitmons.pokit.data.model.pokit.request.GetPokitsRequest
import pokitmons.pokit.data.model.pokit.request.ModifyPokitRequest
import pokitmons.pokit.data.model.pokit.response.CreatePokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitCountResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitImagesResponseItem
import pokitmons.pokit.data.model.pokit.response.GetPokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitsResponse
import pokitmons.pokit.data.model.pokit.response.ModifyPokitResponse

interface PokitDataSource {
suspend fun getPokits(getPokitsRequest: GetPokitsRequest): GetPokitsResponse
suspend fun createPokit(createPokitRequest: CreatePokitRequest): CreatePokitResponse
suspend fun modifyPokit(pokitId: Int, modifyPokitRequest: ModifyPokitRequest): ModifyPokitResponse
suspend fun getPokitImages(): List<GetPokitImagesResponseItem>
suspend fun getPokit(pokitId: Int): GetPokitResponse
suspend fun deletePokit(pokitId: Int)
suspend fun getPokitCount(): GetPokitCountResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package pokitmons.pokit.data.datasource.remote.pokit

import pokitmons.pokit.data.api.PokitApi
import pokitmons.pokit.data.model.pokit.request.CreatePokitRequest
import pokitmons.pokit.data.model.pokit.request.GetPokitsRequest
import pokitmons.pokit.data.model.pokit.request.ModifyPokitRequest
import pokitmons.pokit.data.model.pokit.response.CreatePokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitCountResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitImagesResponseItem
import pokitmons.pokit.data.model.pokit.response.GetPokitResponse
import pokitmons.pokit.data.model.pokit.response.GetPokitsResponse
import pokitmons.pokit.data.model.pokit.response.ModifyPokitResponse
import javax.inject.Inject

class RemotePokitDataSource @Inject constructor(
private val pokitApi: PokitApi,
) : PokitDataSource {
override suspend fun getPokits(getPokitsRequest: GetPokitsRequest): GetPokitsResponse {
return pokitApi.getPokits(
filterUncategorized = getPokitsRequest.filterUncategoriezd,
size = getPokitsRequest.size,
page = getPokitsRequest.page,
sort = getPokitsRequest.sort.value
)
}

override suspend fun createPokit(createPokitRequest: CreatePokitRequest): CreatePokitResponse {
return pokitApi.createPokit(createPokitRequest = createPokitRequest)
}

override suspend fun modifyPokit(pokitId: Int, modifyPokitRequest: ModifyPokitRequest): ModifyPokitResponse {
return pokitApi.modifyPokit(categoryId = pokitId, modifyPokitRequest = modifyPokitRequest)
}

override suspend fun getPokitImages(): List<GetPokitImagesResponseItem> {
return pokitApi.getPokitImages()
}

override suspend fun getPokit(pokitId: Int): GetPokitResponse {
return pokitApi.getPokit(pokitId)
}

override suspend fun deletePokit(pokitId: Int) {
return pokitApi.deletePokit(pokitId)
}

override suspend fun getPokitCount(): GetPokitCountResponse {
return pokitApi.getPokitCount()
}
}
23 changes: 23 additions & 0 deletions data/src/main/java/pokitmons/pokit/data/di/link/LinkModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package pokitmons.pokit.data.di.link

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import pokitmons.pokit.data.datasource.remote.link.LinkDataSource
import pokitmons.pokit.data.datasource.remote.link.RemoteLinkDataSource
import pokitmons.pokit.data.repository.link.LinkRepositoryImpl
import pokitmons.pokit.domain.repository.link.LinkRepository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class LinkModule {
@Binds
@Singleton
abstract fun bindLinkRepository(linkRepositoryImpl: LinkRepositoryImpl): LinkRepository

@Binds
@Singleton
abstract fun bindLinkDataSource(linkDataSourceImpl: RemoteLinkDataSource): LinkDataSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import pokitmons.pokit.data.api.AuthApi
import pokitmons.pokit.data.api.LinkApi
import pokitmons.pokit.data.api.PokitApi
import pokitmons.pokit.data.api.SettingApi
import retrofit2.Retrofit
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -69,6 +71,16 @@ object NetworkModule {
return retrofit.create(AuthApi::class.java)
}

@Provides
fun providePokitService(retrofit: Retrofit): PokitApi {
return retrofit.create(PokitApi::class.java)
}

@Provides
fun provideLinkService(retrofit: Retrofit): LinkApi {
return retrofit.create(LinkApi::class.java)
}

@Provides
fun provideSettingService(retrofit: Retrofit): SettingApi {
return retrofit.create(SettingApi::class.java)
Expand Down
23 changes: 23 additions & 0 deletions data/src/main/java/pokitmons/pokit/data/di/pokit/PokitModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package pokitmons.pokit.data.di.pokit

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import pokitmons.pokit.data.datasource.remote.pokit.PokitDataSource
import pokitmons.pokit.data.datasource.remote.pokit.RemotePokitDataSource
import pokitmons.pokit.data.repository.pokit.PokitRepositoryImpl
import pokitmons.pokit.domain.repository.pokit.PokitRepository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class PokitModule {
@Binds
@Singleton
abstract fun bindPokitRepository(pokitRepositoryImpl: PokitRepositoryImpl): PokitRepository

@Binds
@Singleton
abstract fun bindPokitDataSource(pokitDataSourceImpl: RemotePokitDataSource): PokitDataSource
}
24 changes: 24 additions & 0 deletions data/src/main/java/pokitmons/pokit/data/mapper/link/LinkMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pokitmons.pokit.data.mapper.link

import pokitmons.pokit.data.model.link.response.GetLinksResponse
import pokitmons.pokit.domain.model.link.Link

object LinkMapper {
fun mapperToLinks(linksResponse: GetLinksResponse): List<Link> {
return linksResponse.data.map { data ->
Link(
id = data.contentId,
categoryId = data.category.categoryId,
categoryName = data.category.categoryName,
data = data.data,
domain = data.domain,
title = data.title,
memo = data.memo,
alertYn = data.alertYn,
createdAt = data.createdAt,
isRead = data.isRead,
thumbnail = data.thumbNail
)
}
}
}
Loading

0 comments on commit 7c8a411

Please sign in to comment.