From 013d152444737500f0910609608cbbf68e91f838 Mon Sep 17 00:00:00 2001 From: test1 Date: Sun, 10 Nov 2024 12:46:27 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=95=84=EC=88=98=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/dto/response/MandatoryResponse.java | 2 +- .../team18_be/apply/service/ApplyService.java | 29 ++++++++++--------- .../controller/UserInformationController.java | 1 - 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/team18/team18_be/apply/dto/response/MandatoryResponse.java b/src/main/java/team18/team18_be/apply/dto/response/MandatoryResponse.java index 145e9e1..b1ae800 100644 --- a/src/main/java/team18/team18_be/apply/dto/response/MandatoryResponse.java +++ b/src/main/java/team18/team18_be/apply/dto/response/MandatoryResponse.java @@ -1,6 +1,6 @@ package team18.team18_be.apply.dto.response; public record MandatoryResponse(boolean resumeExistence, boolean visaExistence, - boolean foreignerIdNumberExistence) { + boolean foreignerIdNumberExistence,boolean signExistence) { } diff --git a/src/main/java/team18/team18_be/apply/service/ApplyService.java b/src/main/java/team18/team18_be/apply/service/ApplyService.java index 4dc2c4d..a1e7a9a 100644 --- a/src/main/java/team18/team18_be/apply/service/ApplyService.java +++ b/src/main/java/team18/team18_be/apply/service/ApplyService.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.NoSuchElementException; +import java.util.Optional; import java.util.stream.Collectors; import org.springframework.stereotype.Service; import team18.team18_be.apply.ApplyStatusEnum.ApplyStatus; @@ -21,8 +22,10 @@ import team18.team18_be.resume.repository.ResumeRepository; import team18.team18_be.userInformation.entity.Company; import team18.team18_be.userInformation.entity.ForeignerInformation; +import team18.team18_be.userInformation.entity.Sign; import team18.team18_be.userInformation.repository.CompanyRepository; import team18.team18_be.userInformation.repository.ForeignerInformationRepository; +import team18.team18_be.userInformation.repository.SignRepository; @Service public class ApplyService { @@ -33,18 +36,20 @@ public class ApplyService { private final ResumeRepository resumeRepository; private final CompanyRepository companyRepository; private final ForeignerInformationRepository foreignerInformationRepository; + private final SignRepository signRepository; public ApplyService(ApplicationFormRepository applicationFormRepository, ApplyRepository applyRepository, RecruitmentRepository recruitmentRepository, ResumeRepository resumeRepository, CompanyRepository companyRepository, - ForeignerInformationRepository foreignerInformationRepository) { + ForeignerInformationRepository foreignerInformationRepository,SignRepository signRepository) { this.applicationFormRepository = applicationFormRepository; this.applyRepository = applyRepository; this.recruitmentRepository = recruitmentRepository; this.resumeRepository = resumeRepository; this.companyRepository = companyRepository; this.foreignerInformationRepository = foreignerInformationRepository; + this.signRepository=signRepository; } public Long createApplicationForm(ApplicationFormRequest applicationFormRequest, @@ -112,14 +117,17 @@ private RecruitmentsOfApplierResponse createMyAppliedRecruitments(Apply apply) { } public MandatoryResponse checkMandatory(User user) { - ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user) - .orElseThrow(() -> new NoSuchElementException("해당 외국인 정보가 없습니다.")); - Resume resume = resumeRepository.findByUser(user); - boolean visaExistence = checkNull(foreignerInformation.getForeignerIdNumber()); - boolean resumeExistence = checkNull(foreignerInformation.getVisaGenerateDate()); - boolean foreignerIdNumberExistence = checkNull(resume); + boolean visaExistence = foreignerInformationRepository.findByUser(user) + .map(info -> info.getVisaGenerateDate() != null) + .orElse(false); + boolean foreignerIdNumberExistence = foreignerInformationRepository.findByUser(user) + .map(info -> info.getForeignerIdNumber() != null) + .orElse(false); + boolean resumeExistence = resumeRepository.findByUser(user) != null; + boolean signExistence = signRepository.findByUser(user).isPresent(); + MandatoryResponse mandatoryResponse = new MandatoryResponse(resumeExistence, visaExistence, - foreignerIdNumberExistence); + foreignerIdNumberExistence,signExistence); return mandatoryResponse; } @@ -128,9 +136,4 @@ private Recruitment findRecruitment(Long recruitmentId) { .orElseThrow(() -> new NoSuchElementException("해당되는 구인글이 없습니다.")); return recruitment; } - - private boolean checkNull(Object object) { - return object != null; - } - } diff --git a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java index 322e8ca..37de4da 100644 --- a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java +++ b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java @@ -58,7 +58,6 @@ public ResponseEntity findSign(@LoginUser User user) { public ResponseEntity createCompany( @RequestPart("companyRequest") String companyRequestJson, @RequestPart MultipartFile logoImage, @LoginUser User user) { - System.out.println(companyRequestJson); ObjectMapper objectMapper = new ObjectMapper(); CompanyRequest companyRequest = null; try {