-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
51 changed files
with
1,082 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/terning/data/datasource/CalendarDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>> | ||
} |
25 changes: 25 additions & 0 deletions
25
data/src/main/java/com/terning/data/datasourceimpl/CalendarDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
5 changes: 5 additions & 0 deletions
5
data/src/main/java/com/terning/data/dto/request/CalendarDayListRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
13 changes: 13 additions & 0 deletions
13
data/src/main/java/com/terning/data/dto/request/CalendarMonthListRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
|
12 changes: 12 additions & 0 deletions
12
data/src/main/java/com/terning/data/dto/request/CalendarMonthRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
42 changes: 42 additions & 0 deletions
42
data/src/main/java/com/terning/data/dto/response/CalendarDayListResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" | ||
) | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
data/src/main/java/com/terning/data/dto/response/CalendarMonthListResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
data/src/main/java/com/terning/data/dto/response/CalendarMonthResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
data/src/main/java/com/terning/data/repositoryimpl/CalendarRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.