API 및 메서드 네이밍 규칙
ex)팀 관련 api → teamCreate, teamUpdate 등
비즈니스 로직 (서비스 레이어 메서드) → createTeam, updateTeam
조회 시, find 네이밍 사용 → get은 알맞은 상황이면 사용 아니면 지양
한 개 받을 땐 Optional, 두 개 이상 리스트는 바로 받기
페이징은 Slice
‘/api/{버전}/~’
DTO 네이밍
@Entity
@Getter
**@NoArgsConstructor(access = AccessLevel.PROTECTED)**
public class Sprint extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "sprint_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "project_id")
private Project project;
private String title;
private String goal;
private LocalDate startDt;
private LocalDate dueDt;
@OneToMany(mappedBy = "sprint", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Feedback> feedbacks = new ArrayList<>();
@OneToMany(mappedBy = "sprint", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Task> tasks = new ArrayList<>();
@OneToMany(mappedBy = "sprint", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Meeting> meetings = new ArrayList<>();
@OneToMany(mappedBy = "sprint", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Contribution> contribution = new ArrayList<>();
private Double progress;
**@Builder(access = AccessLevel.PRIVATE)**
private Sprint(
Project project,
String title,
String goal,
LocalDate startDt,
LocalDate dueDt,
Double progress) {
this.project = project;
this.title = title;
this.goal = goal;
this.startDt = startDt;
this.dueDt = dueDt;
this.progress = progress;
}
public static Sprint **createSprint**(Project project, String title, String goal, LocalDate dueDt) {
validateDueDt(LocalDate.now(), dueDt);
return Sprint.builder()
.project(project)
.title(title)
.goal(goal)
.progress(0.0)
.startDt(LocalDate.now())
.dueDt(dueDt)
.build();
}
public void updateSprint(String goal, LocalDate dueDt) {
if (goal != null) this.goal = goal;
if (dueDt != null) {
validateDueDt(this.startDt, dueDt);
this.dueDt = dueDt;
}
}
public void updateSprintTitle(String title) {
this.title = title;
}
public void updateProgress(Double progress) {
this.progress = progress;
}
}
Spring Guide - Directory - Yun Blog | 기술 블로그