Skip to content

Commit

Permalink
수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chs98412 committed Dec 1, 2024
1 parent 7053b95 commit 901f54f
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ class ScheduleCommandService(

fun modifySchedule(command: ScheduleModifyCommand) {
scheduleRepository.findByIdOrNull(command.scheduleNo)?.let {
val partnerNo = coupleQueryService.getLover(command.accountNo).no
if (scheduleRepository.existsByDuplicateSchedule(command.scheduleStartAt, command.scheduleEndAt, command.accountNo, partnerNo)) {
throw ScheduleDuplicatedException("시간대에 겹치는 일정이 존재합니다")
}
it.updateSchedule(command)
scheduleRepository.save(it)
} ?: throw ScheduleNotFoundException("존재하지 않습니다")
//TODO: 수정 요청 상태 변경
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Schedule(
this.scheduleStartAt = command.scheduleStartAt
this.scheduleEndAt = command.scheduleEndAt
this.isCommon = command.isCommon
this.scheduleAt = command.scheduleAt
this.scheduleAt = command.scheduleStartAt.toLocalDate()
}

companion object {
Expand All @@ -92,7 +92,7 @@ class Schedule(
scheduleStartAt = command.scheduleStartAt,
scheduleEndAt = command.scheduleEndAt,
isCommon = command.isCommon,
scheduleAt = command.scheduleAt
scheduleAt = command.scheduleStartAt.toLocalDate()
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ScheduleModifyRequest(
scheduleStartAt = command.scheduleStartAt,
scheduleEndAt = command.scheduleEndAt,
isCommon = command.isCommon,
scheduleAt = command.scheduleAt
scheduleAt = command.scheduleStartAt.toLocalDate()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ interface ScheduleRepository : JpaRepository<Schedule, Int>, ScheduleRepositoryC
// 일정 상세 조회
fun findByAccountNoAndScheduleNo(accountNo: Int, scheduleNo: Int): Schedule

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yedongsoon.example_project.domain.schedule.model

import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleCreateCommand(
Expand All @@ -13,5 +12,4 @@ data class ScheduleCreateCommand(
val scheduleStartAt: LocalDateTime,
val scheduleEndAt: LocalDateTime,
val isCommon: Boolean,
val scheduleAt: LocalDate,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yedongsoon.example_project.domain.schedule.model

import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleModifyCommand(
Expand All @@ -15,5 +14,4 @@ data class ScheduleModifyCommand(
val scheduleStartAt: LocalDateTime,
val scheduleEndAt: LocalDateTime,
val isCommon: Boolean,
val scheduleAt: LocalDate,
)
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yedongsoon.example_project.domain.schedule.model

import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleModifyRequestCreateCommand(
Expand All @@ -14,5 +13,4 @@ data class ScheduleModifyRequestCreateCommand(
val scheduleStartAt: LocalDateTime,
val scheduleEndAt: LocalDateTime,
val isCommon: Boolean,
val scheduleAt: LocalDate,
)
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.yedongsoon.example_project.presentation.handler.model

import com.yedongsoon.example_project.domain.schedule.model.ScheduleCreateCommand
import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleCreateRequest(
Expand All @@ -13,7 +12,6 @@ data class ScheduleCreateRequest(
val scheduleStartAt: LocalDateTime,
val scheduleEndAt: LocalDateTime,
val isCommon: Boolean,
val scheduleAt: LocalDate
) {
// 입력값 -> command
fun toCommand(no: Int) = ScheduleCreateCommand(
Expand All @@ -26,7 +24,5 @@ data class ScheduleCreateRequest(
scheduleStartAt = scheduleStartAt,
scheduleEndAt = scheduleEndAt,
isCommon = isCommon,
scheduleAt = scheduleAt
)
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.yedongsoon.example_project.presentation.handler.model

import com.yedongsoon.example_project.domain.schedule.model.ScheduleModifyCommand
import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleModifyRequest(
Expand All @@ -21,8 +20,6 @@ data class ScheduleModifyRequest(
val scheduleEndAt: LocalDateTime,

val isCommon: Boolean,

val scheduleAt: LocalDate
) {
fun toCommand(scheduleNo: Int, accountNo: Int) = ScheduleModifyCommand(
accountNo = accountNo,
Expand All @@ -36,6 +33,5 @@ data class ScheduleModifyRequest(
scheduleStartAt = scheduleStartAt,
scheduleEndAt = scheduleEndAt,
isCommon = isCommon,
scheduleAt = scheduleAt
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.yedongsoon.example_project.presentation.handler.model

import com.yedongsoon.example_project.domain.schedule.model.ScheduleModifyRequestCreateCommand
import java.time.LocalDate
import java.time.LocalDateTime

data class ScheduleModifyRequestCreateDto(
Expand All @@ -14,19 +13,17 @@ data class ScheduleModifyRequestCreateDto(
val scheduleStartAt: LocalDateTime,
val scheduleEndAt: LocalDateTime,
val isCommon: Boolean,
val scheduleAt: LocalDate,
) {
fun toCommand(no: Int) = ScheduleModifyRequestCreateCommand(
scheduleNo = scheduleNo,
requestAccountNo = no,
busyLevel = busyLevel,
scheduleName = scheduleName,
scheduleLocation = scheduleLocation,
scheduleWith = scheduleWith,
groupGenderType = groupGenderType,
scheduleStartAt = scheduleStartAt,
scheduleEndAt = scheduleEndAt,
isCommon = isCommon,
scheduleAt = scheduleAt,
)
fun toCommand(no: Int) = ScheduleModifyRequestCreateCommand(
scheduleNo = scheduleNo,
requestAccountNo = no,
busyLevel = busyLevel,
scheduleName = scheduleName,
scheduleLocation = scheduleLocation,
scheduleWith = scheduleWith,
groupGenderType = groupGenderType,
scheduleStartAt = scheduleStartAt,
scheduleEndAt = scheduleEndAt,
isCommon = isCommon,
)
}

0 comments on commit 901f54f

Please sign in to comment.