Skip to content

Commit

Permalink
chore: dto spec 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leeggmin committed Mar 26, 2024
1 parent e9a6959 commit 21e0fea
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ public static <T> T modifyIfNotNull(T newValue, T defaultValue) {
public static int modifyIfNotZero(int newValue, int defaultValue) {
return newValue != 0 ? newValue : defaultValue;
}

public static Integer modifyIfNotZeroPermitNull(Integer newValue, Integer defaultValue) {
return newValue == null || newValue != 0 ? newValue : defaultValue;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public void modifyRecruit(int id, RecruitReq dto) {
ModifyUtil.modifyIfNotNull(dto.name(), recruit.getName()),
ModifyUtil.modifyIfNotNull(dto.location(), recruit.getLocation()),
ModifyUtil.modifyIfNotNull(dto.duty(), recruit.getDuty()),
ModifyUtil.modifyIfNotNull(dto.etc(), recruit.getEtc()),
ModifyUtil.modifyIfNotZero(dto.personnel(), recruit.getPersonnel()),
ModifyUtil.modifyIfNotNull(dto.image(), recruit.getImage()),
dto.etc(),
ModifyUtil.modifyIfNotZeroPermitNull(dto.personnel(), recruit.getPersonnel()),
dto.updateRecruitFile(recruit)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import b1nd.dodamcore.recruit.domain.entity.Recruit;
import b1nd.dodamcore.recruit.domain.entity.RecruitFile;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;

import java.util.List;
import java.util.stream.Collectors;

public record RecruitReq(@NotEmpty String name, @NotEmpty String location, @NotEmpty String duty,
String etc, @Positive @NotNull int personnel, @NotEmpty String image, List<Pdf> pdfs) {
String etc, @Positive Integer personnel, List<Pdf> pdfs) {

public Recruit mapToRecruit(Member member) {
Recruit recruit = Recruit.builder()
Expand All @@ -22,7 +21,6 @@ public Recruit mapToRecruit(Member member) {
.duty(duty)
.etc(etc)
.personnel(personnel)
.image(image)
.build();

pdfs.forEach(pdf -> recruit.addRecruitFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public static RecruitPageRes of(Page<Recruit> recruitPage, Integer nextPage) {
recruit.getLocation(),
recruit.getDuty(),
recruit.getEtc(),
recruit.getPersonnel(),
recruit.getImage()
recruit.getPersonnel()
)).collect(Collectors.toList()),
nextPage);
}

public record RecruitListRes(int id, String writer, String name, String location, String duty,
String etc, int personnel, String image) {
public record RecruitListRes(int id, String writer, String name, String location, String duty, String etc, Integer personnel) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

public record RecruitRes(String writer, String name, String location, String duty,
String etc, int personnel, String image, List<Pdf> pdfs) {
String etc, Integer personnel, List<Pdf> pdfs) {

public static RecruitRes of(Recruit recruit) {
return new RecruitRes(
Expand All @@ -16,7 +16,6 @@ public static RecruitRes of(Recruit recruit) {
recruit.getDuty(),
recruit.getEtc(),
recruit.getPersonnel(),
recruit.getImage(),
Pdf.of(recruit.getRecruitFiles())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,32 @@ public class Recruit extends BaseEntity {
@Column(columnDefinition = "LONGTEXT")
private String etc; //추가 내용

@NotNull
private int personnel; //모집 인원

@NotNull
private String image; //채용 공고 이미지
private Integer personnel; //모집 인원

@OneToMany(mappedBy = "recruit", cascade = CascadeType.ALL)
private List<RecruitFile> recruitFiles = new ArrayList<>();

@Builder
public Recruit(Member writer, String name, String location, String duty, String etc, int personnel, String image) {
public Recruit(Member writer, String name, String location, String duty, String etc, Integer personnel) {
this.writer = writer;
this.name = name;
this.location = location;
this.duty = duty;
this.etc = etc;
this.personnel = personnel;
this.image = image;
}

public void addRecruitFile(RecruitFile recruitFile) {
this.recruitFiles.add(recruitFile);
recruitFile.setRecruit(this);
}

public void updateRecruit(String name, String location, String duty, String etc, int personnel, String image, List<RecruitFile> recruitFiles) {
public void updateRecruit(String name, String location, String duty, String etc, Integer personnel, List<RecruitFile> recruitFiles) {
this.name = name;
this.location = location;
this.duty = duty;
this.etc = etc;
this.personnel = personnel;
this.image = image;
this.recruitFiles = recruitFiles;
}
}

0 comments on commit 21e0fea

Please sign in to comment.