Skip to content

Commit

Permalink
[MERGE] #186 -> develop
Browse files Browse the repository at this point in the history
[Refactor/#186] 탐색 기본 뷰 / 리팩토링
  • Loading branch information
arinming authored Aug 25, 2024
2 parents ebc126f + 4575e7d commit 404143c
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme


/**
* 검색창 텍스트 필드 컴포저블입니다.
*
* @param text 텍스트 필드에 표시될 텍스트입니다.
* @param onValueChange 텍스트 필드의 값이 변경될 때 호출되는 콜백 함수입니다.
* @param modifier 텍스트 필드에 적용될 Modifier입니다.
* @param hint 텍스트 필드에 아무것도 입력하지 않았을 때 표시될 힌트 텍스트입니다.
* @param leftIcon 텍스트 필드의 왼쪽에 표시될 아이콘의 리소스 ID입니다.
* @param enabled 텍스트 필드가 활성화되어 있는지 여부를 나타냅니다.
* @param readOnly 텍스트 필드가 읽기 전용인지 여부를 나타냅니다.
* @param onSearchAction 사용자가 키보드에서 검색을 실행할 때 호출되는 콜백 함수입니다.
*/
@Composable
fun SearchTextField(
text: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package com.terning.data.datasource
import com.terning.data.dto.BaseResponse
import com.terning.data.dto.request.SearchRequestDto
import com.terning.data.dto.response.SearchResultResponseDto
import com.terning.data.dto.response.SearchScrapsResponseDto
import com.terning.data.dto.response.SearchViewsResponseDto
import com.terning.data.dto.response.SearchAnnouncementResponseDto

interface SearchDataSource {
suspend fun getSearch(request: SearchRequestDto): BaseResponse<SearchResultResponseDto>
suspend fun getSearchViews(): BaseResponse<SearchViewsResponseDto>
suspend fun getSearchScraps(): BaseResponse<SearchScrapsResponseDto>
suspend fun getSearchViews(): BaseResponse<SearchAnnouncementResponseDto>
suspend fun getSearchScraps(): BaseResponse<SearchAnnouncementResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import com.terning.data.datasource.SearchDataSource
import com.terning.data.dto.BaseResponse
import com.terning.data.dto.request.SearchRequestDto
import com.terning.data.dto.response.SearchResultResponseDto
import com.terning.data.dto.response.SearchScrapsResponseDto
import com.terning.data.dto.response.SearchViewsResponseDto
import com.terning.data.dto.response.SearchAnnouncementResponseDto
import com.terning.data.service.SearchService
import javax.inject.Inject

Expand All @@ -22,9 +21,9 @@ class SearchDataSourceImpl @Inject constructor(
request.size
)

override suspend fun getSearchViews(): BaseResponse<SearchViewsResponseDto> =
override suspend fun getSearchViews(): BaseResponse<SearchAnnouncementResponseDto> =
searchService.getSearchViewsList()

override suspend fun getSearchScraps(): BaseResponse<SearchScrapsResponseDto> =
override suspend fun getSearchScraps(): BaseResponse<SearchAnnouncementResponseDto> =
searchService.getSearchScrapsList()
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.terning.data.dto.response

import com.terning.domain.entity.response.InternshipAnnouncementModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable


@Serializable
data class SearchScrapsResponseDto(
data class SearchAnnouncementResponseDto(
@SerialName("announcements")
val announcements: List<ScrapsAnnouncementDto>,
) {
Expand All @@ -19,14 +18,4 @@ data class SearchScrapsResponseDto(
@SerialName("title")
val title: String,
)

fun toSearchScrapsEntity(): List<InternshipAnnouncementModel> {
return announcements.map {
InternshipAnnouncementModel(
announcementId = it.internshipAnnouncementId,
companyImage = it.companyImage,
title = it.title,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.terning.data.dto.response

import com.terning.domain.entity.response.SearchResultModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -34,20 +33,4 @@ data class SearchResultResponseDto(
@SerialName("deadline")
val deadline: String,
)

fun toSearchResultEntity(): List<SearchResultModel> {
return announcements.map {
SearchResultModel(
internshipAnnouncementId = it.internshipAnnouncementId,
title = it.title,
dDay = it.dDay,
workingPeriod = it.workingPeriod,
companyImage = it.companyImage,
scrapId = it.scrapId,
deadline = it.deadline,
startYearMonth = it.startYearMonth,
color = it.color
)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.terning.data.mapper.search

import com.terning.data.dto.response.SearchAnnouncementResponseDto
import com.terning.domain.entity.search.SearchPopularAnnouncement

fun SearchAnnouncementResponseDto.toSearchPopularAnnouncementList(): List<SearchPopularAnnouncement> {
return announcements.map {
SearchPopularAnnouncement(
announcementId = it.internshipAnnouncementId,
companyImage = it.companyImage,
title = it.title,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.terning.data.mapper.search

import com.terning.data.dto.response.SearchResultResponseDto
import com.terning.domain.entity.search.SearchResult


fun SearchResultResponseDto.toSearchResultList(): List<SearchResult> {
return announcements.map {
SearchResult(
internshipAnnouncementId = it.internshipAnnouncementId,
title = it.title,
dDay = it.dDay,
workingPeriod = it.workingPeriod,
companyImage = it.companyImage,
scrapId = it.scrapId,
deadline = it.deadline,
startYearMonth = it.startYearMonth,
color = it.color
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.terning.data.repositoryimpl

import com.terning.data.datasource.SearchDataSource
import com.terning.data.dto.request.SearchRequestDto
import com.terning.domain.entity.response.InternshipAnnouncementModel
import com.terning.domain.entity.response.SearchResultModel
import com.terning.data.mapper.search.toSearchPopularAnnouncementList
import com.terning.data.mapper.search.toSearchResultList
import com.terning.domain.entity.search.SearchPopularAnnouncement
import com.terning.domain.entity.search.SearchResult
import com.terning.domain.repository.SearchRepository
import javax.inject.Inject

Expand All @@ -15,7 +17,7 @@ class SearchRepositoryImpl @Inject constructor(
sortBy: String,
page: Int,
size: Int,
): Result<List<SearchResultModel>> {
): Result<List<SearchResult>> {
return runCatching {
searchDataSource.getSearch(
SearchRequestDto(
Expand All @@ -24,17 +26,17 @@ class SearchRepositoryImpl @Inject constructor(
page = page,
size = size
)
).result.toSearchResultEntity()
).result.toSearchResultList()
}
}

override suspend fun getSearchViewsList(): Result<List<InternshipAnnouncementModel>> =
override suspend fun getSearchViewsList(): Result<List<SearchPopularAnnouncement>> =
runCatching {
searchDataSource.getSearchViews().result.toSearchViewsEntity()
searchDataSource.getSearchViews().result.toSearchPopularAnnouncementList()
}

override suspend fun getSearchScrapsList(): Result<List<InternshipAnnouncementModel>> =
override suspend fun getSearchScrapsList(): Result<List<SearchPopularAnnouncement>> =
runCatching {
searchDataSource.getSearchScraps().result.toSearchScrapsEntity()
searchDataSource.getSearchScraps().result.toSearchPopularAnnouncementList()
}
}
7 changes: 3 additions & 4 deletions data/src/main/java/com/terning/data/service/SearchService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.terning.data.service

import com.terning.data.dto.BaseResponse
import com.terning.data.dto.response.SearchResultResponseDto
import com.terning.data.dto.response.SearchScrapsResponseDto
import com.terning.data.dto.response.SearchViewsResponseDto
import com.terning.data.dto.response.SearchAnnouncementResponseDto
import retrofit2.http.GET
import retrofit2.http.Query

Expand All @@ -17,8 +16,8 @@ interface SearchService {
): BaseResponse<SearchResultResponseDto>

@GET("api/v1/search/views")
suspend fun getSearchViewsList(): BaseResponse<SearchViewsResponseDto>
suspend fun getSearchViewsList(): BaseResponse<SearchAnnouncementResponseDto>

@GET("api/v1/search/scraps")
suspend fun getSearchScrapsList(): BaseResponse<SearchScrapsResponseDto>
suspend fun getSearchScrapsList(): BaseResponse<SearchAnnouncementResponseDto>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.terning.domain.entity.response
package com.terning.domain.entity.search

data class InternshipAnnouncementModel(
data class SearchPopularAnnouncement(
val title: String,
val companyImage: String,
val announcementId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.terning.domain.entity.response
package com.terning.domain.entity.search

data class SearchResultModel(
data class SearchResult(
val internshipAnnouncementId: Long,
val title: String,
val dDay: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.terning.domain.repository

import com.terning.domain.entity.response.SearchResultModel
import com.terning.domain.entity.response.InternshipAnnouncementModel
import com.terning.domain.entity.search.SearchResult
import com.terning.domain.entity.search.SearchPopularAnnouncement

interface SearchRepository {
suspend fun getSearchList(
query: String,
sortBy: String,
page: Int,
size: Int,
): Result<List<SearchResultModel>>
suspend fun getSearchViewsList(): Result<List<InternshipAnnouncementModel>>
suspend fun getSearchScrapsList(): Result<List<InternshipAnnouncementModel>>
): Result<List<SearchResult>>
suspend fun getSearchViewsList(): Result<List<SearchPopularAnnouncement>>
suspend fun getSearchScrapsList(): Result<List<SearchPopularAnnouncement>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import com.terning.feature.intern.InternRoute
import kotlinx.serialization.Serializable

fun NavController.navigateIntern(
navOptions: NavOptions? = null,
announcementId: Long = 0,
navOptions: NavOptions? = null,
) {
navigate(
route = Intern(announcementId),
Expand Down
Loading

0 comments on commit 404143c

Please sign in to comment.