-
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 #117 from soma-baekgu/feature/BG-240-create-task-e…
…vent [BG-240]: 태스크 이벤트 생성 (2h / 2h)
- Loading branch information
Showing
12 changed files
with
281 additions
and
2 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
13 changes: 13 additions & 0 deletions
13
api/src/main/kotlin/com/backgu/amaker/api/event/dto/TaskEventCreateDto.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.backgu.amaker.api.event.dto | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class TaskEventCreateDto( | ||
val eventTitle: String, | ||
val eventDetails: String, | ||
val assignees: List<String>, | ||
val deadLine: LocalDateTime, | ||
val notificationStartHour: Int, | ||
val notificationStartMinute: Int, | ||
val interval: Int, | ||
) |
23 changes: 23 additions & 0 deletions
23
api/src/main/kotlin/com/backgu/amaker/api/event/dto/TaskEventDto.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,23 @@ | ||
package com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.domain.event.TaskEvent | ||
import java.time.LocalDateTime | ||
|
||
data class TaskEventDto( | ||
val id: Long, | ||
val eventTitle: String, | ||
val deadLine: LocalDateTime, | ||
val notificationStartTime: LocalDateTime, | ||
val notificationInterval: Int, | ||
) { | ||
companion object { | ||
fun of(reactionEvent: TaskEvent) = | ||
TaskEventDto( | ||
id = reactionEvent.id, | ||
eventTitle = reactionEvent.eventTitle, | ||
deadLine = reactionEvent.deadLine, | ||
notificationStartTime = reactionEvent.notificationStartTime, | ||
notificationInterval = reactionEvent.notificationInterval, | ||
) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
api/src/main/kotlin/com/backgu/amaker/api/event/dto/request/TaskEventCreateRequest.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,40 @@ | ||
package com.backgu.amaker.api.event.dto.request | ||
|
||
import com.backgu.amaker.api.event.dto.TaskEventCreateDto | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.Size | ||
import org.springframework.format.annotation.DateTimeFormat | ||
import java.time.LocalDateTime | ||
|
||
data class TaskEventCreateRequest( | ||
@Schema(description = "제목", example = "제목 어때요?") | ||
@field:NotBlank(message = "이벤트 제목을 입력해주세요.") | ||
val eventTitle: String, | ||
@Schema(description = "상세내용", example = "상세내용 어때요?") | ||
@field:NotBlank(message = "이벤트 내용을 입력해주세요.") | ||
val eventDetails: String, | ||
@Schema(description = "답변을 요청할 인원", example = "[\"user1\", \"user2\"]") | ||
@field:Size(min = 1, message = "최소 한 명 이상의 인원을 지정해야 합니다.") | ||
val assignees: List<String>, | ||
@Schema(description = "마감 기한", example = "2021-08-01T00:00:00") | ||
@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
val deadLine: LocalDateTime, | ||
@Schema(description = "알림 시작 시간", example = "1") | ||
val notificationStartHour: Int, | ||
@Schema(description = "알림 시작 분", example = "30") | ||
val notificationStartMinute: Int, | ||
@Schema(description = "알림 주기", example = "15") | ||
val interval: Int, | ||
) { | ||
fun toDto() = | ||
TaskEventCreateDto( | ||
eventTitle = eventTitle, | ||
eventDetails = eventDetails, | ||
assignees = assignees, | ||
deadLine = deadLine, | ||
notificationStartMinute = notificationStartMinute, | ||
notificationStartHour = notificationStartHour, | ||
interval = interval, | ||
) | ||
} |
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
20 changes: 20 additions & 0 deletions
20
domain/src/main/kotlin/com/backgu/amaker/domain/event/TaskEvent.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,20 @@ | ||
package com.backgu.amaker.domain.event | ||
|
||
import java.time.LocalDateTime | ||
|
||
class TaskEvent( | ||
id: Long, | ||
eventTitle: String, | ||
val eventDetails: String, | ||
deadLine: LocalDateTime, | ||
notificationStartTime: LocalDateTime, | ||
notificationInterval: Int, | ||
createdAt: LocalDateTime = LocalDateTime.now(), | ||
updatedAt: LocalDateTime = LocalDateTime.now(), | ||
) : Event(id, eventTitle, deadLine, notificationStartTime, notificationInterval, createdAt, updatedAt) { | ||
companion object { | ||
const val EVENT_TYPE = "TASK" | ||
} | ||
|
||
override fun getEventType(): String = EVENT_TYPE | ||
} |
23 changes: 23 additions & 0 deletions
23
infra/src/main/kotlin/com/backgu/amaker/application/event/service/TaskEventService.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,23 @@ | ||
package com.backgu.amaker.application.event.service | ||
|
||
import com.backgu.amaker.common.exception.BusinessException | ||
import com.backgu.amaker.common.status.StatusCode | ||
import com.backgu.amaker.domain.event.TaskEvent | ||
import com.backgu.amaker.infra.jpa.event.entity.TaskEventEntity | ||
import com.backgu.amaker.infra.jpa.event.repository.TaskEventRepository | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class TaskEventService( | ||
private val taskEventRepository: TaskEventRepository, | ||
) { | ||
@Transactional | ||
fun save(replyEvent: TaskEvent): TaskEvent = taskEventRepository.save(TaskEventEntity.of(replyEvent)).toDomain() | ||
|
||
fun getById(id: Long): TaskEvent = | ||
taskEventRepository.findByIdOrNull(id)?.toDomain() | ||
?: throw BusinessException(StatusCode.EVENT_NOT_FOUND) | ||
} |
51 changes: 51 additions & 0 deletions
51
infra/src/main/kotlin/com/backgu/amaker/infra/jpa/event/entity/TaskEventEntity.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,51 @@ | ||
package com.backgu.amaker.infra.jpa.event.entity | ||
|
||
import com.backgu.amaker.domain.event.TaskEvent | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.DiscriminatorValue | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Table | ||
import java.time.LocalDateTime | ||
|
||
@Entity(name = "TaskEvent") | ||
@Table(name = "task_event") | ||
@DiscriminatorValue(value = "TASK") | ||
class TaskEventEntity( | ||
@Column(nullable = false) | ||
val eventDetails: String, | ||
id: Long, | ||
eventTitle: String, | ||
deadLine: LocalDateTime, | ||
notificationStartTime: LocalDateTime, | ||
notificationInterval: Int, | ||
) : EventEntity( | ||
id = id, | ||
eventTitle = eventTitle, | ||
deadLine = deadLine, | ||
notificationStartTime = notificationStartTime, | ||
notificationInterval = notificationInterval, | ||
) { | ||
override fun toDomain(): TaskEvent = | ||
TaskEvent( | ||
id = id, | ||
eventTitle = eventTitle, | ||
eventDetails = eventDetails, | ||
deadLine = deadLine, | ||
notificationStartTime = notificationStartTime, | ||
notificationInterval = notificationInterval, | ||
createdAt = createdAt, | ||
updatedAt = updatedAt, | ||
) | ||
|
||
companion object { | ||
fun of(taskEvent: TaskEvent) = | ||
TaskEventEntity( | ||
id = taskEvent.id, | ||
eventTitle = taskEvent.eventTitle, | ||
eventDetails = taskEvent.eventDetails, | ||
deadLine = taskEvent.deadLine, | ||
notificationStartTime = taskEvent.notificationStartTime, | ||
notificationInterval = taskEvent.notificationInterval, | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
infra/src/main/kotlin/com/backgu/amaker/infra/jpa/event/repository/TaskEventRepository.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,6 @@ | ||
package com.backgu.amaker.infra.jpa.event.repository | ||
|
||
import com.backgu.amaker.infra.jpa.event.entity.TaskEventEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface TaskEventRepository : JpaRepository<TaskEventEntity, Long> |