diff --git a/src/main/java/com/tiki/server/document/entity/Document.java b/src/main/java/com/tiki/server/document/entity/Document.java index 9ce00b0f..1c9de49b 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -2,6 +2,8 @@ import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PRIVATE; +import static lombok.AccessLevel.PROTECTED; import com.tiki.server.common.entity.BaseTime; import com.tiki.server.timeblock.entity.TimeBlock; @@ -12,13 +14,16 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Entity @Getter -@NoArgsConstructor +@Builder(access = PRIVATE) +@AllArgsConstructor(access = PRIVATE) +@NoArgsConstructor(access = PROTECTED) public class Document extends BaseTime { @Id @@ -34,7 +39,6 @@ public class Document extends BaseTime { @JoinColumn(name = "block_id") private TimeBlock timeBlock; - @Builder public static Document of(String fileName, String fileUrl, TimeBlock timeBlock) { return Document.builder() .fileName(fileName) diff --git a/src/main/java/com/tiki/server/timeblock/entity/TimeBlock.java b/src/main/java/com/tiki/server/timeblock/entity/TimeBlock.java index ddabeaba..4ab18e37 100644 --- a/src/main/java/com/tiki/server/timeblock/entity/TimeBlock.java +++ b/src/main/java/com/tiki/server/timeblock/entity/TimeBlock.java @@ -3,12 +3,15 @@ import static jakarta.persistence.EnumType.STRING; import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PRIVATE; +import static lombok.AccessLevel.PROTECTED; import java.time.LocalDate; import com.tiki.server.common.entity.BaseTime; import com.tiki.server.common.entity.Position; import com.tiki.server.team.entity.Team; +import com.tiki.server.timeblock.dto.request.TimeBlockCreationRequest; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -17,13 +20,16 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Entity @Getter -@NoArgsConstructor +@Builder(access = PRIVATE) +@AllArgsConstructor(access = PRIVATE) +@NoArgsConstructor(access = PROTECTED) public class TimeBlock extends BaseTime { @Id @@ -46,21 +52,13 @@ public class TimeBlock extends BaseTime { @JoinColumn(name = "team_id") private Team team; - @Builder - public static TimeBlock of( - String name, - String color, - Position accessiblePosition, - LocalDate startDate, - LocalDate endDate, - Team team - ) { + public static TimeBlock of(Team team, Position accessiblePosition, TimeBlockCreationRequest request) { return TimeBlock.builder() - .name(name) - .color(color) + .name(request.name()) + .color(request.color()) .accessiblePosition(accessiblePosition) - .startDate(startDate) - .endDate(endDate) + .startDate(request.startDate()) + .endDate(request.endDate()) .team(team) .build(); } diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index c6ef376e..fb360327 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -71,14 +71,7 @@ private void checkMemberAccessible(Position accessiblePosition, Position memberP } private TimeBlock createTimeBlock(Team team, Position accessiblePosition, TimeBlockCreationRequest request) { - return TimeBlock.of( - request.name(), - request.color(), - accessiblePosition, - request.startDate(), - request.endDate(), - team - ); + return TimeBlock.of(team, accessiblePosition, request); } private void saveDocuments(Map files, TimeBlock timeBlock) {