Skip to content

Commit

Permalink
[REFACTOR] 객체 생성 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Chan531 committed Jul 11, 2024
1 parent 7269d1d commit ce8dc19
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/tiki/server/document/entity/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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)
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/com/tiki/server/timeblock/entity/TimeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> files, TimeBlock timeBlock) {
Expand Down

0 comments on commit ce8dc19

Please sign in to comment.