Skip to content

Commit 8d3b5b7

Browse files
authored
Merge pull request #650 from DSM-PICK/develop
merge develop to main
2 parents 61e1fe0 + 91e6a53 commit 8d3b5b7

File tree

14 files changed

+60
-35
lines changed

14 files changed

+60
-35
lines changed

src/main/kotlin/dsm/pick2024/domain/admin/service/QueryMainInfoService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import dsm.pick2024.domain.admin.port.`in`.AdminFacadeUseCase
44
import dsm.pick2024.domain.admin.port.`in`.QueryMainInfoUseCase
55
import dsm.pick2024.domain.admin.presentation.dto.response.QueryMainInfoResponse
66
import dsm.pick2024.domain.selfstudy.port.out.QuerySelfStudyPort
7+
import dsm.pick2024.global.common.TimeUtils
78
import org.springframework.stereotype.Service
89
import org.springframework.transaction.annotation.Transactional
9-
import java.time.LocalDate
1010

1111
@Service
1212
class QueryMainInfoService(
@@ -19,7 +19,7 @@ class QueryMainInfoService(
1919
val admin = adminFacadeUseCase.currentAdmin()
2020

2121
val todaySelfStudy = querySelfStudyPort
22-
.findByTeacherNameAndDate(admin.name, LocalDate.now())
22+
.findByTeacherNameAndDate(admin.name, TimeUtils.nowLocalDate())
2323

2424
return QueryMainInfoResponse(
2525
selfStudyFloor = todaySelfStudy?.floor ?: 0,

src/main/kotlin/dsm/pick2024/domain/classroom/service/QueryFloorClassroomService.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import dsm.pick2024.domain.classroom.exception.FloorNotFoundException
66
import dsm.pick2024.domain.classroom.port.`in`.QueryFloorClassroomUseCase
77
import dsm.pick2024.domain.classroom.port.out.QueryClassroomPort
88
import dsm.pick2024.domain.classroom.presentation.dto.response.QueryClassroomResponse
9-
import org.joda.time.LocalDate
9+
import dsm.pick2024.global.common.TimeUtils
1010
import org.springframework.stereotype.Service
11+
import java.time.DayOfWeek
1112

1213
@Service
1314
class QueryFloorClassroomService(
@@ -19,11 +20,11 @@ class QueryFloorClassroomService(
1920
floor: Int,
2021
status: Status
2122
): List<QueryClassroomResponse> {
22-
val today = LocalDate.now().dayOfWeek
23+
val today = TimeUtils.nowLocalDate().dayOfWeek
2324

2425
val classrooms = when (floor) {
2526
2, 3, 4 -> {
26-
val filteredClassrooms = if (today == 2 || today == 5) {
27+
val filteredClassrooms = if (today == DayOfWeek.TUESDAY || today == DayOfWeek.FRIDAY) {
2728
queryClassroomPort.queryFloorClassroomWithAttendance(floor)
2829
} else {
2930
queryClassroomPort.queryFloorClassroom(floor)
@@ -37,7 +38,7 @@ class QueryFloorClassroomService(
3738
}
3839

3940
return classrooms.map { classroom ->
40-
val move = if (today == 2 || today == 5) {
41+
val move = if (today == DayOfWeek.TUESDAY || today == DayOfWeek.FRIDAY) {
4142
attendanceFinderUseCase.findByUserIdOrThrow(classroom.userId).place ?: ""
4243
} else {
4344
"${classroom.grade}-${classroom.classNum}"

src/main/kotlin/dsm/pick2024/domain/classroom/service/QueryGradeClassroomService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import dsm.pick2024.domain.attendance.port.`in`.AttendanceFinderUseCase
44
import dsm.pick2024.domain.classroom.port.`in`.QueryGradeClassroomUseCase
55
import dsm.pick2024.domain.classroom.port.out.QueryClassroomPort
66
import dsm.pick2024.domain.classroom.presentation.dto.response.QueryClassroomResponse
7-
import org.joda.time.LocalDate
7+
import dsm.pick2024.global.common.TimeUtils
88
import org.springframework.stereotype.Service
99
import org.springframework.transaction.annotation.Transactional
10+
import java.time.DayOfWeek
1011

1112
@Service
1213
class QueryGradeClassroomService(
@@ -18,11 +19,11 @@ class QueryGradeClassroomService(
1819
grade: Int,
1920
classNum: Int
2021
): List<QueryClassroomResponse> {
21-
val today = LocalDate.now().dayOfWeek
22+
val today = TimeUtils.nowLocalDate().dayOfWeek
2223

2324
return queryClassroomPort.queryGradeClassroom(grade, classNum)
2425
.map { classroom ->
25-
val move = if (today == 2 || today == 5) {
26+
val move = if (today == DayOfWeek.TUESDAY || today == DayOfWeek.FRIDAY) {
2627
attendanceFinderUseCase.findByUserIdOrThrow(classroom.userId).place ?: ""
2728
} else {
2829
"${classroom.grade}-${classroom.classNum}"

src/main/kotlin/dsm/pick2024/domain/notice/service/CreateNoticeService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import dsm.pick2024.domain.notice.domain.Notice
55
import dsm.pick2024.domain.notice.port.`in`.CreateNoticeUseCase
66
import dsm.pick2024.domain.notice.port.out.NoticeSavePort
77
import dsm.pick2024.domain.notice.presentation.dto.request.NoticeRequest
8+
import dsm.pick2024.global.common.TimeUtils
89
import org.springframework.stereotype.Service
910
import org.springframework.transaction.annotation.Transactional
10-
import java.time.LocalDateTime
11-
import java.time.ZoneId
1211

1312
@Service
1413
class CreateNoticeService(
@@ -24,7 +23,7 @@ class CreateNoticeService(
2423
Notice(
2524
adminId = admin.id,
2625
teacherName = admin.name,
27-
createAt = LocalDateTime.now(ZoneId.of("Asia/Seoul")),
26+
createAt = TimeUtils.nowLocalDateTime(),
2827
title = request.title,
2928
content = request.content
3029
)

src/main/kotlin/dsm/pick2024/domain/schedule/service/SaveScheduleService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dsm.pick2024.domain.schedule.service
33
import dsm.pick2024.domain.schedule.port.`in`.SaveScheduleUseCase
44
import dsm.pick2024.domain.schedule.port.out.DeleteSchedulePort
55
import dsm.pick2024.domain.schedule.port.out.SaveSchedulePort
6+
import dsm.pick2024.global.common.TimeUtils
67
import dsm.pick2024.global.config.cache.CacheName
78
import dsm.pick2024.infrastructure.feign.neis.NeisScheduleFeignClientService
89
import org.springframework.cache.annotation.CacheEvict
@@ -30,11 +31,11 @@ class SaveScheduleService(
3031
}
3132

3233
private fun formatDate(): Pair<String, String> {
33-
val today = LocalDate.now()
34+
val kstToday = TimeUtils.nowLocalDate()
3435

35-
val start = LocalDate.of(today.year - 1, 1, 1)
36+
val start = LocalDate.of(kstToday.year - 1, 1, 1)
3637

37-
val end = LocalDate.of(today.year + 1, 3, 1)
38+
val end = LocalDate.of(kstToday.year + 1, 3, 1)
3839

3940
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
4041

src/main/kotlin/dsm/pick2024/domain/selfstudy/persistence/SelfStudyPersistenceAdapterPort.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dsm.pick2024.domain.selfstudy.entity.QSelfStudyJpaEntity
66
import dsm.pick2024.domain.selfstudy.mapper.SelfStudyMapper
77
import dsm.pick2024.domain.selfstudy.persistence.repository.SelfStudyRepository
88
import dsm.pick2024.domain.selfstudy.port.out.SelfStudyPort
9+
import dsm.pick2024.global.common.TimeUtils
910
import org.springframework.stereotype.Component
1011
import java.time.LocalDate
1112
import java.time.Month
@@ -40,17 +41,17 @@ class SelfStudyPersistenceAdapterPort(
4041
}
4142

4243
override fun findByTodayTeacher(teacher: String): SelfStudy? {
43-
val day = LocalDate.now()
44-
val nullCheck =
44+
val today = TimeUtils.nowLocalDate()
45+
val entity =
4546
jpaQueryFactory
4647
.selectFrom(QSelfStudyJpaEntity.selfStudyJpaEntity)
4748
.where(
48-
QSelfStudyJpaEntity.selfStudyJpaEntity.date.eq(day),
49+
QSelfStudyJpaEntity.selfStudyJpaEntity.date.eq(today),
4950
QSelfStudyJpaEntity.selfStudyJpaEntity.teacherName.eq(teacher)
5051
)
5152
.fetchOne()
5253

53-
return nullCheck?.let { selfStudyMapper.toDomain(it) }
54+
return entity?.let { selfStudyMapper.toDomain(it) }
5455
}
5556

5657
override fun findByDaySelfStudy(date: LocalDate) =

src/main/kotlin/dsm/pick2024/domain/selfstudy/service/SendNotificationSelfStudyTeacher.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import dsm.pick2024.domain.admin.port.`in`.AdminFinderUseCase
44
import dsm.pick2024.domain.outbox.port.`in`.OutboxFacadeUseCase
55
import dsm.pick2024.domain.selfstudy.port.`in`.SelfStudyFinderUseCase
66
import dsm.pick2024.domain.selfstudy.port.`in`.SendNotificationSelfStudyTeacherUseCase
7+
import dsm.pick2024.global.common.TimeUtils
78
import org.springframework.stereotype.Service
8-
import java.time.LocalDate
99

1010
@Service
1111
class SendNotificationSelfStudyTeacher(
@@ -14,15 +14,15 @@ class SendNotificationSelfStudyTeacher(
1414
private val outboxFacadeUseCase: OutboxFacadeUseCase
1515
) : SendNotificationSelfStudyTeacherUseCase {
1616
override fun execute() {
17-
val selfStudies = selfStudyFinderUseCase.findByDaySelfStudyOrThrow(LocalDate.now()).map { it }
17+
val selfStudies = selfStudyFinderUseCase.findByDaySelfStudyOrThrow(TimeUtils.nowLocalDate())
1818

19-
selfStudies.map {
20-
val admin = adminFinderUseCase.findByAdminNameOrThrow(it.teacherName)
19+
selfStudies.forEach { selfStudy ->
20+
val admin = adminFinderUseCase.findByAdminNameOrThrow(selfStudy.teacherName)
2121
admin.deviceToken?.let { token ->
2222
outboxFacadeUseCase.sendNotification(
2323
deviceToken = token,
2424
title = "[PiCK] 자습감독 알림",
25-
body = "${admin.name}선생님은 오늘 ${it.floor}층 자습감독 선생님입니다."
25+
body = "${admin.name}선생님은 오늘 ${selfStudy.floor}층 자습감독 선생님입니다."
2626
)
2727
}
2828
}

src/main/kotlin/dsm/pick2024/domain/timetable/service/QueryTeacherTimetableService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import dsm.pick2024.domain.timetable.port.`in`.QueryTeacherTimetableUseCase
44
import dsm.pick2024.domain.timetable.port.out.QueryTimeTablePort
55
import dsm.pick2024.domain.timetable.presentation.dto.response.DayTimetableResponse
66
import dsm.pick2024.domain.timetable.presentation.dto.response.PeriodTimetableResponse
7+
import dsm.pick2024.global.common.TimeUtils
78
import dsm.pick2024.infrastructure.s3.FileUtil
89
import dsm.pick2024.infrastructure.s3.PathList
910
import java.time.DayOfWeek
1011
import java.time.LocalDate
11-
import java.time.ZoneId
1212
import org.springframework.stereotype.Service
1313
import org.springframework.transaction.annotation.Transactional
1414

@@ -20,7 +20,7 @@ class QueryTeacherTimetableService(
2020

2121
@Transactional(readOnly = true)
2222
override fun queryTeacherTimetable(grade: Int, classNum: Int): List<DayTimetableResponse> {
23-
val startOfWeek = getStartOfWeek(LocalDate.now(ZoneId.of("Asia/Seoul")))
23+
val startOfWeek = getStartOfWeek(TimeUtils.nowLocalDate())
2424

2525
return (0 until 5).map { i ->
2626
val date = startOfWeek.plusDays(i.toLong())

src/main/kotlin/dsm/pick2024/domain/weekendmeal/service/NotificationWeekendMealService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import dsm.pick2024.domain.weekendmeal.enums.Status
66
import dsm.pick2024.domain.weekendmeal.port.`in`.NotificationWeekendMealUseCase
77
import dsm.pick2024.domain.weekendmeal.port.`in`.WeekendMealFinderUseCase
88
import dsm.pick2024.domain.weekendmeal.port.out.WeekendMealPeriodPort
9+
import dsm.pick2024.global.common.TimeUtils
910
import org.springframework.stereotype.Service
10-
import java.time.LocalDate
1111

1212
@Service
1313
class NotificationWeekendMealService(
@@ -22,10 +22,11 @@ class NotificationWeekendMealService(
2222
}
2323

2424
override fun execute() {
25-
val weekendMealPeriod = weekendMealPeriodPort.queryWeekendPeriodByDate(LocalDate.now())
25+
val today = TimeUtils.nowLocalDate()
26+
val weekendMealPeriod = weekendMealPeriodPort.queryWeekendPeriodByDate(today)
2627
if (weekendMealPeriod != null) {
2728
val users = queryUserPort.findAll()
28-
when (LocalDate.now()) {
29+
when (today) {
2930
weekendMealPeriod.end -> {
3031
users.map {
3132
val status = weekendMealFinderUseCase.findByUserIdOrThrow(it.id).status

src/main/kotlin/dsm/pick2024/domain/weekendmeal/service/PrintAllExcelWeekendMealService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dsm.pick2024.domain.weekendmeal.enums.Status.NO
66
import dsm.pick2024.domain.weekendmeal.enums.Status.OK
77
import dsm.pick2024.domain.weekendmeal.port.`in`.PrintExcelWeekendMealUseCase
88
import dsm.pick2024.domain.weekendmeal.port.out.QueryWeekendMealPort
9-
import java.time.LocalDate
9+
import dsm.pick2024.global.common.TimeUtils
1010
import org.apache.poi.ss.usermodel.BorderStyle
1111
import org.apache.poi.ss.usermodel.CellStyle
1212
import org.apache.poi.ss.usermodel.FillPatternType
@@ -29,7 +29,8 @@ class PrintAllExcelWeekendMealService(
2929

3030
@Transactional(readOnly = true)
3131
override fun execute(response: HttpServletResponse) {
32-
val month = LocalDate.now().monthValue + 1
32+
val kstNow = TimeUtils.nowLocalDate()
33+
val month = kstNow.plusMonths(1).monthValue
3334
val workbook: Workbook = XSSFWorkbook()
3435

3536
// 주말급식 정보

0 commit comments

Comments
 (0)