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

[FEAT/#59] 캘린더뷰 / 월간 캘린더 서버통신 로직 구현 #90

Merged
merged 43 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
acc7547
[FEAT/#59] 스크랩 엔티티, Dto 생성
boiledEgg-s Jul 13, 2024
ef23c12
[FEAT/#59] 스크랩 데이터소스 생성
boiledEgg-s Jul 13, 2024
2e52a96
[FEAT/#59] 스크랩 레포지토리 생성
boiledEgg-s Jul 13, 2024
b6b97b4
[ADD/#59] 힐트 모듈 코드 추가
boiledEgg-s Jul 13, 2024
8facc3d
[MOVE/#59] 패키지 구조 수정
boiledEgg-s Jul 13, 2024
5cb9523
Merge branch 'develop' into feat/#59-calendar-month
boiledEgg-s Jul 15, 2024
a41c1c5
[MOD/#59] 서버 통신 로직 수정
boiledEgg-s Jul 15, 2024
7c0ba19
[FEAT/#59] 페이지 전환 시 서버 호출 구현
boiledEgg-s Jul 15, 2024
a56ee6b
[REFACTOR/#59] 월간 캘린더 호출 코드 리팩토링
boiledEgg-s Jul 15, 2024
c71d01f
[MOD/#59] 기타 코드 수정
boiledEgg-s Jul 15, 2024
8682749
[FEAT/#59] SideEffect 추가
boiledEgg-s Jul 15, 2024
f817357
[REFACTOR/#59] UI 코드 리팩 및 네비게이터 추가
boiledEgg-s Jul 16, 2024
3129dff
[FIX/#59] MainNavigator 재설정
boiledEgg-s Jul 16, 2024
01028e3
Merge remote-tracking branch 'origin/develop' into feat/#59-calendar-…
boiledEgg-s Jul 16, 2024
9c9a462
[FIX/#59] MainNavigator 2차 재설정
boiledEgg-s Jul 16, 2024
12641e9
[MOD/#59] Dto 매퍼 수정
boiledEgg-s Jul 16, 2024
8988ae8
[FEAT/#91] Dto 생성 및 이름 변경
boiledEgg-s Jul 16, 2024
59ca4f5
[RENAME/#91] 통신 클래스 네이밍 수정
boiledEgg-s Jul 16, 2024
5302933
[FEAT/#91] 모듈 추가
boiledEgg-s Jul 16, 2024
3565d93
[FEAT/#91] 데이터소스 코드 추가
boiledEgg-s Jul 16, 2024
2db05f0
[FEAT/#91] 레포지토리 코드 추가
boiledEgg-s Jul 16, 2024
79a3ed2
[RENAME/#91] State 이름 변경
boiledEgg-s Jul 16, 2024
88684e7
[FEAT/#91] 뷰모델 로직 구현
boiledEgg-s Jul 16, 2024
55be60d
[FEAT/#91] 월간 스크랩 목록 구현
boiledEgg-s Jul 16, 2024
b64665b
[CHORE/#91] 월간 스크랩 목록 오류 수정
boiledEgg-s Jul 16, 2024
35e5ac2
[CHORE/#91] 월간 스크랩 목록 코드 수정
boiledEgg-s Jul 16, 2024
9cf9e7f
[FEAT/#91] 일간 스크랩 목록 로직 구현
boiledEgg-s Jul 16, 2024
c22a402
[CHORE/#91] 일간 스크랩 목록 로직 오류 수정
boiledEgg-s Jul 16, 2024
0200946
[FEAT/#91] 일간 스크랩 목록 빈화면 적용
boiledEgg-s Jul 16, 2024
e0db6a1
[REFACTOR/#91] 캘린더 전면 수정
boiledEgg-s Jul 16, 2024
1ce7179
Merge remote-tracking branch 'origin/develop' into feat/#91-calendar-…
boiledEgg-s Jul 16, 2024
5717f6e
[CHORE/#91] 컨플릭 수정
boiledEgg-s Jul 16, 2024
76093d1
[REFACTOR/#91] 임포트 정리
boiledEgg-s Jul 17, 2024
3f9a40d
[MERGE] #91 -> #59
boiledEgg-s Jul 17, 2024
c9bf625
Merge remote-tracking branch 'origin/develop' into feat/#59-calendar-…
boiledEgg-s Jul 17, 2024
4f58997
[CHORE/#59] 서비스 코드 수정
boiledEgg-s Jul 17, 2024
c256acd
[RENAME/#59] 월간 캘린더 스크랩 파일 이름 변경
boiledEgg-s Jul 17, 2024
36e70c5
Merge remote-tracking branch 'origin/develop' into feat/#59-calendar-…
boiledEgg-s Jul 17, 2024
e212c04
[RENAME/#59] 서비스 연결
boiledEgg-s Jul 17, 2024
8802982
[REFACTOR/#59] 전체 코드 리팩토링
boiledEgg-s Jul 17, 2024
e6b1236
[ADD/#59] LifecycleOwner 추가
boiledEgg-s Jul 17, 2024
212ed27
[DEL/#59] 더미 삭제
boiledEgg-s Jul 17, 2024
7d4ec19
[RENAME/#59] 데이터소스 네이밍 수정
boiledEgg-s Jul 17, 2024
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
6 changes: 6 additions & 0 deletions app/src/main/java/com/terning/point/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ import com.terning.data.datasource.SearchDataSource
import com.terning.data.datasource.TokenReissueDataSource
import com.terning.data.datasourceimpl.AuthDataSourceImpl
import com.terning.data.datasourceimpl.SearchDataSourceImpl
import com.terning.data.datasource.CalendarDataSource
import com.terning.data.datasourceimpl.CalendarDataSourceImpl
import com.terning.data.datasourceimpl.TokenReissueDataSourceImpl
import dagger.Binds
import dagger.Module
@@ -16,6 +18,10 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
abstract class DataSourceModule {

@Binds
@Singleton
abstract fun bindCalendarDataSource(calendarDataSourceImpl: CalendarDataSourceImpl): CalendarDataSource

@Binds
@Singleton
abstract fun bindAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource
6 changes: 6 additions & 0 deletions app/src/main/java/com/terning/point/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.terning.point.di

import com.terning.data.repositoryimpl.AuthRepositoryImpl
import com.terning.data.repositoryimpl.CalendarRepositoryImpl
import com.terning.data.repositoryimpl.SearchViewsRepositoryImpl
import com.terning.data.repositoryimpl.TokenReissueRepositoryImpl
import com.terning.data.repositoryimpl.TokenRepositoryImpl
import com.terning.domain.repository.AuthRepository
import com.terning.domain.repository.CalendarRepository
import com.terning.domain.repository.SearchRepository
import com.terning.domain.repository.TokenReissueRepository
import com.terning.domain.repository.TokenRepository
@@ -18,6 +20,10 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {

@Binds
@Singleton
abstract fun calendarRepository(calendarRepositoryImpl: CalendarRepositoryImpl): CalendarRepository

@Binds
@Singleton
abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository
7 changes: 7 additions & 0 deletions app/src/main/java/com/terning/point/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.terning.point.di

import com.terning.data.service.AuthService
import com.terning.data.service.CalendarService
import com.terning.data.service.SearchService
import com.terning.data.service.TokenReissueService
import com.terning.point.di.qualifier.JWT
@@ -26,6 +27,12 @@ object ServiceModule {
fun provideSearchService(@JWT retrofit: Retrofit): SearchService =
retrofit.create(SearchService::class.java)

@Provides
@Singleton
fun provideCalendarService(@JWT retrofit: Retrofit): CalendarService =
retrofit.create(CalendarService::class.java)


@Provides
@Singleton
fun provideTokenReissueService(@REISSUE retrofit: Retrofit): TokenReissueService =
Original file line number Diff line number Diff line change
@@ -24,11 +24,12 @@ import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.getStringAsTitle
import com.terning.core.extension.noRippleClickable
import java.time.LocalDate
import java.time.YearMonth

@Composable
fun CalendarTopAppBar(
modifier: Modifier = Modifier,
date: LocalDate,
date: YearMonth,
isWeekExpanded: Boolean,
isListExpanded: Boolean,
onListButtonClicked: () -> Unit,
@@ -58,7 +59,7 @@ fun CalendarTopAppBar(
)
}
Text(
text = date.getStringAsTitle(),
text = LocalDate.of(date.year, date.month, 1).getStringAsTitle(),
style = TerningTheme.typography.title2,
color = Black,
modifier = Modifier.padding(horizontal = 8.dp)
@@ -97,7 +98,7 @@ fun CalendarTopAppBar(
fun CalendarTopBarPreview() {
TerningPointTheme {
CalendarTopAppBar(
date = LocalDate.now(),
date = YearMonth.now(),
isListExpanded = false,
isWeekExpanded = false
,
6 changes: 6 additions & 0 deletions core/src/main/java/com/terning/core/extension/LocalDateExt.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.terning.core.extension

import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.format.TextStyle
import java.util.Locale

@@ -10,6 +11,11 @@ fun LocalDate.getStringAsTitle(): String =
fun LocalDate.getDateStringInKorean(): String =
"${monthValue}월 ${dayOfMonth}일 ${dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN)}"

fun LocalDate.getDateAsMapString(): String {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
return format(formatter)
}

fun LocalDate.getWeekIndexContainingSelectedDate(inDays: Int): Int = (inDays + dayOfMonth - 1) / 7

fun LocalDate.isToday(): Boolean = this == LocalDate.now()
3 changes: 3 additions & 0 deletions core/src/main/java/com/terning/core/extension/Map.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.terning.core.extension

fun<T> List<T>?.isListNotEmpty():Boolean = this.orEmpty().isNotEmpty()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.terning.data.datasource

import com.terning.data.dto.BaseResponse
import com.terning.data.dto.request.CalendarDayListRequestDto
import com.terning.data.dto.request.CalendarMonthListRequestDto
import com.terning.data.dto.request.CalendarMonthRequestDto
import com.terning.data.dto.response.CalendarDayListResponseDto
import com.terning.data.dto.response.CalendarMonthListResponseDto
import com.terning.data.dto.response.CalendarMonthResponseDto

interface CalendarDataSource {
suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse<List<CalendarMonthResponseDto>>
suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse<List<CalendarMonthListResponseDto>>
suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse<List<CalendarDayListResponseDto>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.terning.data.datasourceimpl

import com.terning.data.datasource.CalendarDataSource
import com.terning.data.dto.BaseResponse
import com.terning.data.dto.request.CalendarDayListRequestDto
import com.terning.data.dto.request.CalendarMonthListRequestDto
import com.terning.data.dto.request.CalendarMonthRequestDto
import com.terning.data.dto.response.CalendarDayListResponseDto
import com.terning.data.dto.response.CalendarMonthListResponseDto
import com.terning.data.dto.response.CalendarMonthResponseDto
import com.terning.data.service.CalendarService
import javax.inject.Inject

class CalendarDataSourceImpl @Inject constructor(
private val calendarService: CalendarService
) : CalendarDataSource {
override suspend fun getCalendarMonth(request: CalendarMonthRequestDto): BaseResponse<List<CalendarMonthResponseDto>> =
calendarService.getCalendarScrapMonth(request.year, request.month)

override suspend fun getCalendarMonthList(request: CalendarMonthListRequestDto): BaseResponse<List<CalendarMonthListResponseDto>> =
calendarService.getCalendarScrapMonthList(request.year, request.month)

override suspend fun getCalendarDayList(request: CalendarDayListRequestDto): BaseResponse<List<CalendarDayListResponseDto>> =
calendarService.getCalendarScrapDayList(request.date)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.terning.data.dto.request

data class CalendarDayListRequestDto(
val date: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.terning.data.dto.request

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

@Serializable
data class CalendarMonthListRequestDto(
@SerialName("deadline")
val year: Int,
@SerialName("scraps")
val month: Int
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.terning.data.dto.request

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

@Serializable
data class CalendarMonthRequestDto(
@SerialName("year")
val year: Int,
@SerialName("month")
val month: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.terning.data.dto.response

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

@Serializable
data class CalendarDayListResponseDto(
@SerialName("scrapId")
val scrapId: Long,
@SerialName("internshipAnnouncementId")
val internshipAnnouncementId: Long,
@SerialName("title")
val title: String,
@SerialName("dDay")
val dDay: String,
@SerialName("workingPeriod")
val workingPeriod: String,
@SerialName("color")
val color: String,
@SerialName("companyImage")
val companyImage: String,
@SerialName("startYear")
val startYear: Int,
@SerialName("startMonth")
val startMonth: Int
){
fun toScrapDetailModelList(): CalendarScrapDetailModel =
CalendarScrapDetailModel(
scrapId = scrapId,
internshipAnnouncementId = internshipAnnouncementId,
title = title,
dDay = dDay,
workingPeriod = workingPeriod,
color = color,
companyImage = companyImage,
startYear = startYear,
startMonth = startMonth,
deadLine = ""
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.terning.data.dto.response

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

@Serializable
data class CalendarMonthListResponseDto(
@SerialName("deadline")
val deadline: String,
@SerialName("scraps")
val scraps: List<Scrap>
) {
@Serializable
data class Scrap(
@SerialName("scrapId")
val scrapId: Long,
@SerialName("internshipAnnouncementId")
val internshipAnnouncementId: Long,
@SerialName("title")
val title: String,
@SerialName("dDay")
val dDay: String,
@SerialName("workingPeriod")
val workingPeriod: String,
@SerialName("color")
val color: String,
@SerialName("companyImage")
val companyImage: String,
@SerialName("startYear")
val startYear: Int,
@SerialName("startMonth")
val startMonth: Int
)

fun toScrapDetailModelList(): List<CalendarScrapDetailModel> = scraps.map { scrap ->
CalendarScrapDetailModel(
scrapId = scrap.scrapId,
internshipAnnouncementId = scrap.internshipAnnouncementId,
title = scrap.title,
dDay = scrap.dDay,
workingPeriod = scrap.workingPeriod,
color = scrap.color,
companyImage = scrap.companyImage,
startYear = scrap.startYear,
startMonth = scrap.startMonth,
deadLine = deadline
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.terning.data.dto.response

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

@Serializable
data class CalendarMonthResponseDto(
@SerialName("deadline")
val deadline: String,
@SerialName("scraps")
val scraps: List<Scrap>
) {
@Serializable
data class Scrap(
@SerialName("scrapId")
val scrapId: Long,
@SerialName("title")
val title: String,
@SerialName("color")
val color: String
)

fun toScrapModelList(): List<CalendarScrapModel> = scraps.map { scrap ->
CalendarScrapModel(
scrapId = scrap.scrapId,
title = scrap.title,
color = scrap.color,
deadLine = deadline,
isScrapped = true
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.terning.data.repositoryimpl

import com.terning.data.datasource.CalendarDataSource
import com.terning.data.dto.request.CalendarDayListRequestDto
import com.terning.data.dto.request.CalendarMonthListRequestDto
import com.terning.data.dto.request.CalendarMonthRequestDto
import com.terning.domain.entity.response.CalendarScrapDetailModel
import com.terning.domain.entity.response.CalendarScrapModel
import com.terning.domain.repository.CalendarRepository
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class CalendarRepositoryImpl @Inject constructor(
private val calendarDataSource: CalendarDataSource
) : CalendarRepository {
override suspend fun getScrapMonth(
year: Int,
month: Int
): Result<Map<String, List<CalendarScrapModel>>> =
runCatching {
val result = calendarDataSource.getCalendarMonth(
request = CalendarMonthRequestDto(
year = year,
month = month
)
).result

val scrapModelMapByDeadLine = result.flatMap { dto ->
dto.toScrapModelList()
}.groupBy { it.deadLine }

scrapModelMapByDeadLine
}

override suspend fun getScrapMonthList(
year: Int,
month: Int
): Result<Map<String, List<CalendarScrapDetailModel>>> =
runCatching {
val result = calendarDataSource.getCalendarMonthList(
request = CalendarMonthListRequestDto(
year = year,
month = month
)
).result

val scrapModelMapByDeadLine = result.flatMap { dto ->
dto.toScrapDetailModelList()
}.groupBy { it.deadLine }

scrapModelMapByDeadLine
}

override suspend fun getScrapDayList(
currentDate: LocalDate
): Result<List<CalendarScrapDetailModel>> =
runCatching {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val request = CalendarDayListRequestDto(currentDate.format(formatter))
val response = calendarDataSource.getCalendarDayList(request)
val scrapModelList = response.result.map { scrap ->
scrap.toScrapDetailModelList()
}
scrapModelList
}
}
Loading
Loading