-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from team-haribo/feature/42-write-the-logic-la…
…te-list 🔀 :: (#42) - write the logic late list
- Loading branch information
Showing
19 changed files
with
205 additions
and
75 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
4 changes: 4 additions & 0 deletions
4
core/data/src/main/java/com/goms/data/repository/council/CouncilRepository.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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package com.goms.data.repository.council | ||
|
||
import com.goms.model.response.council.LateResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.datetime.LocalDate | ||
import java.util.UUID | ||
|
||
interface CouncilRepository { | ||
suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> | ||
|
||
suspend fun getLateList(date: LocalDate): Flow<List<LateResponse>> | ||
} |
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
18 changes: 7 additions & 11 deletions
18
core/design-system/src/main/java/com/goms/design_system/util/getDefaultWednesday.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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
package com.goms.design_system.util | ||
|
||
import kotlinx.datetime.* | ||
import java.time.DayOfWeek | ||
import java.time.Instant | ||
import java.time.LocalDate | ||
import java.time.ZoneId | ||
import java.time.temporal.TemporalAdjusters | ||
|
||
fun getDefaultWednesday(): Instant { | ||
val currentDate = LocalDate.now() | ||
|
||
return if (currentDate.dayOfWeek != DayOfWeek.WEDNESDAY) { | ||
val lastWednesday = currentDate.with(TemporalAdjusters.previous(DayOfWeek.WEDNESDAY)) | ||
lastWednesday.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant() | ||
val currentDate = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date | ||
return if (currentDate.dayOfWeek == DayOfWeek.WEDNESDAY) { | ||
currentDate.atStartOfDayIn(TimeZone.currentSystemDefault()) | ||
} else { | ||
currentDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant() | ||
val lastWednesday = currentDate.minus((currentDate.dayOfWeek.ordinal - DayOfWeek.WEDNESDAY.ordinal).toLong(), DateTimeUnit.DAY) | ||
lastWednesday.atStartOfDayIn(TimeZone.currentSystemDefault()) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/domain/src/main/java/com/goms/domain/council/GetLateListUseCase.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,14 @@ | ||
package com.goms.domain.council | ||
|
||
import com.goms.data.repository.council.CouncilRepository | ||
import com.goms.model.response.council.LateResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.datetime.LocalDate | ||
import javax.inject.Inject | ||
|
||
class GetLateListUseCase @Inject constructor( | ||
private val councilRepository: CouncilRepository | ||
) { | ||
suspend operator fun invoke(date: LocalDate): Flow<List<LateResponse>> = | ||
councilRepository.getLateList(date = date) | ||
} |
16 changes: 16 additions & 0 deletions
16
core/model/src/main/java/com/goms/model/response/council/LateResponse.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,16 @@ | ||
package com.goms.model.response.council | ||
|
||
import com.goms.model.enum.Gender | ||
import com.goms.model.enum.Major | ||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class LateResponse( | ||
@Json(name = "accountIdx") val accountIdx: String, | ||
@Json(name = "name") val name: String, | ||
@Json(name = "grade") val grade: Int, | ||
@Json(name = "major") val major: Major, | ||
@Json(name = "gender") val gender: Gender, | ||
@Json(name = "profileUrl") val profileUrl: String? | ||
) |
9 changes: 9 additions & 0 deletions
9
core/network/src/main/java/com/goms/network/api/CouncilAPI.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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package com.goms.network.api | ||
|
||
import com.goms.model.response.council.LateResponse | ||
import kotlinx.datetime.LocalDate | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
import java.util.UUID | ||
|
||
interface CouncilAPI { | ||
@DELETE("/api/v2/student-council/outing/{accountIdx}") | ||
suspend fun deleteOuting( | ||
@Path("accountIdx") accountIdx: UUID | ||
) | ||
|
||
@GET("/api/v2/student-council/late") | ||
suspend fun getLateList( | ||
@Query("date") date: LocalDate | ||
): List<LateResponse> | ||
} |
4 changes: 4 additions & 0 deletions
4
core/network/src/main/java/com/goms/network/datasource/council/CouncilDataSource.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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package com.goms.network.datasource.council | ||
|
||
import com.goms.model.response.council.LateResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.datetime.LocalDate | ||
import java.util.UUID | ||
|
||
interface CouncilDataSource { | ||
suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> | ||
|
||
suspend fun getLateList(date: LocalDate): Flow<List<LateResponse>> | ||
} |
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
Oops, something went wrong.