Skip to content

Commit

Permalink
Merge pull request #69 from Team-B1ND/hotfix/68-localdatetime-out
Browse files Browse the repository at this point in the history
LocalDateTime 및 심자, 외출, 외박 버그 수정
  • Loading branch information
8954sood authored Apr 20, 2024
2 parents d6af5ff + 9e539cc commit 4de4ce3
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 34 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/ProjectProperties.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import org.gradle.api.JavaVersion

object ProjectProperties {
const val VERSION_CODE = 32
const val VERSION_NAME = "2.2.1"
const val VERSION_CODE = 33
const val VERSION_NAME = "2.2.2"

const val APPLICATION_ID = "kr.hs.dgsw.smartschool.dodamdodam_teacher"
const val NAME_SPACE_DOMAIN = "kr.hs.dgsw.smartschool.domain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fun String?.yearDateTimeToLocalDate(): LocalDateTime {
try {
if (this != null) {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
return LocalDateTime.parse(this, formatter)
return LocalDateTime.parse(this.split(".")[0], formatter)
}
} catch (e: Exception) {
e.printStackTrace()
Expand All @@ -23,7 +23,8 @@ fun String?.yearDateTimeToLocalDate(): LocalDateTime {
}
fun String.yearDateTimeToLocalDateT(): LocalDateTime {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
return LocalDateTime.parse(this, formatter)
val time = if (length == 16) "$this:00" else this
return LocalDateTime.parse(time.split(".")[0], formatter)
}

fun String.yearDateTimeHourToLocalDate(): LocalDateTime {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kr.hs.dgsw.smartschool.local.mapper

import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDate
import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDateT
import kr.hs.dgsw.smartschool.domain.model.member.Member
import kr.hs.dgsw.smartschool.domain.model.member.MemberRole
import kr.hs.dgsw.smartschool.domain.model.member.MemberStatus
Expand Down Expand Up @@ -56,8 +57,8 @@ internal fun Member.toEntity(): MemberEntity {
status = status.name.toMemberStatus(),
teacher = teacher,
student = student,
createdAt = createdAt.yearDateTimeToLocalDate().toString(),
modifiedAt = modifiedAt.yearDateTimeToLocalDate().toString(),
createdAt = createdAt.yearDateTimeToLocalDateT().toString(),
modifiedAt = modifiedAt.yearDateTimeToLocalDateT().toString(),
phone = phone
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ fun OutScreen(
val refreshState = rememberPullRefreshState(
refreshing = state.refreshing,
onRefresh = {
outViewModel.getOutsRefresh()
if (state.currentOutType == 0) {
outViewModel.getOutsRefresh()
} else {
outViewModel.getOutSleepingRefresh()
}
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,35 @@ class OutViewModel @Inject constructor(
reduce {
state.copy(
refreshing = false,
outGoings = it,
outSleepings = it,
outGoings = it.filter { it.status == OutStatus.PENDING },
)
}
}.onFailure {
reduce {
state.copy(
refreshing = false,
)
}
postSideEffect(OutSideEffect.ShowException(it))
}
}

fun getOutSleepingRefresh() = intent {
reduce {
state.copy(
refreshing = true,
)
}

getOutsByDateRemoteUseCase.getOutSleeping(
GetOutsByDateRemoteUseCase.Param(
date = LocalDate.now().toString()
)
).onSuccess {
reduce {
state.copy(
refreshing = false,
outSleepings = it.filter { it.status == OutStatus.PENDING },
)
}
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,26 @@ class CurrentOutViewModel @Inject constructor(
refreshing = true,
)
}
val param = GetOutsByDateRemoteUseCase.Param(
LocalDate.now().toString()
)

getOutsByDateRemoteUseCase(
GetOutsByDateRemoteUseCase.Param(
LocalDate.now().toString()
)
).onSuccess { outGoing ->
getOutsByDateRemoteUseCase.getOutSleepingValid().onSuccess { outSleeping ->
getOutsByDateRemoteUseCase(param).onSuccess { outGoing ->
getOutsByDateRemoteUseCase.getOutSleeping(param).onSuccess { outSleeping ->
reduce {
state.copy(
refreshing = false,
outGoings = outGoing.filter { it.status == OutStatus.ALLOWED },
outSleepings = outSleeping.filter { it.status == OutStatus.ALLOWED },
)
}
}.onFailure {
reduce {
state.copy(
refreshing = false,
outGoings = outGoing,
outSleepings = outSleeping,
)
}
postSideEffect(CurrentOutSideEffect.ShowException(it))
}
}.onFailure {
reduce {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kr.hs.dgsw.smartschool.remote.mapper

import kr.hs.dgsw.smartschool.data.data.auth.LoginData
import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDate
import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDateT
import kr.hs.dgsw.smartschool.domain.model.member.Member
import kr.hs.dgsw.smartschool.domain.model.member.MemberRole
import kr.hs.dgsw.smartschool.domain.model.member.MemberStatus
Expand All @@ -28,8 +28,8 @@ internal fun MemberResponse.toMember(): Member =
phone = phone,
student = student?.toModel(),
teacher = teacher?.toModel(),
createdAt = createdAt?.yearDateTimeToLocalDate().toString(),
modifiedAt = modifiedAt?.yearDateTimeToLocalDate().toString(),
createdAt = createdAt?.yearDateTimeToLocalDateT().toString(),
modifiedAt = modifiedAt?.yearDateTimeToLocalDateT().toString(),
)

internal fun MemberResponseRole.toMemberRole(): MemberRole =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kr.hs.dgsw.smartschool.remote.mapper

import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDate
import kr.hs.dgsw.smartschool.data.utils.yearDateTimeToLocalDateT
import kr.hs.dgsw.smartschool.domain.model.out.Out
import kr.hs.dgsw.smartschool.domain.model.out.OutItem
import kr.hs.dgsw.smartschool.domain.model.out.OutStatus
Expand All @@ -22,9 +23,9 @@ internal fun OutResponse.toOut(): Out {
rejectReason = rejectReason ?: "",
startOutDate = startOutDate,
endOutDate = endOutDate,
createdAt = createdAt.yearDateTimeToLocalDate().toString(),
createdAt = createdAt.yearDateTimeToLocalDateT().toString(),

modifiedAt = modifiedAt.yearDateTimeToLocalDate().toString()
modifiedAt = modifiedAt.yearDateTimeToLocalDateT().toString()
)
}

Expand Down

0 comments on commit 4de4ce3

Please sign in to comment.