-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
76 changed files
with
1,073 additions
and
693 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
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
68 changes: 44 additions & 24 deletions
68
...c/main/java/org/sopt/makers/operation/web/alarm/dto/request/AlarmScheduleSendRequest.java
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,43 +1,63 @@ | ||
package org.sopt.makers.operation.web.alarm.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.List; | ||
|
||
import lombok.val; | ||
|
||
import org.sopt.makers.operation.alarm.domain.Alarm; | ||
import org.sopt.makers.operation.alarm.domain.AlarmType; | ||
import org.sopt.makers.operation.alarm.domain.Category; | ||
import org.sopt.makers.operation.alarm.domain.LinkType; | ||
import org.sopt.makers.operation.alarm.domain.Status; | ||
import org.sopt.makers.operation.alarm.domain.TargetType; | ||
import org.sopt.makers.operation.common.domain.Part; | ||
import org.sopt.makers.operation.alarm.domain.AlarmTarget; | ||
import org.sopt.makers.operation.alarm.domain.AlarmContent; | ||
import org.sopt.makers.operation.alarm.domain.AlarmCategory; | ||
import org.sopt.makers.operation.alarm.domain.AlarmTargetType; | ||
import org.sopt.makers.operation.alarm.domain.AlarmTargetPart; | ||
import org.sopt.makers.operation.alarm.domain.AlarmLinkType; | ||
|
||
import static org.sopt.makers.operation.constant.AlarmConstant.ALARM_REQUEST_DATE_FORMAT; | ||
import static org.sopt.makers.operation.constant.AlarmConstant.ALARM_REQUEST_TIME_FORMAT; | ||
|
||
public record AlarmScheduleSendRequest( | ||
@NotNull Integer createdGeneration, | ||
@NotNull String title, | ||
@NotNull String content, | ||
@NotNull Category category, | ||
@NotNull TargetType targetType, | ||
@NotNull AlarmCategory category, | ||
@NotNull AlarmTargetType targetType, | ||
List<String> targetList, | ||
Part part, | ||
LinkType linkType, | ||
AlarmTargetPart part, | ||
Integer createdGeneration, | ||
AlarmLinkType linkType, | ||
String link, | ||
@NotNull String postDate, | ||
@NotNull String postTime | ||
) { | ||
private AlarmTarget toTargetEntity() { | ||
return switch (this.targetType) { | ||
case ALL -> this.part.equals(AlarmTargetPart.ALL) | ||
? AlarmTarget.all() | ||
: AlarmTarget.partialForAll(this.part, this.targetList); | ||
case ACTIVE -> AlarmTarget.partialForActive(this.createdGeneration, this.part, this.targetList); | ||
case CSV -> AlarmTarget.partialForCsv(this.targetList); | ||
}; | ||
} | ||
|
||
private AlarmContent toContentEntity() { | ||
return switch (this.linkType) { | ||
case WEB -> AlarmContent.withWebLink(this.title, this.content, this.category, this.link); | ||
case APP -> AlarmContent.withAppLink(this.title, this.content, this.category, this.link); | ||
case NONE -> AlarmContent.withoutLink(this.title, this.content, this.category); | ||
}; | ||
} | ||
|
||
public Alarm toEntity() { | ||
return Alarm.builder() | ||
.createdGeneration(this.createdGeneration) | ||
.category(this.category) | ||
.title(this.title) | ||
.content(this.content) | ||
.targetType(this.targetType) | ||
.alarmType(AlarmType.RESERVED) | ||
.link(this.link) | ||
.linkType(linkType) | ||
.part(this.part) | ||
.status(Status.SCHEDULED) | ||
.targetList(this.targetList) | ||
.build(); | ||
AlarmTarget targetEntity = this.toTargetEntity(); | ||
AlarmContent contentEntity = this.toContentEntity(); | ||
val date = LocalDate.parse(postDate, DateTimeFormatter.ofPattern(ALARM_REQUEST_DATE_FORMAT)); | ||
val time = LocalTime.parse(postTime, DateTimeFormatter.ofPattern(ALARM_REQUEST_TIME_FORMAT)); | ||
return Alarm.scheduled(targetEntity, contentEntity, LocalDateTime.of(date, time)); | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...ava/org/sopt/makers/operation/web/alarm/dto/request/AlarmScheduleStatusUpdateRequest.java
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,10 @@ | ||
package org.sopt.makers.operation.web.alarm.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record AlarmScheduleStatusUpdateRequest( | ||
@NotNull LocalDateTime sendAt | ||
) { | ||
} |
6 changes: 3 additions & 3 deletions
6
...i/src/main/java/org/sopt/makers/operation/web/alarm/dto/response/AlarmCreateResponse.java
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,19 +1,19 @@ | ||
package org.sopt.makers.operation.web.alarm.dto.response; | ||
|
||
import static lombok.AccessLevel.*; | ||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
import org.sopt.makers.operation.alarm.domain.Alarm; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder(access = PRIVATE) | ||
public record AlarmCreateResponse( | ||
long alarmId | ||
long id | ||
) { | ||
|
||
public static AlarmCreateResponse of(Alarm alarm) { | ||
return AlarmCreateResponse.builder() | ||
.alarmId(alarm.getId()) | ||
.id(alarm.getId()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.