Skip to content

Commit

Permalink
🔗 :: (#590) 모집분야 중복문제
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 authored Mar 14, 2024
2 parents 54c8fe1 + 5611254 commit 5832b91
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import lombok.Getter;
import team.retum.jobis.common.annotation.Aggregate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static team.retum.jobis.domain.code.model.CodeType.JOB;
import static team.retum.jobis.domain.code.model.CodeType.TECH;

@Getter
@Builder(toBuilder = true)
@Aggregate
Expand All @@ -26,4 +33,12 @@ public Code changeAccessible(boolean isPublic) {
.isPublic(isPublic)
.build();
}

public static Map<CodeType, List<Long>> combineCodesWithType(List<Long> jobCode, List<Long> techCode) {
Map<CodeType, List<Long>> codeIds = new HashMap<>();
codeIds.put(JOB, jobCode);
codeIds.put(TECH, techCode);

return codeIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
import lombok.Builder;
import lombok.Getter;
import team.retum.jobis.common.annotation.Aggregate;
import team.retum.jobis.domain.code.model.Code;
import team.retum.jobis.domain.code.model.CodeType;
import team.retum.jobis.domain.recruitment.dto.request.CreateRecruitAreaRequest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static team.retum.jobis.domain.code.model.CodeType.JOB;
import static team.retum.jobis.domain.code.model.CodeType.TECH;

@Getter
@Builder
@Builder(toBuilder = true)
@Aggregate
public class RecruitArea {

Expand All @@ -31,15 +28,21 @@ public class RecruitArea {
private final Map<CodeType, List<Long>> codes;

public static RecruitArea of(CreateRecruitAreaRequest request, Long recruitmentId) {
Map<CodeType, List<Long>> codeIds = new HashMap<>();
codeIds.put(JOB, request.jobCodes());
codeIds.put(TECH, request.techCodes());
return RecruitArea.builder()
.recruitmentId(recruitmentId)
.hiredCount(request.hiring())
.majorTask(request.majorTask())
.preferentialTreatment(request.preferentialTreatment())
.codes(codeIds)
.codes(Code.combineCodesWithType(request.jobCodes(), request.techCodes()))
.build();
}

public RecruitArea update(CreateRecruitAreaRequest request) {
return this.toBuilder()
.hiredCount(request.hiring())
.majorTask(request.majorTask())
.preferentialTreatment(request.preferentialTreatment())
.codes(Code.combineCodesWithType(request.jobCodes(), request.techCodes()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public void execute(CreateRecruitAreaRequest request, Long recruitAreaId) {
.orElseThrow(() -> RecruitAreaNotFoundException.EXCEPTION);
checkRecruitmentPermissionService.checkPermission(recruitArea);

commandRecruitmentPort.saveRecruitmentArea(
RecruitArea.of(request, recruitArea.getRecruitmentId())
);
commandRecruitmentPort.saveRecruitmentArea(recruitArea.update(request));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ public class UpdateRecruitmentWebRequest {
@NotNull
private String submitDocument;

@NotNull
private LocalDate startDate;

@NotNull
private LocalDate endDate;

@Size(max = 350)
Expand Down

0 comments on commit 5832b91

Please sign in to comment.