Skip to content
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 @@ -102,7 +102,7 @@ fun RegisterTestInfoBottomSheet(
if (forModify && certificationData != null) {
// TODO data 형식에 맞게 여기서 삽입

dateText = certificationData.testDateInformation
dateText = certificationData.testDate
placeTextP1 = certificationData.city
placeTextP2 = certificationData.state
// timeData = certificationData.testTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.sopt.certi.core.util.widthForScreenPercentage
import org.sopt.certi.ui.theme.CERTITheme

@Composable
fun CertiTopBar(
fun DDayoTopBar(
modifier: Modifier = Modifier,
logoutOnClick: () -> Unit = {}
) {
Expand All @@ -40,9 +40,9 @@ fun CertiTopBar(

@Preview(showBackground = true)
@Composable
private fun CertiTopBarPreview() {
private fun DDayoTopBarPreview() {
CERTITheme {
CertiTopBar() {
DDayoTopBar() {
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/org/sopt/certi/core/util/IntExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.sopt.certi.core.util

fun Int.dateString(): String {
return this.toString().padStart(2, '0')
}
4 changes: 4 additions & 0 deletions app/src/main/java/org/sopt/certi/core/util/StringExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ fun String.toLocalDateOrMin(): LocalDate =
fun String.toLocalDateOrNull(): LocalDate? =
runCatching { LocalDate.parse(this, DateFormatters.dotDate) }
.getOrElse { null }

fun String.dateString(): String {
return this.padStart(2, '0')
}
Comment on lines +21 to +23
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[3] 이것도 this.padStart(2, '0') 이거 쓸 수 있을 것 같은뎀

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fun GetCertInfoResponseDto.toDomain() = CertificationData(
agencyName = agencyName,
testType = testType,
description = description,
testDateInformation = testDateInformation,
applicationMethod = applicationMethod,
applicationUrl = applicationUrl,
expirationPeriod = expirationPeriod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.sopt.certi.data.mapper.todomain.cert

import org.sopt.certi.data.remote.dto.response.GetPreCertDayListResponseDto
import org.sopt.certi.data.remote.dto.response.GetPreCertMonthResponseDto
import org.sopt.certi.data.remote.dto.response.PreCertDayItemResponseDto
import org.sopt.certi.data.remote.dto.response.PreCertListResponseDto
import org.sopt.certi.data.remote.dto.response.PreCertMonthDayItem
import org.sopt.certi.domain.model.certification.CertificationData
import org.sopt.certi.domain.model.certification.PreCertDayData

fun PreCertListResponseDto.toDomain(): List<CertificationData> =
data.map { cert ->
Expand All @@ -14,3 +19,39 @@ fun PreCertListResponseDto.toDomain(): List<CertificationData> =
iconIndex = cert.iconIndex
)
}

fun GetPreCertMonthResponseDto.toDomain(): List<Int> =
days.map { day ->
day.toDomain()
}

fun PreCertMonthDayItem.toDomain(): Int = this.day

fun GetPreCertDayListResponseDto.toDomain(): PreCertDayData {
return PreCertDayData(
date = date,
certifications = certifications?.map {
it.toDomain()
}
)
}

fun PreCertDayItemResponseDto.toDomain(): CertificationData {
return CertificationData(
certificationId = certificationId,
certificationName = certificationName,
tags = tags,
averagePeriod = averagePeriod,
charge = charge,
agencyName = agencyName,
testType = testType,
description = description,
applicationMethod = applicationMethod,
applicationUrl = applicationUrl,
expirationPeriod = expirationPeriod,
city = city,
state = state,
testDate = testDate,
isAcquired = isAcquired
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.sopt.certi.data.remote.datasource
import org.sopt.certi.data.remote.dto.base.ApiResponse
import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.response.FavoriteListResponseDto
import org.sopt.certi.data.remote.dto.response.GetPreCertDayListResponseDto
import org.sopt.certi.data.remote.dto.response.GetPreCertMonthResponseDto
import org.sopt.certi.data.remote.dto.response.PreCertListResponseDto
import org.sopt.certi.data.remote.dto.response.UserInfoResponseDto

Expand All @@ -11,4 +13,6 @@ interface HomeRemoteDataSource {
suspend fun getPreCertificationList(): NullableApiResponse<PreCertListResponseDto>
suspend fun getFavoriteList(): NullableApiResponse<FavoriteListResponseDto>
suspend fun toggleFavorite(certificationId: Long): NullableApiResponse<Unit>
suspend fun getPreCertMonth(year: Int, month: Int): ApiResponse<GetPreCertMonthResponseDto>
suspend fun getPreCertDay(date: String): ApiResponse<GetPreCertDayListResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ class HomeRemoteDataSourceImpl @Inject constructor(
override suspend fun getPreCertificationList() = service.getPreCertificationList()
override suspend fun getFavoriteList() = service.getFavoriteList()
override suspend fun toggleFavorite(certificationId: Long) = service.toggleFavorite(certificationId)
override suspend fun getPreCertMonth(year: Int, month: Int) = service.getPreCertMonth(year, month)
override suspend fun getPreCertDay(date: String) = service.getPreCertDay(date)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ data class GetCertInfoResponseDto(
val testType: String,
@SerialName("description")
val description: String,
@SerialName("testDateInformation")
val testDateInformation: String,
@SerialName("applicationMethod")
val applicationMethod: String,
@SerialName("applicationUrl")
val applicationUrl: String,
@SerialName("expirationPeriod")
val expirationPeriod: String
val expirationPeriod: String,
@SerialName("testDateInformation")
val testDateInformation: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.sopt.certi.data.remote.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GetPreCertDayListResponseDto(
@SerialName("date")
val date: String,
@SerialName("certifications")
val certifications: List<PreCertDayItemResponseDto>?
)

@Serializable
data class PreCertDayItemResponseDto(
@SerialName("certificationId")
val certificationId: Long,
@SerialName("certificationName")
val certificationName: String,
@SerialName("tags")
val tags: List<String>,
@SerialName("averagePeriod")
val averagePeriod: String,
@SerialName("charge")
val charge: String,
@SerialName("agencyName")
val agencyName: String,
@SerialName("testType")
val testType: String,
@SerialName("description")
val description: String,
@SerialName("applicationMethod")
val applicationMethod: String,
@SerialName("applicationUrl")
val applicationUrl: String,
@SerialName("expirationPeriod")
val expirationPeriod: String,
@SerialName("city")
val city: String,
@SerialName("state")
val state: String,
@SerialName("testDate")
val testDate: String,
@SerialName("isAcquired")
val isAcquired: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.sopt.certi.data.remote.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GetPreCertMonthResponseDto(
@SerialName("year")
val year: Int,
@SerialName("month")
val month: Int,
@SerialName("days")
val days: List<PreCertMonthDayItem>
)

@Serializable
data class PreCertMonthDayItem(
@SerialName("day")
val day: Int,
@SerialName("count")
val count: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package org.sopt.certi.data.remote.service
import org.sopt.certi.data.remote.dto.base.ApiResponse
import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.response.FavoriteListResponseDto
import org.sopt.certi.data.remote.dto.response.GetPreCertDayListResponseDto
import org.sopt.certi.data.remote.dto.response.GetPreCertMonthResponseDto
import org.sopt.certi.data.remote.dto.response.PreCertListResponseDto
import org.sopt.certi.data.remote.dto.response.UserInfoResponseDto
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface HomeService {
@GET("/api/v1/user")
Expand All @@ -23,4 +26,15 @@ interface HomeService {
suspend fun toggleFavorite(
@Path("certificationId") certificationId: Long
): NullableApiResponse<Unit>

@GET("/api/v1/home/pre-certification/month")
suspend fun getPreCertMonth(
@Query("year") year: Int,
@Query("month") month: Int
): ApiResponse<GetPreCertMonthResponseDto>

@GET("/api/v1/home/pre-certification/day")
suspend fun getPreCertDay(
@Query("date") date: String
): ApiResponse<GetPreCertDayListResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.sopt.certi.domain.model.user.UserInfoData
import org.sopt.certi.domain.repository.HomeRepository
import javax.inject.Inject
import org.sopt.certi.data.remote.util.HttpResponseHandler.handleNullableApiResponse
import org.sopt.certi.data.remote.util.safeApiCall
import org.sopt.certi.domain.model.certification.PreCertDayData

class HomeRepositoryImpl @Inject constructor(
private val homeRemoteDataSource: HomeRemoteDataSource,
Expand Down Expand Up @@ -58,4 +60,18 @@ class HomeRepositoryImpl @Inject constructor(
Unit
}
}

override suspend fun getPreCertMonth(year: Int, month: Int): Result<List<Int>> = safeApiCall {
homeRemoteDataSource.getPreCertMonth(year, month)
.handleApiResponse()
.getOrThrow()
.toDomain()
}

override suspend fun getPreCertDay(date: String): Result<PreCertDayData> = safeApiCall {
homeRemoteDataSource.getPreCertDay(date)
.handleApiResponse()
.getOrThrow()
.toDomain()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ data class CertificationData(
val cardFrontImageUrl: String = "",
val cardBackImageUrl: String = "",
val createdAt: LocalDate = LocalDate.now(),
val testDateInformation: String = "",
val testDate: String = "",
val expirationPeriod: String = "",
val acquisitionDate: String = "",
val grade: String = "",

// 아직 서버에 없음 근데 필요한것들
val isAcquired: Boolean = false, // 취득 여부
val city: String = "", // 시험장소
val city: String = "",
val state: String = "",
val isAcquired: Boolean = false, // 취득 여부
val testTime: String = "" // 시험시간
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.certi.domain.model.certification

data class PreCertDayData(
val date: String = "",
val certifications: List<CertificationData>? = emptyList()
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sopt.certi.domain.repository

import org.sopt.certi.domain.model.certification.CertificationData
import org.sopt.certi.domain.model.certification.PreCertDayData
import org.sopt.certi.domain.model.user.UserInfoData

interface HomeRepository {
Expand All @@ -9,4 +10,6 @@ interface HomeRepository {
suspend fun getPreCertificationList(): Result<List<CertificationData>>
suspend fun getFavoriteList(): Result<List<CertificationData>>
suspend fun toggleFavorite(certificationId: Long): Result<Unit>
suspend fun getPreCertMonth(year: Int, month: Int): Result<List<Int>>
suspend fun getPreCertDay(date: String): Result<PreCertDayData>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.certi.domain.usecase.certification

import org.sopt.certi.domain.repository.HomeRepository
import javax.inject.Inject

class GetPreCertDayUseCase @Inject constructor(
private val homeRepository: HomeRepository
) {
suspend operator fun invoke(date: String) = homeRepository.getPreCertDay(date)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.certi.domain.usecase.certification

import org.sopt.certi.domain.repository.HomeRepository
import javax.inject.Inject

class GetPreCertMonthUseCase @Inject constructor(
private val homeRepository: HomeRepository
) {
suspend operator fun invoke(year: Int, month: Int) = homeRepository.getPreCertMonth(year, month)
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private fun PreviewCertDetailScreen() {
tags = listOf("aa", "bb", "cc"),
charge = "12000",
description = "2D 그래픽 툴의 기능을 활용한 사고의 시각화를 통해 이미지 제작, 수정, 편집 및 그래픽 디자인을 창출하는 업무를 수행하고 이를 통해 비지니스 커뮤니케이션을 원활하게 한다. 1급과 2급, 급수의 차이는 이 업무를 수행하는 툴 활용 능력의 범위와 숙련도 등의 고도화 차이이다.",
testDateInformation = "매월 넷째주 토요일 정기시험 시행 (총 12회)",
testDate = "매월 넷째주 토요일 정기시험 시행 (총 12회)",
applicationMethod = "온라인(한국생산성본부 홈페이지)",
applicationUrl = "asdf",
expirationPeriod = "1년"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.certi.presentation.ui.certdetail

import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -54,6 +55,7 @@ class CertDetailViewModel @Inject constructor(
},
onFailure = {
_certDetailInfo.emit(UiState.Failure(it.message.toString()))
Log.d("Logd", it.message.toString())
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fun CertDetailInfoScreen(
Spacer(Modifier.widthForScreenPercentage(6.dp))

Text(
text = certData.testDateInformation,
text = certData.testDate,
style = CertiTheme.typography.body.regular_16,
color = CertiTheme.colors.gray600
)
Expand Down Expand Up @@ -294,7 +294,7 @@ private fun PreviewCertDetailInfoScreen() {
tags = listOf("aa", "bb", "cc"),
charge = "12000",
description = "2D 그래픽 툴의 기능을 활용한 사고의 시각화를 통해 이미지 제작, 수정, 편집 및 그래픽 디자인을 창출하는 업무를 수행하고 이를 통해 비지니스 커뮤니케이션을 원활하게 한다. 1급과 2급, 급수의 차이는 이 업무를 수행하는 툴 활용 능력의 범위와 숙련도 등의 고도화 차이이다.",
testDateInformation = "매월 넷째주 토요일 정기시험 시행 (총 12회)",
testDate = "매월 넷째주 토요일 정기시험 시행 (총 12회)",
applicationMethod = "온라인(한국생산성본부 홈페이지)",
applicationUrl = "asdf",
expirationPeriod = "1년"
Expand Down
Loading