From 29093482a47324122dd90ec43c5b972975f62e21 Mon Sep 17 00:00:00 2001 From: test1 Date: Mon, 4 Nov 2024 19:11:29 +0900 Subject: [PATCH 01/56] =?UTF-8?q?feat=20:=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/controller/ApplyController.java | 12 +++++++++++- .../apply/dto/request/ApplicationFormRequest.java | 2 +- .../dto/response/ApplicationFormResponse.java | 11 +++++++++++ .../apply/dto/response/ApplyResponse.java | 10 ---------- .../team18_be/apply/service/ApplyService.java | 14 +++++++++++++- 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 src/main/java/team18/team18_be/apply/dto/response/ApplicationFormResponse.java delete mode 100644 src/main/java/team18/team18_be/apply/dto/response/ApplyResponse.java diff --git a/src/main/java/team18/team18_be/apply/controller/ApplyController.java b/src/main/java/team18/team18_be/apply/controller/ApplyController.java index 24cd6217..a97135e6 100644 --- a/src/main/java/team18/team18_be/apply/controller/ApplyController.java +++ b/src/main/java/team18/team18_be/apply/controller/ApplyController.java @@ -10,14 +10,17 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import team18.team18_be.apply.dto.request.ApplicationFormRequest; +import team18.team18_be.apply.dto.response.ApplicationFormResponse; import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse; import team18.team18_be.apply.dto.response.MandatoryResponse; import team18.team18_be.apply.dto.response.RecruitmentsOfApplierResponse; import team18.team18_be.apply.service.ApplyService; import team18.team18_be.auth.entity.User; import team18.team18_be.config.resolver.LoginUser; +import team18.team18_be.apply.dto.request.ApplicationFormRequest; + @RestController @RequestMapping("/api/application") @@ -42,6 +45,13 @@ public ResponseEntity createApplicationForm( return ResponseEntity.created(location).build(); } + @Operation(summary = "특정 지원서 조회") + @GetMapping("/form/{applyId}") + public ResponseEntity findApplication(@PathVariable Long applyId, @LoginUser User user){ + ApplicationFormResponse applicationFormResponse = applyService.findApplication(applyId); + return ResponseEntity.ok(applicationFormResponse); + } + @Operation(summary = "구인글에 지원한 지원자 확인", description = "고용주가 자신이 올린 구인글에 누가 지원했는지 보여준다.") @GetMapping("/{recruitmentId}") public ResponseEntity> searchApplicant( diff --git a/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java b/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java index f74c8224..7910fd8d 100644 --- a/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java +++ b/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java @@ -1,5 +1,5 @@ package team18.team18_be.apply.dto.request; -public record ApplicationFormRequest(String name, String address, String applyMotivation) { +public record ApplicationFormRequest(String name, String address, String motivation) { } diff --git a/src/main/java/team18/team18_be/apply/dto/response/ApplicationFormResponse.java b/src/main/java/team18/team18_be/apply/dto/response/ApplicationFormResponse.java new file mode 100644 index 00000000..478d07f9 --- /dev/null +++ b/src/main/java/team18/team18_be/apply/dto/response/ApplicationFormResponse.java @@ -0,0 +1,11 @@ +package team18.team18_be.apply.dto.response; + +public record ApplicationFormResponse( + String name, + String address, + String phoneNumber, + + String motivation +) { + +} diff --git a/src/main/java/team18/team18_be/apply/dto/response/ApplyResponse.java b/src/main/java/team18/team18_be/apply/dto/response/ApplyResponse.java deleted file mode 100644 index 0c5d5b7a..00000000 --- a/src/main/java/team18/team18_be/apply/dto/response/ApplyResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package team18.team18_be.apply.dto.response; - -public record ApplyResponse( - Long userId, - String name, - String motivation, - Long resumeId -) { - -} 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 2751a3a6..da484064 100644 --- a/src/main/java/team18/team18_be/apply/service/ApplyService.java +++ b/src/main/java/team18/team18_be/apply/service/ApplyService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; import team18.team18_be.apply.ApplyStatusEnum.ApplyStatus; import team18.team18_be.apply.dto.request.ApplicationFormRequest; +import team18.team18_be.apply.dto.response.ApplicationFormResponse; import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse; import team18.team18_be.apply.dto.response.MandatoryResponse; import team18.team18_be.apply.dto.response.RecruitmentsOfApplierResponse; @@ -54,11 +55,21 @@ public Long createApplicationForm(ApplicationFormRequest applicationFormRequest, Apply savedApply = applyRepository.save(apply); ApplicationForm applicationForm = new ApplicationForm(applicationFormRequest.name(), applicationFormRequest.address(), applicationFormRequest.address(), - applicationFormRequest.applyMotivation(), savedApply); + applicationFormRequest.motivation(), savedApply); applicationFormRepository.save(applicationForm); return savedApply.getId(); } + public ApplicationFormResponse findApplication(Long applyId) { + Apply apply = applyRepository.findById(applyId) + .orElseThrow(() -> new NoSuchElementException("해당 지원서가 없습니다")); + ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); + ApplicationFormResponse applicationFormResponse = new ApplicationFormResponse( + applicationForm.getName(), applicationForm.getAddress(), applicationForm.getAddress(), + applicationForm.getMotivation()); + return applicationFormResponse; + } + public List searchApplicant(Long recruitmentId, User user) { Recruitment recruitment = findRecruitment(recruitmentId); @@ -115,4 +126,5 @@ private Recruitment findRecruitment(Long recruitmentId) { private boolean checkNull(Object object) { return object != null; } + } From 66dbed66449c6c1050adca53febc51e8475dbc3b Mon Sep 17 00:00:00 2001 From: test1 Date: Mon, 4 Nov 2024 19:24:42 +0900 Subject: [PATCH 02/56] =?UTF-8?q?feat=20:=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/controller/ApplyController.java | 6 +++--- .../controller/RecruitmentController.java | 1 - .../RecruitmentSummationResponse.java | 1 + .../recruitment/entity/Recruitment.java | 1 - .../recruitment/mapper/RecruitmentMapper.java | 13 +++++------- .../repository/RecruitmentRepository.java | 2 ++ .../service/RecruitmentService.java | 20 +++++++++++-------- .../resume/controller/ResumeController.java | 2 +- .../team18_be/resume/mapper/ResumeMapper.java | 6 ++++-- .../resume/service/ResumeService.java | 4 +--- 10 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/main/java/team18/team18_be/apply/controller/ApplyController.java b/src/main/java/team18/team18_be/apply/controller/ApplyController.java index a97135e6..4b80bae0 100644 --- a/src/main/java/team18/team18_be/apply/controller/ApplyController.java +++ b/src/main/java/team18/team18_be/apply/controller/ApplyController.java @@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import team18.team18_be.apply.dto.request.ApplicationFormRequest; import team18.team18_be.apply.dto.response.ApplicationFormResponse; import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse; import team18.team18_be.apply.dto.response.MandatoryResponse; @@ -19,7 +19,6 @@ import team18.team18_be.apply.service.ApplyService; import team18.team18_be.auth.entity.User; import team18.team18_be.config.resolver.LoginUser; -import team18.team18_be.apply.dto.request.ApplicationFormRequest; @RestController @@ -47,7 +46,8 @@ public ResponseEntity createApplicationForm( @Operation(summary = "특정 지원서 조회") @GetMapping("/form/{applyId}") - public ResponseEntity findApplication(@PathVariable Long applyId, @LoginUser User user){ + public ResponseEntity findApplication(@PathVariable Long applyId, + @LoginUser User user) { ApplicationFormResponse applicationFormResponse = applyService.findApplication(applyId); return ResponseEntity.ok(applicationFormResponse); } diff --git a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java index c2fbcb1e..3f11bde8 100644 --- a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java +++ b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java @@ -4,7 +4,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import java.util.List; -import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java index 05c36ea9..d7d23873 100644 --- a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java @@ -9,4 +9,5 @@ public record RecruitmentSummationResponse( String salary, String area ) { + } diff --git a/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java b/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java index 45384bb6..0239c0a6 100644 --- a/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java +++ b/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java @@ -8,7 +8,6 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; import java.util.Date; -import lombok.Builder; import lombok.Getter; import lombok.Setter; import team18.team18_be.userInformation.entity.Company; diff --git a/src/main/java/team18/team18_be/recruitment/mapper/RecruitmentMapper.java b/src/main/java/team18/team18_be/recruitment/mapper/RecruitmentMapper.java index a6a8c733..3b8d3051 100644 --- a/src/main/java/team18/team18_be/recruitment/mapper/RecruitmentMapper.java +++ b/src/main/java/team18/team18_be/recruitment/mapper/RecruitmentMapper.java @@ -1,28 +1,25 @@ package team18.team18_be.recruitment.mapper; import java.util.Date; -import java.util.NoSuchElementException; -import org.mapstruct.AfterMapping; -import org.mapstruct.Context; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; import org.mapstruct.factory.Mappers; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; import team18.team18_be.recruitment.dto.response.RecruitmentResponse; import team18.team18_be.recruitment.entity.Recruitment; import team18.team18_be.recruitment.entity.RecruitmentContent; import team18.team18_be.userInformation.entity.Company; -import team18.team18_be.userInformation.repository.CompanyRepository; @Mapper(componentModel = "spring") public interface RecruitmentMapper { + RecruitmentMapper INSTANCE = Mappers.getMapper(RecruitmentMapper.class); Recruitment toRecruitment(String koreanTitle, String vietnameseTitle, - RecruitmentRequest recruitmentRequest, RecruitmentContent recruitmentContent, Company company,Boolean hiring, + RecruitmentRequest recruitmentRequest, RecruitmentContent recruitmentContent, Company company, + Boolean hiring, Date uploadDate); - RecruitmentResponse toRecruitmentResponse(Recruitment recruitment,RecruitmentContent recruitmentContent); + RecruitmentResponse toRecruitmentResponse(Recruitment recruitment, + RecruitmentContent recruitmentContent); } diff --git a/src/main/java/team18/team18_be/recruitment/repository/RecruitmentRepository.java b/src/main/java/team18/team18_be/recruitment/repository/RecruitmentRepository.java index 019ffa52..4a4fa1ca 100644 --- a/src/main/java/team18/team18_be/recruitment/repository/RecruitmentRepository.java +++ b/src/main/java/team18/team18_be/recruitment/repository/RecruitmentRepository.java @@ -11,7 +11,9 @@ public interface RecruitmentRepository extends JpaRepository { List findByCompany(Optional company); + Page findAllByHiringTrueOrderBySalaryDesc(Pageable pageable); + Page findAllByHiringTrueOrderByUploadDateDesc(Pageable pageable); Page findAllByHiringTrue(Pageable pageable); diff --git a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java index 65437dc7..7ae0e7e7 100644 --- a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java +++ b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java @@ -51,9 +51,10 @@ public void saveRecruitment(RecruitmentRequest recruitmentRequest) new RecruitmentContent(koreanDetailedDescription, vietnameseDetailedDescription)); recruitmentRepository.save( recruitmentMapper.toRecruitment(koreanTitle, vietnameseTitle, recruitmentRequest, - recruitmentContent,companyRepository.findById(recruitmentRequest.companyId()) - .orElseThrow(() -> new NoSuchElementException("해당하는 회사가 존재하지 않습니다.")),true,new Date() - )); + recruitmentContent, companyRepository.findById(recruitmentRequest.companyId()) + .orElseThrow(() -> new NoSuchElementException("해당하는 회사가 존재하지 않습니다.")), true, + new Date() + )); } @@ -73,7 +74,8 @@ public List getAllRecruitment(Pageable pageable) { } public List getAllRecruitmentAndSortBySalary(Pageable pageable) { - Page recruitments = recruitmentRepository.findAllByHiringTrueOrderBySalaryDesc(pageable); + Page recruitments = recruitmentRepository.findAllByHiringTrueOrderBySalaryDesc( + pageable); return recruitments.stream() .map(recruitment -> new RecruitmentSummationResponse( recruitment.getRecruitmentId(), @@ -88,7 +90,8 @@ public List getAllRecruitmentAndSortBySalary(Pagea } public List getAllRecruitmentAndSortByDate(Pageable pageable) { - Page recruitments = recruitmentRepository.findAllByHiringTrueOrderByUploadDateDesc(pageable); + Page recruitments = recruitmentRepository.findAllByHiringTrueOrderByUploadDateDesc( + pageable); return recruitments.stream() .map(recruitment -> new RecruitmentSummationResponse( recruitment.getRecruitmentId(), @@ -105,7 +108,8 @@ public List getAllRecruitmentAndSortByDate(Pageabl public RecruitmentResponse getRecruitmentResponseByRecruitmentId(Long userId) { Recruitment recruitment = recruitmentRepository.findById(userId) .orElseThrow(() -> new NoSuchElementException("해당하는 이력서가 존재하지 않습니다.")); - return recruitmentMapper.toRecruitmentResponse(recruitment,recruitment.getRecruitmentContent()); + return recruitmentMapper.toRecruitmentResponse(recruitment, + recruitment.getRecruitmentContent()); } public List getRecruitmentResponseByCompanyId(Long companyId) { @@ -125,8 +129,8 @@ public List getRecruitmentResponseByCompanyId(Lon .collect(Collectors.toList()); } - public void setRecruitmentHiringFalse(Long recruitmentId){ - Recruitment recruitment = recruitmentRepository.findById(recruitmentId) + public void setRecruitmentHiringFalse(Long recruitmentId) { + Recruitment recruitment = recruitmentRepository.findById(recruitmentId) .orElseThrow(() -> new NoSuchElementException("해당하는 회사가 존재하지 않습니다.")); recruitment.setHiring(false); recruitmentRepository.save(recruitment); diff --git a/src/main/java/team18/team18_be/resume/controller/ResumeController.java b/src/main/java/team18/team18_be/resume/controller/ResumeController.java index d4c36cdb..8456297a 100644 --- a/src/main/java/team18/team18_be/resume/controller/ResumeController.java +++ b/src/main/java/team18/team18_be/resume/controller/ResumeController.java @@ -54,7 +54,7 @@ public ResponseEntity getResumeById( @LoginUser User user ) { - return ResponseEntity.ok().body(resumeService.findResumeById(resumeId,applyId)); + return ResponseEntity.ok().body(resumeService.findResumeById(resumeId, applyId)); } } diff --git a/src/main/java/team18/team18_be/resume/mapper/ResumeMapper.java b/src/main/java/team18/team18_be/resume/mapper/ResumeMapper.java index f68dbdef..c1752fc4 100644 --- a/src/main/java/team18/team18_be/resume/mapper/ResumeMapper.java +++ b/src/main/java/team18/team18_be/resume/mapper/ResumeMapper.java @@ -1,7 +1,6 @@ package team18.team18_be.resume.mapper; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import team18.team18_be.auth.entity.User; import team18.team18_be.resume.dto.request.ResumeRequest; @@ -11,9 +10,12 @@ @Mapper(componentModel = "spring") public interface ResumeMapper { + ResumeMapper INSTANCE = Mappers.getMapper(ResumeMapper.class); + ResumeResponse toResumeResponse(Resume resume); - ResumeAndApplyResponse toResumeAndApplyResponse(Resume resume,String motivation); + + ResumeAndApplyResponse toResumeAndApplyResponse(Resume resume, String motivation); Resume toResume(ResumeRequest resumeRequest, User user); } diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index af851ebd..4dcfdbe8 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -1,14 +1,12 @@ package team18.team18_be.resume.service; import java.util.NoSuchElementException; -import java.util.Objects; import org.springframework.stereotype.Service; import team18.team18_be.apply.entity.ApplicationForm; import team18.team18_be.apply.entity.Apply; import team18.team18_be.apply.repository.ApplicationFormRepository; import team18.team18_be.apply.repository.ApplyRepository; import team18.team18_be.auth.entity.User; -import team18.team18_be.auth.repository.AuthRepository; import team18.team18_be.resume.dto.request.ResumeRequest; import team18.team18_be.resume.dto.response.ResumeAndApplyResponse; import team18.team18_be.resume.dto.response.ResumeResponse; @@ -47,7 +45,7 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { Apply apply = applyRepository.findById(applyId) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); - return resumeMapper.toResumeAndApplyResponse(resume,applicationForm.getMotivation()); + return resumeMapper.toResumeAndApplyResponse(resume, applicationForm.getMotivation()); } } From d44cf7e9f9fe675a9757fbe50a7708fe7eab0aab Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:29:16 +0900 Subject: [PATCH 03/56] =?UTF-8?q?Update=20deploy.yml=20:=20=EC=9D=BC?= =?UTF-8?q?=EB=B6=80=EB=A7=8C=20CI/CD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2a7377c3..47ec010b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -60,19 +60,5 @@ jobs: - name: Deploy to GCP run: | - # 필요한 패키지 설치 - sudo apt-get update - sudo apt-get install -y google-cloud-cli - - # GCP 인증 - echo "${{ secrets.HIREHIGHER_GCP_KEY }}" | base64 --decode > ${HOME}/gcp-key.json - gcloud auth activate-service-account --key-file=${HOME}/gcp-key.json - - # GCP 프로젝트 설정 - gcloud config set project fleet-point-420405 - - # GCP VM 인스턴스에 JAR 파일 전송 - gcloud compute scp ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher-api:/home/hirehigher/repository --zone asia-northeast3-a - - # GCP VM에서 배포 쉘 스크립트 실행 - gcloud compute ssh hirehigher-api --zone asia-northeast3-a --command 'bash /home/hirehigher/repository/deploy.sh' + # scp로 VM에 jar 파일 전송 + sudo scp ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher-api:/home/hirehigher/repository --zone asia-northeast3-a From 542fc0762e3d755099a72595b0c04c16a7f0c279 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:38:31 +0900 Subject: [PATCH 04/56] Update deploy.yml --- .github/workflows/deploy.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 47ec010b..2716aaab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,7 +47,7 @@ jobs: with: name: team18-be-jar path: build/libs/team18-be-0.0.1-SNAPSHOT.jar - + deploy: runs-on: ubuntu-latest needs: build @@ -58,7 +58,12 @@ jobs: with: name: team18-be-jar + - name: Configure SSH private key + run: | + touch ./key-hirehigher + echo "${{ secrets.HIREHIGHER_GCP_SSH_KEY }}" > ./key-hirehigher + - name: Deploy to GCP run: | # scp로 VM에 jar 파일 전송 - sudo scp ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher-api:/home/hirehigher/repository --zone asia-northeast3-a + sudo scp -i ./key-hirehigher ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository From 3c7cf834ae0d42fed1ac1fbac0fc5bc9f4e14bcc Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:45:11 +0900 Subject: [PATCH 05/56] Update deploy.yml --- .github/workflows/deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2716aaab..07f97dda 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,6 +62,10 @@ jobs: run: | touch ./key-hirehigher echo "${{ secrets.HIREHIGHER_GCP_SSH_KEY }}" > ./key-hirehigher + chmod 600 ./key-hirehigher + + - name: Add GCP VM to known_hosts + run: ssh-keyscan -H "${{ secrets.GCP_VM_IP }}" >> ~/.ssh/known_hosts - name: Deploy to GCP run: | From df81a6440e3247b6f7010d4bfd80a9a0fb7b7fba Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:48:14 +0900 Subject: [PATCH 06/56] =?UTF-8?q?Update=20deploy.yml=20:=20.ssh=20?= =?UTF-8?q?=EB=94=94=EB=A0=89=ED=86=A0=EB=A6=AC=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 07f97dda..c3b6db06 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -65,7 +65,9 @@ jobs: chmod 600 ./key-hirehigher - name: Add GCP VM to known_hosts - run: ssh-keyscan -H "${{ secrets.GCP_VM_IP }}" >> ~/.ssh/known_hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan -H "${{ secrets.GCP_VM_IP }}" >> ~/.ssh/known_hosts - name: Deploy to GCP run: | From 0434333b85b061274297694f43f8215e49f813a1 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:56:48 +0900 Subject: [PATCH 07/56] =?UTF-8?q?Update=20deploy.yml=20:=20=ED=98=B8?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=ED=82=A4=20=EA=B2=80=EC=A6=9D=20=EB=B9=84?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c3b6db06..f982e372 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -72,4 +72,4 @@ jobs: - name: Deploy to GCP run: | # scp로 VM에 jar 파일 전송 - sudo scp -i ./key-hirehigher ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository + scp -o StrictHostKeyChecking=no -i ./key-hirehigher ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository From 6ff9b999d2307a342172c84ab18f082bd2d4a2ac Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:01:26 +0900 Subject: [PATCH 08/56] =?UTF-8?q?Update=20deploy.yml=20:=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f982e372..f04fd0ac 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -72,4 +72,4 @@ jobs: - name: Deploy to GCP run: | # scp로 VM에 jar 파일 전송 - scp -o StrictHostKeyChecking=no -i ./key-hirehigher ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository + scp -o StrictHostKeyChecking=no -i ./key-hirehigher ./team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository From d6b183f69e013f407fd3f2db4946271a5ab2de6d Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:30:03 +0900 Subject: [PATCH 09/56] =?UTF-8?q?Update=20deploy.yml=20:=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=8D=BC=ED=8B=B0=20active=EB=A5=BC=20prod=EB=A1=9C?= =?UTF-8?q?=20=EB=8D=AE=EC=96=B4=EC=94=8C=EC=9A=B0=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f04fd0ac..b8a020aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,9 @@ jobs: java-version: '21' distribution: 'adopt' + - name : Override APPLICATION PROPERTIES + run : echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties + - name: Configure Production Properties run: | touch ./src/main/resources/application-prod.properties From aac5a81f08f6950907e1c996d1da01076e03eee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Tue, 5 Nov 2024 17:34:24 +0900 Subject: [PATCH 10/56] =?UTF-8?q?chore:=20test=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=8D=BC=ED=8B=B0=20active=20(=EB=B0=B0=ED=8F=AC=20=EC=8B=9C?= =?UTF-8?q?=20CI/CD=20=EC=83=81=20prod=EB=A1=9C=20=EB=8D=AE=EC=96=B4?= =?UTF-8?q?=EC=94=8C=EC=9B=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a4e651ec..ad87a7be 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ -spring.profiles.active=prod +spring.profiles.active=test spring.profiles.include=gcs From 93e056d25b277a35a282859eb265ab66ec81cd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Wed, 6 Nov 2024 16:04:48 +0900 Subject: [PATCH 11/56] =?UTF-8?q?fix:=20Configuration=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=88=84=EB=9D=BD=EB=90=9C=20?= =?UTF-8?q?=EA=B2=83=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/config/CorsConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index c7bacb4d..7e63cd86 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -1,9 +1,11 @@ package team18.team18_be.config; +import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +@Configuration public class CorsConfig implements WebMvcConfigurer { @Override From 0f74546c73ae57e328d2d899d4a7e6fd217455eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Wed, 6 Nov 2024 16:07:06 +0900 Subject: [PATCH 12/56] =?UTF-8?q?feat:=20CORS=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=EC=9D=98=20Authorization=20=ED=95=84=EB=93=9C=EB=A7=8C=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/config/CorsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index 7e63cd86..b2199761 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -13,7 +13,7 @@ public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins("http://localhost:3000") .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") - .allowedHeaders("*") + .allowedHeaders("Authorization") .exposedHeaders(HttpHeaders.LOCATION) .allowCredentials(true) .maxAge(1800); From 0f8fe7149fcb916fb365c2d0c314ccef0e71b36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Wed, 6 Nov 2024 21:37:19 +0900 Subject: [PATCH 13/56] =?UTF-8?q?feat:=20=EC=9B=90=ED=99=9C=ED=95=9C=20?= =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=20=EB=B0=B0=ED=8F=AC=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=B4=20=EC=9E=84=EC=8B=9C=EB=A1=9C=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=20=EA=B8=B0=EA=B0=84=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/auth/service/AuthService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/team18/team18_be/auth/service/AuthService.java b/src/main/java/team18/team18_be/auth/service/AuthService.java index 104f4a78..2731b521 100644 --- a/src/main/java/team18/team18_be/auth/service/AuthService.java +++ b/src/main/java/team18/team18_be/auth/service/AuthService.java @@ -137,7 +137,6 @@ private String getAccessToken(User user) { SecretKey key = Keys.hmacShaKeyFor(keyBytes); return Jwts.builder() .claim(USER_ID, user.getId()) - .expiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60L)) .signWith(key) .compact(); } From 94947cd819225dd96deb76e424358c5ec0372c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Thu, 7 Nov 2024 22:30:07 +0900 Subject: [PATCH 14/56] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=A0=ED=8A=B8?= =?UTF-8?q?=EC=97=94=EB=93=9C=20=EC=98=A4=EB=A6=AC=EC=A7=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/auth/service/AuthService.java | 1 - src/main/java/team18/team18_be/config/CorsConfig.java | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/team18/team18_be/auth/service/AuthService.java b/src/main/java/team18/team18_be/auth/service/AuthService.java index 2731b521..d69773c6 100644 --- a/src/main/java/team18/team18_be/auth/service/AuthService.java +++ b/src/main/java/team18/team18_be/auth/service/AuthService.java @@ -7,7 +7,6 @@ import io.jsonwebtoken.security.Keys; import java.net.URI; import java.nio.charset.StandardCharsets; -import java.util.Date; import java.util.NoSuchElementException; import javax.crypto.SecretKey; import org.apache.logging.log4j.util.InternalException; diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index b2199761..096b095f 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -1,5 +1,6 @@ package team18.team18_be.config; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.web.servlet.config.annotation.CorsRegistry; @@ -8,10 +9,13 @@ @Configuration public class CorsConfig implements WebMvcConfigurer { + @Value("${front.origin}") + private String FRONT_ORIGIN; + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") - .allowedOrigins("http://localhost:3000") + .allowedOrigins(FRONT_ORIGIN) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") .allowedHeaders("Authorization") .exposedHeaders(HttpHeaders.LOCATION) From b960b57bb8f59aadcb33ce52c35739ac86ceb153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Fri, 8 Nov 2024 12:17:44 +0900 Subject: [PATCH 15/56] =?UTF-8?q?chore:=20=EC=9D=B8=EC=A6=9D=20=ED=97=A4?= =?UTF-8?q?=EB=8D=94=EA=B0=80=20=EC=97=86=EB=8A=94=20API=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EC=97=90=EB=8F=84=20CORS=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/config/CorsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index 096b095f..99bbcb01 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -17,7 +17,7 @@ public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins(FRONT_ORIGIN) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") - .allowedHeaders("Authorization") + .allowedHeaders("Authorization", "Content-Type") .exposedHeaders(HttpHeaders.LOCATION) .allowCredentials(true) .maxAge(1800); From 62b57972011d1a7dc61c17f5fd17ac2eb9e4abde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Fri, 8 Nov 2024 12:55:01 +0900 Subject: [PATCH 16/56] =?UTF-8?q?chore:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EC=96=B8=ED=8A=B8=EC=97=90=EC=84=9C=20Authorization=20?= =?UTF-8?q?=ED=97=A4=EB=8D=94=EC=97=90=20=EC=A0=91=EA=B7=BC=EC=9D=84=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/config/CorsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index 99bbcb01..5d8bb854 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -18,7 +18,7 @@ public void addCorsMappings(CorsRegistry registry) { .allowedOrigins(FRONT_ORIGIN) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") .allowedHeaders("Authorization", "Content-Type") - .exposedHeaders(HttpHeaders.LOCATION) + .exposedHeaders(HttpHeaders.LOCATION, HttpHeaders.AUTHORIZATION) .allowCredentials(true) .maxAge(1800); } From 9b2566132ae1d12666381ca06d73bc38150dbc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Fri, 8 Nov 2024 13:22:08 +0900 Subject: [PATCH 17/56] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=EC=97=90=20name=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/auth/controller/AuthController.java | 2 +- .../auth/dto/response/LoginResponse.java | 3 ++- .../auth/dto/response/UserTypeResponse.java | 3 ++- .../team18_be/auth/service/AuthService.java | 2 +- .../team18_be/auth/service/AuthServiceTest.java | 15 ++++++++------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/team18/team18_be/auth/controller/AuthController.java b/src/main/java/team18/team18_be/auth/controller/AuthController.java index cd17ee36..e21e4f25 100644 --- a/src/main/java/team18/team18_be/auth/controller/AuthController.java +++ b/src/main/java/team18/team18_be/auth/controller/AuthController.java @@ -57,7 +57,7 @@ public ResponseEntity login(@RequestBody CodeRequest codeReque headers.setBearerAuth(loginResponse.accessToken()); UserTypeResponse userTypeResponse = new UserTypeResponse(loginResponse.type(), - loginResponse.profileImage()); + loginResponse.profileImage(), loginResponse.name()); return new ResponseEntity<>(userTypeResponse, headers, HttpStatus.OK); } diff --git a/src/main/java/team18/team18_be/auth/dto/response/LoginResponse.java b/src/main/java/team18/team18_be/auth/dto/response/LoginResponse.java index 423153ca..65c78fbe 100644 --- a/src/main/java/team18/team18_be/auth/dto/response/LoginResponse.java +++ b/src/main/java/team18/team18_be/auth/dto/response/LoginResponse.java @@ -3,7 +3,8 @@ public record LoginResponse( String accessToken, String type, - String profileImage + String profileImage, + String name ) { } diff --git a/src/main/java/team18/team18_be/auth/dto/response/UserTypeResponse.java b/src/main/java/team18/team18_be/auth/dto/response/UserTypeResponse.java index 17a7ad88..2b4bd542 100644 --- a/src/main/java/team18/team18_be/auth/dto/response/UserTypeResponse.java +++ b/src/main/java/team18/team18_be/auth/dto/response/UserTypeResponse.java @@ -2,7 +2,8 @@ public record UserTypeResponse( String type, - String profileImage + String profileImage, + String name ) { } diff --git a/src/main/java/team18/team18_be/auth/service/AuthService.java b/src/main/java/team18/team18_be/auth/service/AuthService.java index d69773c6..8c272a31 100644 --- a/src/main/java/team18/team18_be/auth/service/AuthService.java +++ b/src/main/java/team18/team18_be/auth/service/AuthService.java @@ -128,7 +128,7 @@ private LoginResponse getLoginResponse(String userEmail, () -> new NoSuchElementException(ErrorMessage.NOT_FOUND_USER.getErrorMessage())); String userType = user.getType(); String accessToken = getAccessToken(user); - return new LoginResponse(accessToken, userType, profileImage); + return new LoginResponse(accessToken, userType, profileImage, user.getName()); } private String getAccessToken(User user) { diff --git a/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java b/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java index 7a39faf5..572eee6b 100644 --- a/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java +++ b/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java @@ -44,8 +44,6 @@ @SuppressWarnings("NonAsciiCharacters") class AuthServiceTest { - static final String NAME = "name"; - static final String EMAIL = "email"; static final String PICTURE = "profile_image"; static final String USER_INFO_URI = "/userinfo/v2/me"; static final String APPLICATION_TEST_PROPERTIES = "application-test.properties"; @@ -75,8 +73,10 @@ class AuthServiceTest { static Stream 파라미터_구글_토큰_기반_회원가입_및_로그인() { return Stream.of( - Arguments.of("신규 유저일 때", new User(NAME, EMAIL, UserType.FIRST.getUserType()), true), - Arguments.of("기존 유저일 때", new User(NAME, EMAIL, UserType.EMPLOYER.getUserType()), false) + Arguments.of("신규 유저일 때", new User(USER_NAME, USER_EMAIL, UserType.FIRST.getUserType()), + true), + Arguments.of("기존 유저일 때", new User(USER_NAME, USER_EMAIL, UserType.EMPLOYER.getUserType()), + false) ); } @@ -162,11 +162,11 @@ class AuthServiceTest { void 구글_토큰_기반_회원가입_및_로그인(String testName, User user, boolean isNewUser) throws JsonProcessingException { // given - OAuthUserInfo oAuthUserInfo = new OAuthUserInfo(NAME, EMAIL, PICTURE); + OAuthUserInfo oAuthUserInfo = new OAuthUserInfo(USER_NAME, USER_EMAIL, PICTURE); mockWebServer.enqueue( new MockResponse().setBody(objectMapper.writeValueAsString(oAuthUserInfo))); - given(authRepository.existsByEmail(EMAIL)).willReturn(!isNewUser); - given(authRepository.findByEmail(EMAIL)).willReturn(Optional.of(user)); + given(authRepository.existsByEmail(USER_EMAIL)).willReturn(!isNewUser); + given(authRepository.findByEmail(USER_EMAIL)).willReturn(Optional.of(user)); String mockUri = mockWebServer.url(USER_INFO_URI).toString(); OAuthJwtResponse oAuthJwtResponse = new OAuthJwtResponse(OAUTH_ACCESS_TOKEN); @@ -181,6 +181,7 @@ class AuthServiceTest { SoftAssertions.assertSoftly(softly -> { assertThat(loginResponse.type()).isEqualTo(user.getType()); assertThat(loginResponse.profileImage()).isEqualTo(PICTURE); + assertThat(loginResponse.name()).isEqualTo(USER_NAME); assertThat(loginResponse.accessToken()).isNotNull(); }); } From 2c1579a6f3567dae3559ad2b1188ca4a8cc9698d Mon Sep 17 00:00:00 2001 From: EunKyung Lee <2dmsrud2002@naver.com> Date: Fri, 8 Nov 2024 14:37:06 +0900 Subject: [PATCH 18/56] =?UTF-8?q?Refactor:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit url, urlV에 대한 변수명이 명확하지 않아서 주석을 통해 베트남어인지 한국어인지 나타냄을 설명함 --- .../team18_be/contract/dto/response/ContractFileResponse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/team18/team18_be/contract/dto/response/ContractFileResponse.java b/src/main/java/team18/team18_be/contract/dto/response/ContractFileResponse.java index ec4fe894..319f5053 100644 --- a/src/main/java/team18/team18_be/contract/dto/response/ContractFileResponse.java +++ b/src/main/java/team18/team18_be/contract/dto/response/ContractFileResponse.java @@ -1,7 +1,9 @@ package team18.team18_be.contract.dto.response; public record ContractFileResponse( + // 한국어 파일 url String url, + // 베트남어 파일 url String urlV ) { From a2df9774fdb4f6eebe9b7d2ec4a6eb7a11f5acce Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:00:26 +0900 Subject: [PATCH 19/56] =?UTF-8?q?feat=20:=20Optional=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/repository/ApplicationFormRepository.java | 3 ++- .../team18/team18_be/apply/repository/ApplyRepository.java | 5 +++-- .../userInformation/repository/CompanyRepository.java | 3 ++- .../repository/ForeignerInformationRepository.java | 3 ++- .../team18_be/userInformation/repository/SignRepository.java | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/team18/team18_be/apply/repository/ApplicationFormRepository.java b/src/main/java/team18/team18_be/apply/repository/ApplicationFormRepository.java index 1fd2c2fc..39e12cdd 100644 --- a/src/main/java/team18/team18_be/apply/repository/ApplicationFormRepository.java +++ b/src/main/java/team18/team18_be/apply/repository/ApplicationFormRepository.java @@ -1,11 +1,12 @@ package team18.team18_be.apply.repository; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.apply.entity.ApplicationForm; import team18.team18_be.apply.entity.Apply; public interface ApplicationFormRepository extends JpaRepository { - ApplicationForm findByApply(Apply apply); + Optional findByApply(Apply apply); } diff --git a/src/main/java/team18/team18_be/apply/repository/ApplyRepository.java b/src/main/java/team18/team18_be/apply/repository/ApplyRepository.java index 4f5aa873..844f9e03 100644 --- a/src/main/java/team18/team18_be/apply/repository/ApplyRepository.java +++ b/src/main/java/team18/team18_be/apply/repository/ApplyRepository.java @@ -1,6 +1,7 @@ package team18.team18_be.apply.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.apply.entity.Apply; import team18.team18_be.auth.entity.User; @@ -8,7 +9,7 @@ public interface ApplyRepository extends JpaRepository { - List findByRecruitment(Recruitment recruitment); + Optional> findByRecruitment(Recruitment recruitment); - List findByUser(User user); + Optional> findByUser(User user); } diff --git a/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java b/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java index 77a253d8..4dd58899 100644 --- a/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java +++ b/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java @@ -1,10 +1,11 @@ package team18.team18_be.userInformation.repository; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.auth.entity.User; import team18.team18_be.userInformation.entity.Company; public interface CompanyRepository extends JpaRepository { - Company findByUser(User user); + Optional findByUser(User user); } diff --git a/src/main/java/team18/team18_be/userInformation/repository/ForeignerInformationRepository.java b/src/main/java/team18/team18_be/userInformation/repository/ForeignerInformationRepository.java index 2b3e1b61..b4d8eb58 100644 --- a/src/main/java/team18/team18_be/userInformation/repository/ForeignerInformationRepository.java +++ b/src/main/java/team18/team18_be/userInformation/repository/ForeignerInformationRepository.java @@ -1,11 +1,12 @@ package team18.team18_be.userInformation.repository; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.auth.entity.User; import team18.team18_be.userInformation.entity.ForeignerInformation; public interface ForeignerInformationRepository extends JpaRepository { - ForeignerInformation findByUser(User user); + Optional findByUser(User user); } diff --git a/src/main/java/team18/team18_be/userInformation/repository/SignRepository.java b/src/main/java/team18/team18_be/userInformation/repository/SignRepository.java index 0a0d78b1..eea6984e 100644 --- a/src/main/java/team18/team18_be/userInformation/repository/SignRepository.java +++ b/src/main/java/team18/team18_be/userInformation/repository/SignRepository.java @@ -1,10 +1,11 @@ package team18.team18_be.userInformation.repository; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.auth.entity.User; import team18.team18_be.userInformation.entity.Sign; public interface SignRepository extends JpaRepository { - Sign findByUser(User user); + Optional findByUser(User user); } From 904ee9929fec1645f1eaaf753b25014dd2f12df8 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:01:49 +0900 Subject: [PATCH 20/56] =?UTF-8?q?fix=20:=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/apply/dto/request/ApplicationFormRequest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java b/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java index 7910fd8d..1db78596 100644 --- a/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java +++ b/src/main/java/team18/team18_be/apply/dto/request/ApplicationFormRequest.java @@ -1,5 +1,8 @@ package team18.team18_be.apply.dto.request; -public record ApplicationFormRequest(String name, String address, String motivation) { +public record ApplicationFormRequest(String name, + String address, + String phoneNumber, + String motivation) { } From 399ec67b56f99d7142074a559bc323352926c453 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:02:15 +0900 Subject: [PATCH 21/56] =?UTF-8?q?feat=20:=20=EC=83=9D=EC=84=B1=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/apply/entity/Apply.java | 7 +++++++ .../team18_be/userInformation/entity/Company.java | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/team18/team18_be/apply/entity/Apply.java b/src/main/java/team18/team18_be/apply/entity/Apply.java index aca59749..0f73377d 100644 --- a/src/main/java/team18/team18_be/apply/entity/Apply.java +++ b/src/main/java/team18/team18_be/apply/entity/Apply.java @@ -40,6 +40,13 @@ public Apply(String status, User user, Recruitment recruitment) { this.recruitment = recruitment; } + public Apply(Long id, String status, User user, Recruitment recruitment) { + this.id = id; + this.status = status; + this.user = user; + this.recruitment = recruitment; + } + public Long getId() { return id; } diff --git a/src/main/java/team18/team18_be/userInformation/entity/Company.java b/src/main/java/team18/team18_be/userInformation/entity/Company.java index 7214609c..0a533fc9 100644 --- a/src/main/java/team18/team18_be/userInformation/entity/Company.java +++ b/src/main/java/team18/team18_be/userInformation/entity/Company.java @@ -36,6 +36,17 @@ public class Company { public Company() { } + public Company(Long id, String name, String industryOccupation, String brand, Long revenuePerYear, + String logoImage, User user) { + this.id = id; + this.name = name; + this.industryOccupation = industryOccupation; + this.brand = brand; + this.revenuePerYear = revenuePerYear; + this.logoImage = logoImage; + this.user = user; + } + public Company(String name, String industryOccupation, String brand, Long revenuePerYear, String logoImage, User user) { this.name = name; From cb38fbe57ee03a81ca28d990641252d2b8e5a21e Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:02:52 +0900 Subject: [PATCH 22/56] =?UTF-8?q?refactor=20:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18/team18_be/apply/controller/ApplyController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/team18/team18_be/apply/controller/ApplyController.java b/src/main/java/team18/team18_be/apply/controller/ApplyController.java index 4b80bae0..08350bf9 100644 --- a/src/main/java/team18/team18_be/apply/controller/ApplyController.java +++ b/src/main/java/team18/team18_be/apply/controller/ApplyController.java @@ -46,9 +46,9 @@ public ResponseEntity createApplicationForm( @Operation(summary = "특정 지원서 조회") @GetMapping("/form/{applyId}") - public ResponseEntity findApplication(@PathVariable Long applyId, + public ResponseEntity findApplicationForm(@PathVariable Long applyId, @LoginUser User user) { - ApplicationFormResponse applicationFormResponse = applyService.findApplication(applyId); + ApplicationFormResponse applicationFormResponse = applyService.findApplicationForm(applyId); return ResponseEntity.ok(applicationFormResponse); } From c57357bbdb07c2be1bee09b9a2f34d05d2b3c9c8 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:04:07 +0900 Subject: [PATCH 23/56] =?UTF-8?q?fix=20:=20Optional=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=B0=8F=20=EC=9A=94=EC=B2=AD=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/apply/service/ApplyService.java | 20 ++++++++++++------- .../team18/team18_be/common/FileService.java | 4 +++- .../resume/service/ResumeService.java | 3 ++- .../service/UserInformationService.java | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) 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 da484064..4dc2c4d5 100644 --- a/src/main/java/team18/team18_be/apply/service/ApplyService.java +++ b/src/main/java/team18/team18_be/apply/service/ApplyService.java @@ -54,18 +54,19 @@ public Long createApplicationForm(ApplicationFormRequest applicationFormRequest, Apply apply = new Apply(status.getKoreanName(), user, recruitment); Apply savedApply = applyRepository.save(apply); ApplicationForm applicationForm = new ApplicationForm(applicationFormRequest.name(), - applicationFormRequest.address(), applicationFormRequest.address(), + applicationFormRequest.address(), applicationFormRequest.phoneNumber(), applicationFormRequest.motivation(), savedApply); applicationFormRepository.save(applicationForm); return savedApply.getId(); } - public ApplicationFormResponse findApplication(Long applyId) { + public ApplicationFormResponse findApplicationForm(Long applyId) { Apply apply = applyRepository.findById(applyId) .orElseThrow(() -> new NoSuchElementException("해당 지원서가 없습니다")); - ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); + ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) + .orElseThrow(() -> new NoSuchElementException("해당 지원서가 없습니다.")); ApplicationFormResponse applicationFormResponse = new ApplicationFormResponse( - applicationForm.getName(), applicationForm.getAddress(), applicationForm.getAddress(), + applicationForm.getName(), applicationForm.getAddress(), applicationForm.getPhoneNumber(), applicationForm.getMotivation()); return applicationFormResponse; } @@ -74,7 +75,9 @@ public ApplicationFormResponse findApplication(Long applyId) { public List searchApplicant(Long recruitmentId, User user) { Recruitment recruitment = findRecruitment(recruitmentId); - return applyRepository.findByRecruitment(recruitment).stream() + return applyRepository.findByRecruitment(recruitment) + .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 없습니다.")) + .stream() .map(this::createApplierPerRecruitmentResponse) .collect(Collectors.toList()); } @@ -89,7 +92,9 @@ private ApplierPerRecruitmentResponse createApplierPerRecruitmentResponse(Apply } public List searchMyAppliedRecruitments(User user) { - return applyRepository.findByUser(user).stream() + return applyRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 없습니다.")) + .stream() .map(this::createMyAppliedRecruitments) .collect(Collectors.toList()); } @@ -107,7 +112,8 @@ private RecruitmentsOfApplierResponse createMyAppliedRecruitments(Apply apply) { } public MandatoryResponse checkMandatory(User user) { - ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user); + ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당 외국인 정보가 없습니다.")); Resume resume = resumeRepository.findByUser(user); boolean visaExistence = checkNull(foreignerInformation.getForeignerIdNumber()); boolean resumeExistence = checkNull(foreignerInformation.getVisaGenerateDate()); diff --git a/src/main/java/team18/team18_be/common/FileService.java b/src/main/java/team18/team18_be/common/FileService.java index ed6aa5e1..83767bcc 100644 --- a/src/main/java/team18/team18_be/common/FileService.java +++ b/src/main/java/team18/team18_be/common/FileService.java @@ -1,6 +1,7 @@ package team18.team18_be.common; import io.jsonwebtoken.io.IOException; +import java.util.NoSuchElementException; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -36,7 +37,8 @@ public String uploadContractPdf(byte[] pdfData, String dirName, String fileName) } public byte[] getSignImage(User user) { - Sign sign = signRepository.findByUser(user); + Sign sign = signRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당 사인이 없습니다")); ResponseEntity response = restTemplate.getForEntity(sign.getImageUrl(), byte[].class); diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index 4dcfdbe8..e4a131bc 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -44,7 +44,8 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { .orElseThrow(() -> new NoSuchElementException("해당하는 이력서가 존재하지 않습니다.")); Apply apply = applyRepository.findById(applyId) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); - ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); + ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) + .orElseThrow(() -> new NoSuchElementException("해당하는 지원서가 존재하지 않습니다.")); return resumeMapper.toResumeAndApplyResponse(resume, applicationForm.getMotivation()); } diff --git a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java index fa8ee1b2..e273d361 100644 --- a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java +++ b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java @@ -57,7 +57,8 @@ public Long createCompany(CompanyRequest companyRequest, MultipartFile logoImage } public CompanyResponse findCompany(User user) { - Company company = companyRepository.findByUser(user); + Company company = companyRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당 회사 정보가 없습니다")); CompanyResponse companyResponse = new CompanyResponse(company.getId(), company.getName(), company.getIndustryOccupation(), company.getBrand(), company.getRevenuePerYear(), company.getLogoImage()); @@ -78,7 +79,8 @@ public Long fillInVisa(VisaRequest visaRequest, User user) { public VisaResponse findVisa(Long userId) { User user = authRepository.findById(userId) .orElseThrow(() -> new NoSuchElementException("해당 유저가 없습니다.")); - ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user); + ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당 외국인 정보가 없습니다")); String visaGenerateDate = foreignerInformation.getVisaGenerateDate().toString(); String visaExpiryDate = foreignerInformation.getVisaExpiryDate().toString(); VisaResponse visaResponse = new VisaResponse(foreignerInformation.getForeignerIdNumber(), @@ -98,7 +100,8 @@ public Long fillInSign(MultipartFile imageUrl, User user) { } public SignResponse findSign(User user) { - Sign sign = signRepository.findByUser(user); + Sign sign = signRepository.findByUser(user) + .orElseThrow(() -> new NoSuchElementException("해당 사인이 없습니다.")); SignResponse signResponse = new SignResponse(sign.getImageUrl()); return signResponse; } From 9a906afcfd5e21865852c57bff6d0bbfd99e3480 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:04:40 +0900 Subject: [PATCH 24/56] =?UTF-8?q?feat=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/service/applyServiceTest.java | 143 ++++++++++++++++ .../userInfo/userInformationServiceTest.java | 155 ++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 src/test/java/team18/team18_be/apply/service/applyServiceTest.java create mode 100644 src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java diff --git a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java new file mode 100644 index 00000000..89ad4a4d --- /dev/null +++ b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java @@ -0,0 +1,143 @@ +package team18.team18_be.apply.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import team18.team18_be.apply.ApplyStatusEnum.ApplyStatus; +import team18.team18_be.apply.dto.request.ApplicationFormRequest; +import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse; +import team18.team18_be.apply.dto.response.RecruitmentsOfApplierResponse; +import team18.team18_be.apply.entity.ApplicationForm; +import team18.team18_be.apply.entity.Apply; +import team18.team18_be.apply.repository.ApplicationFormRepository; +import team18.team18_be.apply.repository.ApplyRepository; +import team18.team18_be.auth.entity.User; +import team18.team18_be.recruitment.entity.Recruitment; +import team18.team18_be.recruitment.entity.RecruitmentContent; +import team18.team18_be.recruitment.repository.RecruitmentRepository; +import team18.team18_be.resume.entity.Resume; +import team18.team18_be.resume.repository.ResumeRepository; +import team18.team18_be.userInformation.entity.Company; +import team18.team18_be.userInformation.repository.CompanyRepository; + +public class applyServiceTest { + + @Mock + private ApplyRepository applyRepository; + + @Mock + private ApplicationFormRepository applicationFormRepository; + @Mock + private RecruitmentRepository recruitmentRepository; + @Mock + private ResumeRepository resumeRepository; + @Mock + private CompanyRepository companyRepository; + @InjectMocks + private ApplyService applyService; + private User employee; + private User employer; + private Company company; + private RecruitmentContent recruitmentContent; + private Recruitment recruitment; + private Apply apply; + private Resume resume; + private ApplicationForm applicationForm; + + + @BeforeEach + public void setUp() { + MockitoAnnotations.openMocks(this); + employee = new User(1L, "홍길동", "abcd@naver.com", "2"); + employer = new User(2L, "A사장", "employer@naver.com", "1"); + company = new Company(1L,"A", "Food", "Nobrand", 10000L, "aaaa.logoimage.src", employer); + recruitmentContent = new RecruitmentContent("koreanDetailedDescription", + "vietnameseDetailedDescription"); + recruitment = new Recruitment("koreanTitle", "vietnameseTitle", "companySize", + "area", "salary", + "workDuration", "workDays", "workType", "workHours", "requestedCareer", "majorBusiness", + "eligibilityCriteria", "preferredConditions", "employerName", "companyName", company, + recruitmentContent); + resume = new Resume(1L,"홍길동", "123 street", "01012345678", "cooker", "good", "myIntroduction",employee); + apply = new Apply(1L, ApplyStatus.REVIEWING_APPLICATION.getKoreanName(), employee, + recruitment); + applicationForm = new ApplicationForm("홍길동", "123 street", "01012345678", "myMotivation", + apply); + } + + @Test + public void testCreateApplicationForm() { + // Given + ApplicationFormRequest request = new ApplicationFormRequest("홍길동", "123 Street", + "my_motivation"); + Long recruitmentId = 1L; + + when(applyRepository.save(any(Apply.class))).thenReturn( + apply); + when(applicationFormRepository.save(any(ApplicationForm.class))).thenReturn( + applicationForm); + when(recruitmentRepository.findById(recruitmentId)).thenReturn( + Optional.of(recruitment)); + + // When + Long result = applyService.createApplicationForm(request, recruitmentId, employee); + + // Then + assertNotNull(result); + assertEquals(apply.getId(), result); + verify(applyRepository).save(any(Apply.class)); + verify(applicationFormRepository).save(any(ApplicationForm.class)); + } + + @Test + public void testSearchApplicant() { + //given + Long recruitmentId = 1L; + List applies = Stream.of(apply).collect(Collectors.toList()); + when(recruitmentRepository.findById(recruitmentId)).thenReturn( + Optional.ofNullable(recruitment)); + when(applyRepository.findByRecruitment(recruitment)).thenReturn( + Optional.ofNullable(applies)); + when(resumeRepository.findByUser(employee)).thenReturn(resume); + + //when + List responses = applyService.searchApplicant( + recruitmentId, employer); + + //then + assertNotNull(responses); + assertEquals(applies.size(), responses.size()); + } + + @Test + public void testSearchMyAppliedRecruitments(){ + //given + List applies = Stream.of(apply).toList(); + when(applyRepository.findByUser(employee)).thenReturn(Optional.of(applies)); + when(recruitmentRepository.findById(recruitment.getRecruitmentId())).thenReturn( + Optional.ofNullable(recruitment)); + when(companyRepository.findById(recruitment.getCompany().getId())).thenReturn( + Optional.ofNullable(company)); + + //when + List responses = applyService.searchMyAppliedRecruitments(employee); + + //then + assertNotNull(responses); + assertEquals(apply.getId(),responses.get(0).applyId()); + assertEquals(company.getLogoImage(),responses.get(0).image()); + } + +} diff --git a/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java new file mode 100644 index 00000000..062e5fb9 --- /dev/null +++ b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java @@ -0,0 +1,155 @@ +package team18.team18_be.userInfo; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.time.LocalDate; +import java.util.NoSuchElementException; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.web.multipart.MultipartFile; +import team18.team18_be.auth.entity.User; +import team18.team18_be.auth.repository.AuthRepository; +import team18.team18_be.config.GCS.FileUtil; +import team18.team18_be.config.GCS.GcsUploader; +import team18.team18_be.userInformation.dto.request.CompanyRequest; +import team18.team18_be.userInformation.dto.request.CompanyResponse; +import team18.team18_be.userInformation.dto.request.VisaRequest; +import team18.team18_be.userInformation.dto.request.VisaResponse; +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; +import team18.team18_be.userInformation.service.UserInformationService; + +public class userInformationServiceTest { + + @InjectMocks + private UserInformationService userInformationService; + @Mock + private ForeignerInformationRepository foreignerInformationRepository; + @Mock + private CompanyRepository companyRepository; + @Mock + private SignRepository signRepository; + @Mock + private AuthRepository authRepository; + @Mock + private GcsUploader gcsUploader; + @Mock + private FileUtil fileUtil; + + private User employer; + private User employee; + private Company company; + private ForeignerInformation foreignerInformation; + + @BeforeEach + public void setup() { + MockitoAnnotations.openMocks(this); + employee = new User(1L, "홍길동", "abcd@naver.com", "2"); + employer = new User(2L, "A사장", "employer@naver.com", "1"); + company = new Company(1L, "A", "Food", "Nobrand", 10000L, "aaaa.logoimage.src", employer); + foreignerInformation = new ForeignerInformation(1L, "123456789", LocalDate.of(2024, 10, 25), + LocalDate.of(2034, 10, 25), employee); + } + + @Test + public void testCreateCompany() { + //given + byte[] imageFile = "test data".getBytes(); + CompanyRequest companyRequest = new CompanyRequest("A", "Food", "Nobrand", 10000L); + MockMultipartFile logoImage = new MockMultipartFile( + "logoImage", // 파라미터 이름 + "test.jpg", // 원본 파일명 + "image/jpeg", // MIME 타입 + "test data".getBytes() // 파일 데이터 (바이트 배열) + ); + when(fileUtil.safelyGetBytes(any(MultipartFile.class))).thenReturn(Optional.of(imageFile)); + when(gcsUploader.upload(any(byte[].class), any(String.class), any(String.class))) + .thenReturn(Optional.of("aaaa.logoimage.src")); + when(companyRepository.save(any(Company.class))).thenReturn(company); + + Long result = userInformationService.createCompany(companyRequest, logoImage, employer); + + assertEquals(company.getId(), result); + } + + @Test + public void testFindCompany() { + //given + when(companyRepository.findByUser(employer)).thenReturn(Optional.of(company)); + //when + CompanyResponse companyResponse = userInformationService.findCompany(employer); + //then + assertEquals(company.getId(), companyResponse.CompanyId()); + } + + @Test + public void testFillInVisa() { + //given + VisaRequest visaRequest = new VisaRequest("123456789", "2024-10-25"); + when(foreignerInformationRepository.save(any(ForeignerInformation.class))).thenReturn( + foreignerInformation); + //when + Long result = userInformationService.fillInVisa(visaRequest, employee); + //then + assertEquals(foreignerInformation.getId(), result); + } + + @Test + public void testFindVisa() { + //given + Long employeeId = 1L; + when(authRepository.findById(employeeId)).thenReturn(Optional.of(employee)); + when(foreignerInformationRepository.findByUser(employee)).thenReturn( + Optional.of(foreignerInformation)); + //when + VisaResponse visaResponse = userInformationService.findVisa(employeeId); + //then + assertEquals(foreignerInformation.getForeignerIdNumber(), visaResponse.foreginerNumber()); + assertEquals(foreignerInformation.getVisaGenerateDate().toString(), + visaResponse.visaGenereteDate().toString()); + assertEquals(foreignerInformation.getVisaExpiryDate().toString(), + visaResponse.visaExpiryDate().toString()); + } + + @Test + public void testFillInSign_FileReadError() { + // given + MultipartFile imageUrl = new MockMultipartFile("image", "test.jpg", "image/jpeg", + "test data".getBytes()); + when(fileUtil.safelyGetBytes(any(MultipartFile.class))).thenReturn(Optional.empty()); + + // when & then + assertThrows(IllegalArgumentException.class, () -> { + userInformationService.fillInSign(imageUrl, employer); + }); + } + + @Test + public void testFillInSign_FileUploadError() { + // given + MultipartFile imageUrl = new MockMultipartFile("image", "test.jpg", "image/jpeg", + "test data".getBytes()); + when(fileUtil.safelyGetBytes(any(MultipartFile.class))).thenReturn( + Optional.of("test data".getBytes())); + when(gcsUploader.upload(any(byte[].class), any(String.class), any(String.class))).thenReturn( + Optional.empty()); + + // when & then + assertThrows(NoSuchElementException.class, () -> { + userInformationService.fillInSign(imageUrl, employer); + }); + } + +} From 2d2fc7396fe421f33858437907db5695c726c4fe Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:07:25 +0900 Subject: [PATCH 25/56] =?UTF-8?q?feat=20:=20repository=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/resume/service/ResumeService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index e4a131bc..4dcfdbe8 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -44,8 +44,7 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { .orElseThrow(() -> new NoSuchElementException("해당하는 이력서가 존재하지 않습니다.")); Apply apply = applyRepository.findById(applyId) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); - ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) - .orElseThrow(() -> new NoSuchElementException("해당하는 지원서가 존재하지 않습니다.")); + ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); return resumeMapper.toResumeAndApplyResponse(resume, applicationForm.getMotivation()); } From 4dafb3c1f9882338828ef52e21e5ae43e7494e0f Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 15:20:43 +0900 Subject: [PATCH 26/56] =?UTF-8?q?refactor=20:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/apply/service/applyServiceTest.java | 14 ++++++++------ .../userInfo/userInformationServiceTest.java | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java index 89ad4a4d..c4413253 100644 --- a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java +++ b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java @@ -62,7 +62,7 @@ public void setUp() { MockitoAnnotations.openMocks(this); employee = new User(1L, "홍길동", "abcd@naver.com", "2"); employer = new User(2L, "A사장", "employer@naver.com", "1"); - company = new Company(1L,"A", "Food", "Nobrand", 10000L, "aaaa.logoimage.src", employer); + company = new Company(1L, "A", "Food", "Nobrand", 10000L, "aaaa.logoimage.src", employer); recruitmentContent = new RecruitmentContent("koreanDetailedDescription", "vietnameseDetailedDescription"); recruitment = new Recruitment("koreanTitle", "vietnameseTitle", "companySize", @@ -70,7 +70,8 @@ public void setUp() { "workDuration", "workDays", "workType", "workHours", "requestedCareer", "majorBusiness", "eligibilityCriteria", "preferredConditions", "employerName", "companyName", company, recruitmentContent); - resume = new Resume(1L,"홍길동", "123 street", "01012345678", "cooker", "good", "myIntroduction",employee); + resume = new Resume(1L, "홍길동", "123 street", "01012345678", "cooker", "good", "myIntroduction", + employee); apply = new Apply(1L, ApplyStatus.REVIEWING_APPLICATION.getKoreanName(), employee, recruitment); applicationForm = new ApplicationForm("홍길동", "123 street", "01012345678", "myMotivation", @@ -122,7 +123,7 @@ public void testSearchApplicant() { } @Test - public void testSearchMyAppliedRecruitments(){ + public void testSearchMyAppliedRecruitments() { //given List applies = Stream.of(apply).toList(); when(applyRepository.findByUser(employee)).thenReturn(Optional.of(applies)); @@ -132,12 +133,13 @@ public void testSearchMyAppliedRecruitments(){ Optional.ofNullable(company)); //when - List responses = applyService.searchMyAppliedRecruitments(employee); + List responses = applyService.searchMyAppliedRecruitments( + employee); //then assertNotNull(responses); - assertEquals(apply.getId(),responses.get(0).applyId()); - assertEquals(company.getLogoImage(),responses.get(0).image()); + assertEquals(apply.getId(), responses.get(0).applyId()); + assertEquals(company.getLogoImage(), responses.get(0).image()); } } diff --git a/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java index 062e5fb9..9ed8b785 100644 --- a/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java +++ b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java @@ -25,7 +25,6 @@ import team18.team18_be.userInformation.dto.request.VisaResponse; 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; @@ -118,9 +117,9 @@ public void testFindVisa() { //then assertEquals(foreignerInformation.getForeignerIdNumber(), visaResponse.foreginerNumber()); assertEquals(foreignerInformation.getVisaGenerateDate().toString(), - visaResponse.visaGenereteDate().toString()); + visaResponse.visaGenereteDate()); assertEquals(foreignerInformation.getVisaExpiryDate().toString(), - visaResponse.visaExpiryDate().toString()); + visaResponse.visaExpiryDate()); } @Test From 7e705b113092fe200c8c504c920b23c7b0f007c5 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:26:31 +0900 Subject: [PATCH 27/56] =?UTF-8?q?refactor=20:=20salary=20Long=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/recruitment/dto/request/RecruitmentRequest.java | 2 +- .../recruitment/dto/response/RecruitmentResponse.java | 2 +- .../java/team18/team18_be/recruitment/entity/Recruitment.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/team18/team18_be/recruitment/dto/request/RecruitmentRequest.java b/src/main/java/team18/team18_be/recruitment/dto/request/RecruitmentRequest.java index 8d3a8147..c3965951 100644 --- a/src/main/java/team18/team18_be/recruitment/dto/request/RecruitmentRequest.java +++ b/src/main/java/team18/team18_be/recruitment/dto/request/RecruitmentRequest.java @@ -4,7 +4,7 @@ public record RecruitmentRequest( String title, String companySize, String area, - String salary, + Long salary, String workDuration, String workDays, String workType, diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponse.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponse.java index 6ee7f16f..8a6da3b8 100644 --- a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponse.java +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponse.java @@ -5,7 +5,7 @@ public record RecruitmentResponse( String vietnameseTitle, String companySize, String area, - String salary, + Long salary, String workDuration, String workDays, String workType, diff --git a/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java b/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java index 45384bb6..92d48192 100644 --- a/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java +++ b/src/main/java/team18/team18_be/recruitment/entity/Recruitment.java @@ -25,7 +25,7 @@ public class Recruitment { private String vietnameseTitle; private String companySize; private String area; - private String salary; + private Long salary; private String workDuration; private String workDays; private String workType; @@ -46,7 +46,7 @@ public class Recruitment { private RecruitmentContent recruitmentContent; public Recruitment(String koreanTitle, String vietnameseTitle, String companySize, String area, - String salary, String workDuration, String workDays, String workType, String workHours, + Long salary, String workDuration, String workDays, String workType, String workHours, String requestedCareer, String majorBusiness, String eligibilityCriteria, String preferredConditions, String employerName, String companyName, Company company, From 26b0a1cbcc4166716cee76eedbd7775a93813c47 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:27:32 +0900 Subject: [PATCH 28/56] =?UTF-8?q?refactor=20:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18/team18_be/resume/controller/ResumeController.java | 2 +- .../java/team18/team18_be/resume/service/ResumeService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/team18/team18_be/resume/controller/ResumeController.java b/src/main/java/team18/team18_be/resume/controller/ResumeController.java index d4c36cdb..169e023f 100644 --- a/src/main/java/team18/team18_be/resume/controller/ResumeController.java +++ b/src/main/java/team18/team18_be/resume/controller/ResumeController.java @@ -43,7 +43,7 @@ public ResponseEntity saveResume( public ResponseEntity getResume( @LoginUser User user ) { - return ResponseEntity.ok().body(resumeService.findResumeByEmployeeId(user)); + return ResponseEntity.ok().body(resumeService.findResumeByEmployee(user)); } @ApiOperation(value = "이력서 id로 이력서 조회 메서드") diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index af851ebd..135fb4e4 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -37,7 +37,7 @@ public void saveResume(ResumeRequest resumeRequest, User user) { resumeRepository.save(resumeMapper.toResume(resumeRequest, user)); } - public ResumeResponse findResumeByEmployeeId(User user) { + public ResumeResponse findResumeByEmployee(User user) { return resumeMapper.toResumeResponse(resumeRepository.findByUser(user)); } From 8eba5307d09fe262e79c22933b79eb9c8687333d Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:27:52 +0900 Subject: [PATCH 29/56] =?UTF-8?q?test=20:=20=EA=B5=AC=EC=9D=B8=EA=B8=80=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecruitmentResponseForCompany.java | 2 +- .../RecruitmentSummationResponse.java | 2 +- .../{ => configtest}/OpenAiServiceTest.java | 11 +- .../recruitment/RecruitmentServiceTest.java | 128 ++++++++++++++++++ 4 files changed, 136 insertions(+), 7 deletions(-) rename src/test/java/team18/team18_be/{ => configtest}/OpenAiServiceTest.java (82%) create mode 100644 src/test/java/team18/team18_be/recruitment/RecruitmentServiceTest.java diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponseForCompany.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponseForCompany.java index 7b042da1..54222c2f 100644 --- a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponseForCompany.java +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentResponseForCompany.java @@ -6,7 +6,7 @@ public record RecruitmentResponseForCompany( String koreanTitle, String vietnameseTitle, String companyName, - String salary, + Long salary, String area, Boolean hiring ) { diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java index 05c36ea9..8bc7f3f5 100644 --- a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentSummationResponse.java @@ -6,7 +6,7 @@ public record RecruitmentSummationResponse( String koreanTitle, String vietnameseTitle, String companyName, - String salary, + Long salary, String area ) { } diff --git a/src/test/java/team18/team18_be/OpenAiServiceTest.java b/src/test/java/team18/team18_be/configtest/OpenAiServiceTest.java similarity index 82% rename from src/test/java/team18/team18_be/OpenAiServiceTest.java rename to src/test/java/team18/team18_be/configtest/OpenAiServiceTest.java index 1bc04985..214ecb15 100644 --- a/src/test/java/team18/team18_be/OpenAiServiceTest.java +++ b/src/test/java/team18/team18_be/configtest/OpenAiServiceTest.java @@ -1,20 +1,21 @@ -package team18.team18_be; +package team18.team18_be.configtest; import com.fasterxml.jackson.core.JsonProcessingException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import team18.team18_be.Team18BeApplication; import team18.team18_be.config.infrastructure.OpenAiService; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; -@SpringBootTest +@SpringBootTest(classes = Team18BeApplication.class) public class OpenAiServiceTest { private final RecruitmentRequest recruitmentRequest = new RecruitmentRequest( "주방 보조", // 직무 제목 "중소기업", // 회사 규모 "서울 강남구", // 근무 지역 - "2400만원", // 급여 + 240000000L, // 급여 "1년 이상", // 근무 기간 "주 5일", // 근무일 "풀타임", // 근무 형태 @@ -31,13 +32,13 @@ public class OpenAiServiceTest { private OpenAiService openAiService; @Test - void test1() throws JsonProcessingException { + void 한국어제목_베트남어로_바꾸기() throws JsonProcessingException { String result = openAiService.translateKoreanToVietnamese("스타벅스 충남대점에서 아르바이트생을 모집합니다."); System.out.println(result); } @Test - void test2() throws JsonProcessingException { + void 받은_구인글_요약하고_번역() throws JsonProcessingException { String result = openAiService.summation(recruitmentRequest); System.out.println(result); System.out.println(openAiService.translateKoreanToVietnamese(result)); diff --git a/src/test/java/team18/team18_be/recruitment/RecruitmentServiceTest.java b/src/test/java/team18/team18_be/recruitment/RecruitmentServiceTest.java new file mode 100644 index 00000000..cb176c58 --- /dev/null +++ b/src/test/java/team18/team18_be/recruitment/RecruitmentServiceTest.java @@ -0,0 +1,128 @@ +package team18.team18_be.recruitment; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import jakarta.transaction.Transactional; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import team18.team18_be.Team18BeApplication; +import team18.team18_be.auth.entity.User; +import team18.team18_be.auth.repository.AuthRepository; +import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; +import team18.team18_be.recruitment.entity.Recruitment; +import team18.team18_be.recruitment.repository.RecruitmentRepository; +import team18.team18_be.recruitment.service.RecruitmentService; +import team18.team18_be.userInformation.entity.Company; +import team18.team18_be.userInformation.repository.CompanyRepository; + +@SpringBootTest(classes = Team18BeApplication.class) +@Transactional +public class RecruitmentServiceTest { + + static final String NAME = "name"; + static final String EMAIL = "email"; + @Autowired + RecruitmentRepository recruitmentRepository; + @Autowired + RecruitmentService recruitmentService; + @Autowired + CompanyRepository companyRepository; + @Autowired + AuthRepository authRepository; + + @Test + @Transactional + @DisplayName("구인글 저장") + public void saveRecruitmentTest() throws JsonProcessingException { + User user = new User(NAME, EMAIL, "first"); + Company company = new Company("MyCompany", "Tech", "MyBrand", 1000000L, "image", user); + companyRepository.save(company); + + recruitmentService.saveRecruitment( + new RecruitmentRequest("맛있는 밥상에서 아르바이트를 모집합니다.", "50명 이상의 직원", "서울, 대한민국", + 70000000L, "정규직", "주 5일", "상근", "오전 10시부터 오후 7시까지", + "경력 5년 이상", "한식 레스토랑", "요리 관련 전공 또는 경력", + "팀워크 및 리더십 경험", "박정호", "맛있는 한상", 1L)); + Recruitment recruitment = recruitmentRepository.findById(1L).get(); + assertThat(recruitment.getArea()).isEqualTo("서울, 대한민국"); + } + + @Test + @Transactional + @DisplayName("구인글 전체조회") + public void findAllRecruitmentTest() throws JsonProcessingException { + User user = new User(NAME, EMAIL, "first"); + Company company = new Company("MyCompany", "Tech", "MyBrand", 1000000L, "image", user); + companyRepository.save(company); + authRepository.save(user); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "초보자를 위한 요리사 모집", "30명 이상의 직원", "제주, 대한민국", + 25000000L, "계약직", "주 6일", "파트타임", "오전 7시부터 오후 3시까지", + "경력 1년 이상", "지역 맛집", "요리 관련 자격증 소지자 우대", + "팀워크와 성실함", "정하윤", "제주 맛집", 1L)); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "프리랜서 웹 개발자 모집", "10명 이하의 직원", "서울, 대한민국", + 100000000L, "프리랜서", "주 3일", "원격 근무", "유연한 근무 시간", + "경력 7년 이상", "스타트업", "풀스택 개발 경험 필수", + "문제 해결 능력 및 주도성", "김재훈", "테크이노베이션", 1L)); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "해외 영업 전문가 모집", "200명 이상의 직원", "부산, 대한민국", + 120000000L, "정규직", "주 5일", "상근", "오전 8시부터 오후 5시까지", + "경력 10년 이상", "무역 회사", "국제 무역 및 영업 관련 전공", + "영어 능통 및 협상 기술", "이민호", "글로벌 트레이드", 1L)); + + Pageable pageable = PageRequest.of(0, 5); + + List recruitmentSummationResponseList = recruitmentService.getAllRecruitment( + pageable); + assertThat(recruitmentSummationResponseList.size()).isEqualTo(3); + } + + @Test + @Transactional + @DisplayName("구인글 급여 순서대로 전체조회") + public void findAllRecruitmentBySalaryTest() throws JsonProcessingException { + User user = new User(NAME, EMAIL, "first"); + Company company = new Company("MyCompany", "Tech", "MyBrand", 1000000L, "image", user); + companyRepository.save(company); + authRepository.save(user); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "초보자를 위한 요리사 모집", "30명 이상의 직원", "제주, 대한민국", + 25000000L, "계약직", "주 6일", "파트타임", "오전 7시부터 오후 3시까지", + "경력 1년 이상", "지역 맛집", "요리 관련 자격증 소지자 우대", + "팀워크와 성실함", "정하윤", "제주 맛집", 1L)); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "프리랜서 웹 개발자 모집", "10명 이하의 직원", "서울, 대한민국", + 100000000L, "프리랜서", "주 3일", "원격 근무", "유연한 근무 시간", + "경력 7년 이상", "스타트업", "풀스택 개발 경험 필수", + "문제 해결 능력 및 주도성", "김재훈", "테크이노베이션", 1L)); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "해외 영업 전문가 모집", "200명 이상의 직원", "부산, 대한민국", + 120000000L, "정규직", "주 5일", "상근", "오전 8시부터 오후 5시까지", + "경력 10년 이상", "무역 회사", "국제 무역 및 영업 관련 전공", + "영어 능통 및 협상 기술", "이민호", "글로벌 트레이드", 1L)); + + Pageable pageable = PageRequest.of(0, 5); + + List recruitmentSummationResponseList = recruitmentService.getAllRecruitmentAndSortBySalary( + pageable); + + assertThat(recruitmentSummationResponseList.get(0).recruitmentId()).isEqualTo(3L); + assertThat(recruitmentSummationResponseList.get(1).recruitmentId()).isEqualTo(2L); + assertThat(recruitmentSummationResponseList.get(2).recruitmentId()).isEqualTo(1L); + } + +} From 46ddf46fb35d8e4d96d6c6a47caf2a60c4458bdf Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:28:01 +0900 Subject: [PATCH 30/56] =?UTF-8?q?test=20:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resumetest/ResumeServiceTest.java | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/test/java/team18/team18_be/resumetest/ResumeServiceTest.java diff --git a/src/test/java/team18/team18_be/resumetest/ResumeServiceTest.java b/src/test/java/team18/team18_be/resumetest/ResumeServiceTest.java new file mode 100644 index 00000000..76ea1815 --- /dev/null +++ b/src/test/java/team18/team18_be/resumetest/ResumeServiceTest.java @@ -0,0 +1,125 @@ +package team18.team18_be.resumetest; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import jakarta.transaction.Transactional; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import team18.team18_be.Team18BeApplication; +import team18.team18_be.apply.entity.ApplicationForm; +import team18.team18_be.apply.entity.Apply; +import team18.team18_be.apply.repository.ApplicationFormRepository; +import team18.team18_be.apply.repository.ApplyRepository; +import team18.team18_be.auth.entity.User; +import team18.team18_be.auth.repository.AuthRepository; +import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.repository.RecruitmentRepository; +import team18.team18_be.recruitment.service.RecruitmentService; +import team18.team18_be.resume.dto.request.ResumeRequest; +import team18.team18_be.resume.dto.response.ResumeAndApplyResponse; +import team18.team18_be.resume.dto.response.ResumeResponse; +import team18.team18_be.resume.entity.Resume; +import team18.team18_be.resume.repository.ResumeRepository; +import team18.team18_be.resume.service.ResumeService; +import team18.team18_be.userInformation.entity.Company; +import team18.team18_be.userInformation.repository.CompanyRepository; + +@SpringBootTest(classes = Team18BeApplication.class) +public class ResumeServiceTest { + + static final String NAME = "name"; + static final String EMAIL = "email"; + + @Autowired + ResumeService resumeService; + @Autowired + ResumeRepository resumeRepository; + @Autowired + AuthRepository authRepository; + @Autowired + ApplyRepository applyRepository; + @Autowired + RecruitmentService recruitmentService; + @Autowired + RecruitmentRepository recruitmentRepository; + @Autowired + ApplicationFormRepository applicationFormRepository; + @Autowired + CompanyRepository companyRepository; + + @Test + @Transactional + @DisplayName("이력서 저장하기") + public void saveResumeTest() { + User user = new User(NAME, EMAIL, "first"); + resumeService.saveResume( + new ResumeRequest("김민지", + "서울특별시 강남구 테헤란로 123", + "010-1234-5678", + "3년 이상의 백엔드 개발 경력", + "한국어 능력 상", + "저는 효율적인 시스템을 구축하고, 사용자의 경험을 향상시키는 것을 목표로 하는 백엔드 개발자입니다. 다양한 기술 스택을 활용하여 문제를 해결하며, 팀워크와 협업을 중요시합니다.") + , user + ); + Resume resume = resumeRepository.findById(1L).get(); + assertThat(resume.getApplicantName()).isEqualTo("김민지"); + } + + @Test + @Transactional + @DisplayName("사용자 별 이력서 찾기") + public void findResumeByEmployeeIdTest() { + User user = new User(NAME, EMAIL, "first"); + resumeService.saveResume( + new ResumeRequest("김민지", + "서울특별시 강남구 테헤란로 123", + "010-1234-5678", + "3년 이상의 백엔드 개발 경력", + "한국어 능력 상", + "저는 효율적인 시스템을 구축하고, 사용자의 경험을 향상시키는 것을 목표로 하는 백엔드 개발자입니다. 다양한 기술 스택을 활용하여 문제를 해결하며, 팀워크와 협업을 중요시합니다.") + , user + ); + authRepository.save(user); + ResumeResponse resumeResponse = resumeService.findResumeByEmployee(user); + assertThat(resumeResponse.applicantName()).isEqualTo("김민지"); + } + + @Test + @Transactional + @DisplayName("이력서 id로 이력서 찾고, 지원서 내용 추가") + public void findResumeByIdTest() throws JsonProcessingException { + User user = new User(NAME, EMAIL, "first"); + authRepository.save(user); + Company company = new Company("MyCompany", "Tech", "MyBrand", 1000000L, "image", user); + companyRepository.save(company); + resumeService.saveResume( + new ResumeRequest("김민지", + "서울특별시 강남구 테헤란로 123", + "010-1234-5678", + "3년 이상의 백엔드 개발 경력", + "한국어 능력 상", + "저는 효율적인 시스템을 구축하고, 사용자의 경험을 향상시키는 것을 목표로 하는 백엔드 개발자입니다. 다양한 기술 스택을 활용하여 문제를 해결하며, 팀워크와 협업을 중요시합니다.") + , user + ); + + recruitmentService.saveRecruitment(new RecruitmentRequest( + "해외 영업 전문가 모집", "200명 이상의 직원", "부산, 대한민국", + 120000000L, "정규직", "주 5일", "상근", "오전 8시부터 오후 5시까지", + "경력 10년 이상", "무역 회사", "국제 무역 및 영업 관련 전공", + "영어 능통 및 협상 기술", "이민호", "글로벌 트레이드", 1L)); + + Apply apply = new Apply("status", user, recruitmentRepository.findById(1L).get()); + applyRepository.save(apply); + applicationFormRepository.save( + new ApplicationForm("김민지", "충남대학교", "01033333333", "한국어 실력을 늘리고자 지원했습니다.", apply)); + + ResumeAndApplyResponse resumeAndApplyResponse = resumeService.findResumeById(1L, 1L); + assertThat(resumeAndApplyResponse.applicantName()).isEqualTo("김민지"); + assertThat(resumeAndApplyResponse.motivation()).isEqualTo("한국어 실력을 늘리고자 지원했습니다."); + } + + +} From a5dfd262e3c692602328dbca288559e9daa07b50 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:50:07 +0900 Subject: [PATCH 31/56] =?UTF-8?q?feat=20:=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/resume/service/ResumeService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index 135fb4e4..62ca5377 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -46,7 +46,8 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { .orElseThrow(() -> new NoSuchElementException("해당하는 이력서가 존재하지 않습니다.")); Apply apply = applyRepository.findById(applyId) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); - ApplicationForm applicationForm = applicationFormRepository.findByApply(apply); + ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) + .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); return resumeMapper.toResumeAndApplyResponse(resume,applicationForm.getMotivation()); } From 54edb2b4ffd30d5e303ecbea55081ae6f3097fc8 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:41:05 +0900 Subject: [PATCH 32/56] =?UTF-8?q?fix=20:=20=EC=97=90=EB=9F=AC=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/resume/service/ResumeService.java | 1 + .../java/team18/team18_be/apply/service/applyServiceTest.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index abc66768..16e5b968 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -43,6 +43,7 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new NoSuchElementException("해당하는 이력서가 존재하지 않습니다.")); Apply apply = applyRepository.findById(applyId) + .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); return resumeMapper.toResumeAndApplyResponse(resume,applicationForm.getMotivation()); diff --git a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java index c4413253..512aa6f5 100644 --- a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java +++ b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java @@ -66,7 +66,7 @@ public void setUp() { recruitmentContent = new RecruitmentContent("koreanDetailedDescription", "vietnameseDetailedDescription"); recruitment = new Recruitment("koreanTitle", "vietnameseTitle", "companySize", - "area", "salary", + "area", 100000000L, "workDuration", "workDays", "workType", "workHours", "requestedCareer", "majorBusiness", "eligibilityCriteria", "preferredConditions", "employerName", "companyName", company, recruitmentContent); From 8428946160c122a87a6fdad094a9933a226facb2 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 16:45:15 +0900 Subject: [PATCH 33/56] =?UTF-8?q?fix=20:=20test=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95(=EC=A0=84=ED=99=94?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/apply/service/applyServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java index c4413253..1772c4cd 100644 --- a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java +++ b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java @@ -82,7 +82,7 @@ public void setUp() { public void testCreateApplicationForm() { // Given ApplicationFormRequest request = new ApplicationFormRequest("홍길동", "123 Street", - "my_motivation"); + "01012345678","my_motivation"); Long recruitmentId = 1L; when(applyRepository.save(any(Apply.class))).thenReturn( From e3d515208cd6413ef859f2c4a48c828351a91696 Mon Sep 17 00:00:00 2001 From: EunKyung Lee <2dmsrud2002@naver.com> Date: Fri, 8 Nov 2024 17:03:02 +0900 Subject: [PATCH 34/56] =?UTF-8?q?Fix:=20swagger=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ApiOpearation 삭제함 --- .../team18_be/contract/controller/ContractController.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/team18/team18_be/contract/controller/ContractController.java b/src/main/java/team18/team18_be/contract/controller/ContractController.java index f45857d4..ac7d8357 100644 --- a/src/main/java/team18/team18_be/contract/controller/ContractController.java +++ b/src/main/java/team18/team18_be/contract/controller/ContractController.java @@ -1,7 +1,6 @@ package team18.team18_be.contract.controller; import com.itextpdf.text.DocumentException; -import io.swagger.annotations.ApiOperation; import jakarta.validation.Valid; import java.io.IOException; import org.springframework.http.HttpStatus; @@ -29,7 +28,6 @@ public ContractController(ContractService contractService) { this.contractService = contractService; } - @ApiOperation(value = "근로계약서 등록 메서드 - 고용주 등록") @PostMapping public ResponseEntity makeContract(@Valid @RequestBody ContractRequest request, @LoginUser User user) throws DocumentException, IOException { @@ -37,7 +35,6 @@ public ResponseEntity makeContract(@Valid @RequestBody ContractRequest req return ResponseEntity.status(HttpStatus.CREATED).build(); } - @ApiOperation(value = "근로계약서 등록 메서드 - 근로자 서명 등록") @PostMapping("/employee") public ResponseEntity fillInEmployeeSign(@Valid @RequestBody ContractRequest request, @LoginUser User user) throws IOException, DocumentException { @@ -45,19 +42,16 @@ public ResponseEntity fillInEmployeeSign(@Valid @RequestBody ContractReque return ResponseEntity.status(HttpStatus.CREATED).build(); } - @ApiOperation(value = "근로계약서 id별 pdf url 반환 메서드") @GetMapping("/{applyId}/download") public ResponseEntity downloadContract(@PathVariable("applyId") Long id) { return ResponseEntity.ok(contractService.getContractPdfUrl(id)); } - @ApiOperation(value = "근로계약서 id별 image url 반환 메서드") @GetMapping("/{applyId}/preview") public ResponseEntity previewContract(@PathVariable("applyId") Long id) { return ResponseEntity.ok(contractService.getContractImageUrl(id)); } - @ApiOperation(value = "근로계약서 id별 근로계약서 정보 반환 메서드") @GetMapping("/{applyId}") public ResponseEntity getContract(@PathVariable("applyId") Long id) { return ResponseEntity.ok(contractService.getContract(id)); From f7f711c31c28102a8f218134c8d5df7a543b338f Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:46:10 +0900 Subject: [PATCH 35/56] =?UTF-8?q?Update=20deploy.yml=20:=20=EA=B9=83?= =?UTF-8?q?=ED=97=99=20=EC=95=A1=EC=85=98=20=EC=9C=A0=EB=8F=99=20IP?= =?UTF-8?q?=EB=A5=BC=20GCP=20SSH=20=EA=B7=9C=EC=B9=99=EC=97=90=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b8a020aa..79d21ab3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -61,6 +61,25 @@ jobs: with: name: team18-be-jar + - name: Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + export_default_credentials: true + + - name: Get GitHub Actions Runner IP + id: get_ip + run: | + echo $(curl -s https://api64.ipify.org) > RUNNER_IP.txt + + - name: Add GitHub Actions IP to GCP Firewall + run: | + RUNNER_IP=$(cat RUNNER_IP.txt) + gcloud compute firewall-rules update default-allow-ssh \ + --allow tcp:22 \ + --source-ranges=${RUNNER_IP}/32 + - name: Configure SSH private key run: | touch ./key-hirehigher @@ -76,3 +95,9 @@ jobs: run: | # scp로 VM에 jar 파일 전송 scp -o StrictHostKeyChecking=no -i ./key-hirehigher ./team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository + + - name: Remove GitHub Actions IP from GCP Firewall + run: | + RUNNER_IP=$(cat RUNNER_IP.txt) + gcloud compute firewall-rules update default-allow-ssh \ + --remove-source-ranges=${RUNNER_IP}/32 From a68d243835b263471ae7631b3d9966656516f42e Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:52:04 +0900 Subject: [PATCH 36/56] Update deploy.yml --- .github/workflows/deploy.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 79d21ab3..94f0691c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -61,12 +61,15 @@ jobs: with: name: team18-be-jar + - name: Authenticate with GCP + uses: google-github-actions/auth@v0 + with: + credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" + - name: Set up Google Cloud SDK uses: google-github-actions/setup-gcloud@v1 with: project_id: ${{ secrets.GCP_PROJECT_ID }} - service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} - export_default_credentials: true - name: Get GitHub Actions Runner IP id: get_ip From 3d24f64be4e7c14642eff4e6e6050563147b1cc1 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:59:27 +0900 Subject: [PATCH 37/56] Update deploy.yml --- .github/workflows/deploy.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 94f0691c..f51af05d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,7 +62,7 @@ jobs: name: team18-be-jar - name: Authenticate with GCP - uses: google-github-actions/auth@v0 + uses: google-github-actions/auth@v1 with: credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" @@ -79,9 +79,19 @@ jobs: - name: Add GitHub Actions IP to GCP Firewall run: | RUNNER_IP=$(cat RUNNER_IP.txt) - gcloud compute firewall-rules update default-allow-ssh \ - --allow tcp:22 \ - --source-ranges=${RUNNER_IP}/32 + + # 기존의 source-ranges 값을 가져옵니다. + EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") + + # GitHub Actions IP가 이미 있다면 추가하지 않도록 방지 + if [[ "$EXCLUDE_IPS" != *"$RUNNER_IP/32"* ]]; then + # GitHub Actions IP를 추가 + gcloud compute firewall-rules update default-allow-ssh \ + --allow tcp:22 \ + --source-ranges="${EXCLUDE_IPS},${RUNNER_IP}/32" + else + echo "GitHub Actions IP already exists in the source-ranges" + fi - name: Configure SSH private key run: | @@ -102,5 +112,13 @@ jobs: - name: Remove GitHub Actions IP from GCP Firewall run: | RUNNER_IP=$(cat RUNNER_IP.txt) + + # 기존 firewall 규칙 가져오기 + EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") + + # GitHub Actions IP를 제외한 source ranges 설정 + NEW_SOURCE_RANGES=$(echo $EXCLUDE_IPS | sed "s/$RUNNER_IP\/32//g") + + # 업데이트된 firewall 규칙 적용 gcloud compute firewall-rules update default-allow-ssh \ - --remove-source-ranges=${RUNNER_IP}/32 + --source-ranges=$NEW_SOURCE_RANGES From 9c33c431d14c93b664d91f11ae655ba0019d3163 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:06:34 +0900 Subject: [PATCH 38/56] Update deploy.yml From 994520a7b552ee77caff888ca85ebffde5c9f900 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:12:46 +0900 Subject: [PATCH 39/56] Update deploy.yml --- .github/workflows/deploy.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f51af05d..9115186e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -80,18 +80,16 @@ jobs: run: | RUNNER_IP=$(cat RUNNER_IP.txt) - # 기존의 source-ranges 값을 가져옵니다. + # 기존의 source-ranges 값 가져오기 EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") + + # 세미콜론 제거 + EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/;*$//') - # GitHub Actions IP가 이미 있다면 추가하지 않도록 방지 - if [[ "$EXCLUDE_IPS" != *"$RUNNER_IP/32"* ]]; then - # GitHub Actions IP를 추가 - gcloud compute firewall-rules update default-allow-ssh \ - --allow tcp:22 \ - --source-ranges="${EXCLUDE_IPS},${RUNNER_IP}/32" - else - echo "GitHub Actions IP already exists in the source-ranges" - fi + # GitHub Actions IP를 추가 + gcloud compute firewall-rules update default-allow-ssh \ + --allow tcp:22 \ + --source-ranges="${EXCLUDE_IPS},${RUNNER_IP}/32" - name: Configure SSH private key run: | From 23af08a80ff3b5cbe4445a4c49c2560c736f425a Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:16:28 +0900 Subject: [PATCH 40/56] Update deploy.yml --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9115186e..8648d53c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -83,8 +83,9 @@ jobs: # 기존의 source-ranges 값 가져오기 EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") + # 세미콜론 제거 - EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/;*$//') + EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]*$//') # GitHub Actions IP를 추가 gcloud compute firewall-rules update default-allow-ssh \ From 16458dfb977d4b2de092ca6be26ef5c5898b3740 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:19:54 +0900 Subject: [PATCH 41/56] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8648d53c..45bd0574 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,7 +85,7 @@ jobs: # 세미콜론 제거 - EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]*$//') + EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]//g') # GitHub Actions IP를 추가 gcloud compute firewall-rules update default-allow-ssh \ From 658a14c3f1623f3f46695b8469e26b6e816a2740 Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:23:17 +0900 Subject: [PATCH 42/56] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 45bd0574..1159a2c3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,7 +85,7 @@ jobs: # 세미콜론 제거 - EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]//g') + EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]//g' | sed 's/$/,/') # GitHub Actions IP를 추가 gcloud compute firewall-rules update default-allow-ssh \ From cb76153321b3d8d13296704f697335cb50ec30de Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:27:44 +0900 Subject: [PATCH 43/56] Update deploy.yml --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1159a2c3..fc795f77 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -83,9 +83,8 @@ jobs: # 기존의 source-ranges 값 가져오기 EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") - # 세미콜론 제거 - EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/[;[:space:]]//g' | sed 's/$/,/') + EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/;/,/g') # GitHub Actions IP를 추가 gcloud compute firewall-rules update default-allow-ssh \ From a7eae0d5c5838f5a118482b7a4f498222582c37a Mon Sep 17 00:00:00 2001 From: Minsu Bae <104720635+minsu-cnu@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:31:30 +0900 Subject: [PATCH 44/56] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fc795f77..faf156aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -115,7 +115,7 @@ jobs: EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "") # GitHub Actions IP를 제외한 source ranges 설정 - NEW_SOURCE_RANGES=$(echo $EXCLUDE_IPS | sed "s/$RUNNER_IP\/32//g") + NEW_SOURCE_RANGES=$(echo $EXCLUDE_IPS | sed "s/$RUNNER_IP\/32//g" | sed 's/;/,/g') # 업데이트된 firewall 규칙 적용 gcloud compute firewall-rules update default-allow-ssh \ From 538b4248c4ada27c7d1cc3a34f249d63c3042109 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 20:17:43 +0900 Subject: [PATCH 45/56] =?UTF-8?q?fix=20:=20=EC=9A=94=EC=B2=AD=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20415=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserInformationController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 fa9bf67d..97026da4 100644 --- a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java +++ b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java @@ -1,8 +1,11 @@ package team18.team18_be.userInformation.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import java.net.URI; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -50,9 +53,17 @@ public ResponseEntity findSign(@LoginUser User user) { } @Operation(summary = "회사등록") - @PostMapping("/company") - public ResponseEntity createCompany(@RequestPart CompanyRequest companyRequest, + @PostMapping(value = "/company", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + 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 { + companyRequest = objectMapper.readValue(companyRequestJson, CompanyRequest.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } Long companyId = userInformationService.createCompany(companyRequest, logoImage, user); URI location = createURI(companyId); return ResponseEntity.created(location).build(); From 6213962c46903e6ed6ac7016e4d2ea71ad529ae7 Mon Sep 17 00:00:00 2001 From: test1 Date: Fri, 8 Nov 2024 21:32:14 +0900 Subject: [PATCH 46/56] =?UTF-8?q?fix=20:=20413=EC=98=A4=EB=A5=98=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ad87a7be..8f0efac3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,4 @@ spring.profiles.active=test spring.profiles.include=gcs +spring.servlet.multipart.max-file-size=2GB +spring.servlet.multipart.max-request-size=2GB From 118e153c279cf7dc13808700774120aeec137b28 Mon Sep 17 00:00:00 2001 From: test1 Date: Sat, 9 Nov 2024 00:04:14 +0900 Subject: [PATCH 47/56] =?UTF-8?q?feat=20:=20=ED=9A=8C=EC=82=AC=20get=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=EA=B0=92=EC=9D=84=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserInformationController.java | 9 +++++---- .../repository/CompanyRepository.java | 3 ++- .../service/UserInformationService.java | 14 +++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) 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 97026da4..6e62c40d 100644 --- a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java +++ b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import java.net.URI; +import java.util.List; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -37,7 +38,7 @@ public UserInformationController(UserInformationService userInformationService) } @Operation(summary = "사인등록", description = "image파일을 받아 gcs에 해당 이미지 저장") - @PostMapping(value = "/sign") + @PostMapping(value = "/sign", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity fillInSign(@RequestParam MultipartFile imageUrl, @LoginUser User user) { Long signId = userInformationService.fillInSign(imageUrl, user); @@ -71,9 +72,9 @@ public ResponseEntity createCompany(@RequestPart("companyRequest") String @Operation(summary = "회사 정보 가져오기", description = "로그인된 user의 회사 정보 가져오기") @GetMapping("/company") - public ResponseEntity findCompany(@LoginUser User user) { - CompanyResponse companyResponse = userInformationService.findCompany(user); - return ResponseEntity.ok(companyResponse); + public ResponseEntity> findCompany(@LoginUser User user) { + List companyResponses = userInformationService.findCompany(user); + return ResponseEntity.ok(companyResponses); } diff --git a/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java b/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java index 4dd58899..6a07c5de 100644 --- a/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java +++ b/src/main/java/team18/team18_be/userInformation/repository/CompanyRepository.java @@ -1,5 +1,6 @@ package team18.team18_be.userInformation.repository; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import team18.team18_be.auth.entity.User; @@ -7,5 +8,5 @@ public interface CompanyRepository extends JpaRepository { - Optional findByUser(User user); + Optional> findByUser(User user); } diff --git a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java index e273d361..9fb1438e 100644 --- a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java +++ b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java @@ -1,7 +1,10 @@ package team18.team18_be.userInformation.service; import java.time.LocalDate; +import java.util.Collections; +import java.util.List; import java.util.NoSuchElementException; +import java.util.stream.Collectors; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -56,15 +59,20 @@ public Long createCompany(CompanyRequest companyRequest, MultipartFile logoImage return savedCompany.getId(); } - public CompanyResponse findCompany(User user) { - Company company = companyRepository.findByUser(user) - .orElseThrow(() -> new NoSuchElementException("해당 회사 정보가 없습니다")); + public List findCompany(User user) { + return companyRepository.findByUser(user).orElse(Collections.emptyList()).stream() + .map(this::createCompanyResponse) + .collect(Collectors.toList()); + } + + private CompanyResponse createCompanyResponse(Company company) { CompanyResponse companyResponse = new CompanyResponse(company.getId(), company.getName(), company.getIndustryOccupation(), company.getBrand(), company.getRevenuePerYear(), company.getLogoImage()); return companyResponse; } + public Long fillInVisa(VisaRequest visaRequest, User user) { LocalDate visaGenerateDate = LocalDate.parse(visaRequest.visaGenerateDate()); LocalDate visaExpiryDate = visaGenerateDate.plusYears(10); From fff5bf1671935ac3fa1c8fed48d612dd237a8ee3 Mon Sep 17 00:00:00 2001 From: test1 Date: Sat, 9 Nov 2024 01:35:13 +0900 Subject: [PATCH 48/56] =?UTF-8?q?feat=20:=20=ED=9A=8C=EC=82=ACresponse=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userInformation/dto/request/CompanyResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/team18/team18_be/userInformation/dto/request/CompanyResponse.java b/src/main/java/team18/team18_be/userInformation/dto/request/CompanyResponse.java index a3d10449..082ea9e0 100644 --- a/src/main/java/team18/team18_be/userInformation/dto/request/CompanyResponse.java +++ b/src/main/java/team18/team18_be/userInformation/dto/request/CompanyResponse.java @@ -1,6 +1,6 @@ package team18.team18_be.userInformation.dto.request; -public record CompanyResponse(Long CompanyId, String name, String industryOccupation, String brand, - Long revenuePerYear, String logo) { +public record CompanyResponse(Long companyId, String name, String industryOccupation, String brand, + Long revenuePerYear, String logoImage) { } From 1c1b26ba771b07287a152de3ff2a60d930e76df5 Mon Sep 17 00:00:00 2001 From: test1 Date: Sat, 9 Nov 2024 18:06:27 +0900 Subject: [PATCH 49/56] =?UTF-8?q?fix=20:=20test=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/userInfo/userInformationServiceTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java index 9ed8b785..cf52afa7 100644 --- a/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java +++ b/src/test/java/team18/team18_be/userInfo/userInformationServiceTest.java @@ -6,6 +6,8 @@ import static org.mockito.Mockito.when; import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; import java.util.NoSuchElementException; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -86,11 +88,13 @@ public void testCreateCompany() { @Test public void testFindCompany() { //given - when(companyRepository.findByUser(employer)).thenReturn(Optional.of(company)); + List comapnys = new ArrayList<>(); + comapnys.add(company); + when(companyRepository.findByUser(employer)).thenReturn(Optional.of(comapnys)); //when - CompanyResponse companyResponse = userInformationService.findCompany(employer); + List companyResponse = userInformationService.findCompany(employer); //then - assertEquals(company.getId(), companyResponse.CompanyId()); + assertEquals(company.getId(), companyResponse.get(0).companyId()); } @Test From 2d09e78886fec8912d9a47f35a41aeb0a8d41873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Sat, 9 Nov 2024 18:16:47 +0900 Subject: [PATCH 50/56] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20API?= =?UTF-8?q?=EA=B0=80=20=ED=94=84=EB=A1=A0=ED=8A=B8=EC=97=94=EB=93=9C?= =?UTF-8?q?=EC=9D=98=20=EB=A1=9C=EC=BB=AC=20=ED=99=98=EA=B2=BD=EA=B3=BC=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C?= =?UTF-8?q?=EC=9D=98=20=EC=9A=94=EC=B2=AD=EC=97=90=20=EB=91=98=20=EB=8B=A4?= =?UTF-8?q?=20=EB=8C=80=EC=9D=91=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/RecruitmentMapperImpl.java | 4 ++-- .../resume/mapper/ResumeMapperImpl.java | 2 +- .../auth/controller/AuthController.java | 8 +++++-- .../team18_be/auth/service/AuthService.java | 24 +++++++++++++++---- .../team18/team18_be/config/CorsConfig.java | 11 +++++---- .../config/property/GoogleProperty.java | 3 ++- .../team18_be/exception/ErrorMessage.java | 3 ++- .../exception/GlobalExceptionHandler.java | 7 ++++++ .../resume/service/ResumeService.java | 2 +- .../controller/UserInformationController.java | 3 ++- .../apply/service/applyServiceTest.java | 2 +- .../auth/service/AuthServiceTest.java | 14 +++++++---- 12 files changed, 60 insertions(+), 23 deletions(-) diff --git a/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java b/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java index f87f0396..93bc3f89 100644 --- a/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java +++ b/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java @@ -11,7 +11,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-11-03T19:16:36+0900", + date = "2024-11-08T17:16:00+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)" ) @Component @@ -60,7 +60,7 @@ public RecruitmentResponse toRecruitmentResponse(Recruitment recruitment, Recrui String vietnameseTitle = null; String companySize = null; String area = null; - String salary = null; + Long salary = null; String workDuration = null; String workDays = null; String workType = null; diff --git a/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java b/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java index e7268abd..006af9e9 100644 --- a/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java +++ b/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java @@ -10,7 +10,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-11-03T19:16:36+0900", + date = "2024-11-08T17:16:00+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)" ) @Component diff --git a/src/main/java/team18/team18_be/auth/controller/AuthController.java b/src/main/java/team18/team18_be/auth/controller/AuthController.java index e21e4f25..1199b94e 100644 --- a/src/main/java/team18/team18_be/auth/controller/AuthController.java +++ b/src/main/java/team18/team18_be/auth/controller/AuthController.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; @@ -47,9 +48,12 @@ public AuthController(AuthService authService) { @ApiResponse(responseCode = "500", description = "서버 내부 에러", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class))) }) @PostMapping("/oauth") - public ResponseEntity login(@RequestBody CodeRequest codeRequest) { + public ResponseEntity login(@RequestBody CodeRequest codeRequest, + HttpServletRequest request) { + String referer = request.getHeader("Referer"); + OAuthJwtResponse oAuthJwtResponse = authService.getOAuthToken(codeRequest, - GOOGLE_TOKEN_URI); + GOOGLE_TOKEN_URI, referer); LoginResponse loginResponse = authService.registerOAuth(oAuthJwtResponse, GOOGLE_USER_INFO_URI); diff --git a/src/main/java/team18/team18_be/auth/service/AuthService.java b/src/main/java/team18/team18_be/auth/service/AuthService.java index 8c272a31..0650c433 100644 --- a/src/main/java/team18/team18_be/auth/service/AuthService.java +++ b/src/main/java/team18/team18_be/auth/service/AuthService.java @@ -43,6 +43,7 @@ public class AuthService { public static final String AUTHORIZATION = "Authorization"; public static final String BEARER = "Bearer "; public static final String ACCESS_TOKEN = "access_token"; + public static final String LOCALHOST = "localhost"; private final AuthRepository authRepository; private final GoogleProperty googleProperty; private final RestClient restClient = RestClient.builder().build(); @@ -55,8 +56,10 @@ public AuthService(AuthRepository authRepository, GoogleProperty googleProperty) this.googleProperty = googleProperty; } - public OAuthJwtResponse getOAuthToken(CodeRequest codeRequest, String externalApiUri) { - LinkedMultiValueMap requestBody = getRequestBody(codeRequest); + public OAuthJwtResponse getOAuthToken(CodeRequest codeRequest, String externalApiUri, + String referer) { + validateReferer(referer); + LinkedMultiValueMap requestBody = getRequestBody(codeRequest, referer); ResponseEntity response = restClient.post() .uri(URI.create(externalApiUri)) @@ -111,13 +114,20 @@ public void registerUserType(UserTypeRequest userTypeRequest, User user) { authRepository.save(user.updateUserType(userTypeRequest.type())); } - private LinkedMultiValueMap getRequestBody(CodeRequest codeRequest) { + private LinkedMultiValueMap getRequestBody(CodeRequest codeRequest, + String referer) { LinkedMultiValueMap requestBody = new LinkedMultiValueMap<>(); requestBody.add(AUTHORIZATION_CODE, codeRequest.code()); requestBody.add(CLIENT_ID, googleProperty.clientId()); requestBody.add(CLIENT_SECRET, googleProperty.clientSecret()); - requestBody.add(REDIRECT_URI, googleProperty.redirectUri()); requestBody.add(GRANT_TYPE, googleProperty.grantType()); + + if (referer.contains(LOCALHOST)) { + requestBody.add(REDIRECT_URI, googleProperty.redirectUriLocal()); + } else { + requestBody.add(REDIRECT_URI, googleProperty.redirectUriProd()); + } + return requestBody; } @@ -139,4 +149,10 @@ private String getAccessToken(User user) { .signWith(key) .compact(); } + + private void validateReferer(String referer) { + if (referer == null) { + throw new IllegalCallerException(ErrorMessage.NOT_FOUND_REFERER_IN_HEADER.getErrorMessage()); + } + } } diff --git a/src/main/java/team18/team18_be/config/CorsConfig.java b/src/main/java/team18/team18_be/config/CorsConfig.java index 5d8bb854..59497ad1 100644 --- a/src/main/java/team18/team18_be/config/CorsConfig.java +++ b/src/main/java/team18/team18_be/config/CorsConfig.java @@ -9,15 +9,18 @@ @Configuration public class CorsConfig implements WebMvcConfigurer { - @Value("${front.origin}") - private String FRONT_ORIGIN; + @Value("${front.origin-local}") + private String FRONT_ORIGIN_LOCAL; + + @Value("${front.origin-prod}") + private String FRONT_ORIGIN_PROD; @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") - .allowedOrigins(FRONT_ORIGIN) + .allowedOrigins(FRONT_ORIGIN_LOCAL, FRONT_ORIGIN_PROD) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") - .allowedHeaders("Authorization", "Content-Type") + .allowedHeaders("Authorization", "Content-Type", "Referer") .exposedHeaders(HttpHeaders.LOCATION, HttpHeaders.AUTHORIZATION) .allowCredentials(true) .maxAge(1800); diff --git a/src/main/java/team18/team18_be/config/property/GoogleProperty.java b/src/main/java/team18/team18_be/config/property/GoogleProperty.java index 858c77a4..54db6611 100644 --- a/src/main/java/team18/team18_be/config/property/GoogleProperty.java +++ b/src/main/java/team18/team18_be/config/property/GoogleProperty.java @@ -6,7 +6,8 @@ public record GoogleProperty( String clientId, String clientSecret, - String redirectUri, + String redirectUriLocal, + String redirectUriProd, String grantType ) { diff --git a/src/main/java/team18/team18_be/exception/ErrorMessage.java b/src/main/java/team18/team18_be/exception/ErrorMessage.java index fa9f0959..fc2aa157 100644 --- a/src/main/java/team18/team18_be/exception/ErrorMessage.java +++ b/src/main/java/team18/team18_be/exception/ErrorMessage.java @@ -7,7 +7,8 @@ public enum ErrorMessage { GOOGLE_OAUTH_USER_INFO_ERROR_MESSAGE("구글 유저 정보 조회 중 에러가 발생하였습니다."), OBJECT_MAPPER_ERROR_MESSAGE("JSON 파싱 오류가 발생하였습니다."), NOT_FOUND_ACCESS_TOKEN_ERROR_MESSAGE("요청에 액세스 토큰이 존재하지 않습니다."), - ACCESS_TOKEN_EXPIRED_ERROR_MESSAGE("액세스 토큰이 만료되었습니다."); + ACCESS_TOKEN_EXPIRED_ERROR_MESSAGE("액세스 토큰이 만료되었습니다."), + NOT_FOUND_REFERER_IN_HEADER("헤더에 Referer가 없습니다."); private final String errorMessage; diff --git a/src/main/java/team18/team18_be/exception/GlobalExceptionHandler.java b/src/main/java/team18/team18_be/exception/GlobalExceptionHandler.java index cd57ed4e..54ddab8e 100644 --- a/src/main/java/team18/team18_be/exception/GlobalExceptionHandler.java +++ b/src/main/java/team18/team18_be/exception/GlobalExceptionHandler.java @@ -73,4 +73,11 @@ public ResponseEntity handleFileDownloadException( ExceptionResponse exceptionResponse = new ExceptionResponse(e.getMessage()); return new ResponseEntity<>(exceptionResponse, HttpStatus.NOT_FOUND); } + + @ExceptionHandler(value = IllegalCallerException.class) + public ResponseEntity handleIllegalCallerException( + IllegalCallerException e) { + ExceptionResponse exceptionResponse = new ExceptionResponse(e.getMessage()); + return new ResponseEntity<>(exceptionResponse, HttpStatus.BAD_REQUEST); + } } diff --git a/src/main/java/team18/team18_be/resume/service/ResumeService.java b/src/main/java/team18/team18_be/resume/service/ResumeService.java index 16e5b968..636b9afb 100644 --- a/src/main/java/team18/team18_be/resume/service/ResumeService.java +++ b/src/main/java/team18/team18_be/resume/service/ResumeService.java @@ -46,7 +46,7 @@ public ResumeAndApplyResponse findResumeById(Long resumeId, Long applyId) { .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); ApplicationForm applicationForm = applicationFormRepository.findByApply(apply) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 존재하지 않습니다.")); - return resumeMapper.toResumeAndApplyResponse(resume,applicationForm.getMotivation()); + return resumeMapper.toResumeAndApplyResponse(resume, applicationForm.getMotivation()); } } 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 6e62c40d..322e8ca5 100644 --- a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java +++ b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java @@ -55,7 +55,8 @@ public ResponseEntity findSign(@LoginUser User user) { @Operation(summary = "회사등록") @PostMapping(value = "/company", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity createCompany(@RequestPart("companyRequest") String companyRequestJson, + public ResponseEntity createCompany( + @RequestPart("companyRequest") String companyRequestJson, @RequestPart MultipartFile logoImage, @LoginUser User user) { System.out.println(companyRequestJson); ObjectMapper objectMapper = new ObjectMapper(); diff --git a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java index 6b71f975..c7d98537 100644 --- a/src/test/java/team18/team18_be/apply/service/applyServiceTest.java +++ b/src/test/java/team18/team18_be/apply/service/applyServiceTest.java @@ -82,7 +82,7 @@ public void setUp() { public void testCreateApplicationForm() { // Given ApplicationFormRequest request = new ApplicationFormRequest("홍길동", "123 Street", - "01012345678","my_motivation"); + "01012345678", "my_motivation"); Long recruitmentId = 1L; when(applyRepository.save(any(Apply.class))).thenReturn( diff --git a/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java b/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java index 572eee6b..f6c05bf5 100644 --- a/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java +++ b/src/test/java/team18/team18_be/auth/service/AuthServiceTest.java @@ -49,7 +49,8 @@ class AuthServiceTest { static final String APPLICATION_TEST_PROPERTIES = "application-test.properties"; static final String OAUTH_GOOGLE_CLIENT_ID = "oauth.google.client-id"; static final String OAUTH_GOOGLE_CLIENT_SECRET = "oauth.google.client-secret"; - static final String OAUTH_GOOGLE_REDIRECT_URI = "oauth.google.redirect-uri"; + static final String OAUTH_GOOGLE_REDIRECT_URI_LOCAL = "oauth.google.redirect-uri-local"; + static final String OAUTH_GOOGLE_REDIRECT_URI_PROD = "oauth.google.redirect-uri-prod"; static final String OAUTH_GOOGLE_GRANT_TYPE = "oauth.google.grant-type"; static final String JWT_SECRET = "jwt.secret"; static final String SECRET_KEY = "SECRET_KEY"; @@ -61,6 +62,8 @@ class AuthServiceTest { static final String AUTHORIZATION_CODE = "authorization_code"; static final String OAUTH_ACCESS_TOKEN = "access_token"; + static final String REFERER = "referer"; + @InjectMocks AuthService authService; @@ -94,14 +97,15 @@ class AuthServiceTest { String clientId = properties.getProperty(OAUTH_GOOGLE_CLIENT_ID); String clientSecert = properties.getProperty(OAUTH_GOOGLE_CLIENT_SECRET); - String redirectUri = properties.getProperty(OAUTH_GOOGLE_REDIRECT_URI); + String redirectUriLocal = properties.getProperty(OAUTH_GOOGLE_REDIRECT_URI_LOCAL); + String redirectUriProd = properties.getProperty(OAUTH_GOOGLE_REDIRECT_URI_PROD); String grantType = properties.getProperty(OAUTH_GOOGLE_GRANT_TYPE); String secretKey = properties.getProperty(JWT_SECRET); ReflectionTestUtils.setField(authService, SECRET_KEY, secretKey); ReflectionTestUtils.setField(authService, GOOGLE_PROPERTY, - new GoogleProperty(clientId, clientSecert, redirectUri, grantType)); + new GoogleProperty(clientId, clientSecert, redirectUriLocal, redirectUriProd, grantType)); } @BeforeEach @@ -139,7 +143,7 @@ class AuthServiceTest { CodeRequest codeRequest = new CodeRequest(AUTHORIZATION_CODE); // when - OAuthJwtResponse response = authService.getOAuthToken(codeRequest, mockServerUri); + OAuthJwtResponse response = authService.getOAuthToken(codeRequest, mockServerUri, REFERER); // then assertThat(response.accessToken()).isEqualTo(OAUTH_ACCESS_TOKEN); @@ -153,7 +157,7 @@ class AuthServiceTest { CodeRequest codeRequest = new CodeRequest(AUTHORIZATION_CODE); // when, then - assertThatThrownBy(() -> authService.getOAuthToken(codeRequest, mockUri)).isInstanceOf( + assertThatThrownBy(() -> authService.getOAuthToken(codeRequest, mockUri, REFERER)).isInstanceOf( OAuthLoginFailedException.class); } From 013d152444737500f0910609608cbbf68e91f838 Mon Sep 17 00:00:00 2001 From: test1 Date: Sun, 10 Nov 2024 12:46:27 +0900 Subject: [PATCH 51/56] =?UTF-8?q?feat=20:=20=ED=95=84=EC=88=98=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=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 145e9e1f..b1ae8003 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 4dc2c4d5..a1e7a9a9 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 322e8ca5..37de4dab 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 { From 1ff34db51c98da47bcf16c983d149eaad1dac7f3 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:06:29 +0900 Subject: [PATCH 52/56] =?UTF-8?q?fix=20:=20Lob=20colum=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team18/team18_be/resume/entity/Resume.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/team18/team18_be/resume/entity/Resume.java b/src/main/java/team18/team18_be/resume/entity/Resume.java index 37050774..f75bca80 100644 --- a/src/main/java/team18/team18_be/resume/entity/Resume.java +++ b/src/main/java/team18/team18_be/resume/entity/Resume.java @@ -1,5 +1,6 @@ package team18.team18_be.resume.entity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -25,6 +26,7 @@ public class Resume { private String career; private String korean; @Lob + @Column(columnDefinition = "TEXT") private String selfIntroduction; @ManyToOne From e2e4e19b999ec2a070a54d181ddbd06fcc7509e5 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:07:50 +0900 Subject: [PATCH 53/56] =?UTF-8?q?fix=20:=20Lob=20colum=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team18_be/recruitment/entity/RecruitmentContent.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/team18/team18_be/recruitment/entity/RecruitmentContent.java b/src/main/java/team18/team18_be/recruitment/entity/RecruitmentContent.java index 0cfed7d4..51048dae 100644 --- a/src/main/java/team18/team18_be/recruitment/entity/RecruitmentContent.java +++ b/src/main/java/team18/team18_be/recruitment/entity/RecruitmentContent.java @@ -1,5 +1,6 @@ package team18.team18_be.recruitment.entity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -13,8 +14,10 @@ public class RecruitmentContent { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long resumeContentId; @Lob + @Column(columnDefinition = "TEXT") private String koreanDetailedDescription; @Lob + @Column(columnDefinition = "TEXT") private String vietnameseDetailedDescription; public RecruitmentContent(String koreanDetailedDescription, From e35cc365a2127fddb4f268b3c442810db7bdf7a0 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:10:27 +0900 Subject: [PATCH 54/56] =?UTF-8?q?fix=20:=20swagger=20doc=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecruitmentController.java | 20 +++++++++---------- .../resume/controller/ResumeController.java | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java index 3f11bde8..a07b81f3 100644 --- a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java +++ b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java @@ -1,8 +1,8 @@ package team18.team18_be.recruitment.controller; import com.fasterxml.jackson.core.JsonProcessingException; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -23,7 +23,7 @@ import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; import team18.team18_be.recruitment.service.RecruitmentService; -@Api(tags = {"구인글 관련 Controller"}) +@Tag(name = "구인글 관련 Controller") @RestController @RequestMapping("/api/recruitments") public class RecruitmentController { @@ -34,7 +34,7 @@ public RecruitmentController(RecruitmentService recruitmentService) { this.recruitmentService = recruitmentService; } - @ApiOperation(value = "구인글 저장 메서드") + @Operation(summary = "구인글 저장 메서드") @PostMapping public ResponseEntity saveRecruitment( @RequestBody RecruitmentRequest recruitmentRequest, @@ -44,7 +44,7 @@ public ResponseEntity saveRecruitment( return ResponseEntity.status(HttpStatus.CREATED).build(); } - @ApiOperation(value = "구인글 전체 조회 메서드") + @Operation(summary = "구인글 전체 조회 메서드") @GetMapping public ResponseEntity> getAllRecruitments( @RequestParam int page @@ -54,7 +54,7 @@ public ResponseEntity> getAllRecruitments( return ResponseEntity.ok().body(recruitmentService.getAllRecruitment(pageable)); } - @ApiOperation(value = "구인글id로 조회 메서드") + @Operation(summary = "구인글id로 조회 메서드") @GetMapping("/{postId}") public ResponseEntity getRecruitments( @PathVariable Long postId @@ -63,7 +63,7 @@ public ResponseEntity getRecruitments( .body(recruitmentService.getRecruitmentResponseByRecruitmentId(postId)); } - @ApiOperation(value = "회사 별 구인글 조회 메서드") + @Operation(summary = "회사 별 구인글 조회 메서드") @GetMapping("/company/{companyId}") public ResponseEntity> getAllRecruitmentByCompanyId( @PathVariable Long companyId @@ -72,7 +72,7 @@ public ResponseEntity> getAllRecruitmentByCo .body(recruitmentService.getRecruitmentResponseByCompanyId(companyId)); } - @ApiOperation(value = "구인글 마감 메서드") + @Operation(summary = "구인글 마감 메서드") @GetMapping("/hiringClose/{recruitmentId}") public ResponseEntity setRecruitmentHiringFalse( @PathVariable Long recruitmentId @@ -81,7 +81,7 @@ public ResponseEntity setRecruitmentHiringFalse( return ResponseEntity.ok().build(); } - @ApiOperation(value = "최근 올라온 구인글 순서대로 정렬") + @Operation(summary = "최근 올라온 구인글 순서대로 정렬") @GetMapping("/latestRegistration") public ResponseEntity> getAllRecruitmentsLatestRegistration( @RequestParam int page @@ -91,7 +91,7 @@ public ResponseEntity> getAllRecruitmentsLate return ResponseEntity.ok().body(recruitmentService.getAllRecruitmentAndSortByDate(pageable)); } - @ApiOperation(value = "급여 높은 순서대로 정리해서 전체 구인글 반환하는 메서드") + @Operation(summary = "급여 높은 순서대로 정리해서 전체 구인글 반환하는 메서드") @GetMapping("/salary") public ResponseEntity> getAllRecruitmentsSalary( @RequestParam int page diff --git a/src/main/java/team18/team18_be/resume/controller/ResumeController.java b/src/main/java/team18/team18_be/resume/controller/ResumeController.java index 4d969dba..584799e0 100644 --- a/src/main/java/team18/team18_be/resume/controller/ResumeController.java +++ b/src/main/java/team18/team18_be/resume/controller/ResumeController.java @@ -1,7 +1,7 @@ package team18.team18_be.resume.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -17,7 +17,7 @@ import team18.team18_be.resume.dto.response.ResumeResponse; import team18.team18_be.resume.service.ResumeService; -@Api(tags = {"이력서 관련 Controller"}) +@Tag(name = "이력서 관련 Controller") @RestController @RequestMapping("/api/resumes") public class ResumeController { @@ -28,7 +28,7 @@ public ResumeController(ResumeService resumeService) { this.resumeService = resumeService; } - @ApiOperation(value = "이력서 저장 메서드") + @Operation(summary = "이력서 저장 메서드") @PostMapping public ResponseEntity saveResume( @RequestBody ResumeRequest resumeRequest, @@ -38,7 +38,7 @@ public ResponseEntity saveResume( return new ResponseEntity<>(HttpStatus.CREATED); } - @ApiOperation(value = "구직자 별 이력서 조회 메서드") + @Operation(summary = "구직자 별 이력서 조회 메서드") @GetMapping public ResponseEntity getResume( @LoginUser User user @@ -46,7 +46,7 @@ public ResponseEntity getResume( return ResponseEntity.ok().body(resumeService.findResumeByEmployee(user)); } - @ApiOperation(value = "이력서 id로 이력서 조회 메서드") + @Operation(summary = "이력서 id로 이력서 조회 메서드") @GetMapping("/{resumeId}/{applyId}") public ResponseEntity getResumeById( @PathVariable Long resumeId, From 4904be1a500dced59996f00bfc6bb10bfda19749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=B0=EB=AF=BC=EC=88=98?= Date: Sun, 10 Nov 2024 20:49:56 +0900 Subject: [PATCH 55/56] =?UTF-8?q?fix:=20swagger=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20=EB=B0=8F=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - .../mapper/RecruitmentMapperImpl.java | 2 +- .../resume/mapper/ResumeMapperImpl.java | 2 +- .../apply/dto/response/MandatoryResponse.java | 2 +- .../team18_be/apply/service/ApplyService.java | 10 ++--- .../config/swagger/SwaggerConfig.java | 39 ------------------- 6 files changed, 7 insertions(+), 49 deletions(-) diff --git a/build.gradle b/build.gradle index 804733b7..84cb2173 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,6 @@ dependencies { runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6' runtimeOnly 'com.h2database:h2' implementation 'jakarta.validation:jakarta.validation-api:3.0.2' - implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13.2' implementation group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.13' diff --git a/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java b/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java index 93bc3f89..85dda104 100644 --- a/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java +++ b/src/main/generated/team18/team18_be/recruitment/mapper/RecruitmentMapperImpl.java @@ -11,7 +11,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-11-08T17:16:00+0900", + date = "2024-11-10T20:46:08+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)" ) @Component diff --git a/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java b/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java index 006af9e9..b4977b59 100644 --- a/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java +++ b/src/main/generated/team18/team18_be/resume/mapper/ResumeMapperImpl.java @@ -10,7 +10,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-11-08T17:16:00+0900", + date = "2024-11-10T20:46:08+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)" ) @Component 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 b1ae8003..6b4e8dd5 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 signExistence) { + 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 a1e7a9a9..fc06ffa1 100644 --- a/src/main/java/team18/team18_be/apply/service/ApplyService.java +++ b/src/main/java/team18/team18_be/apply/service/ApplyService.java @@ -2,7 +2,6 @@ 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 +20,6 @@ import team18.team18_be.resume.entity.Resume; 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; @@ -42,14 +39,15 @@ public class ApplyService { public ApplyService(ApplicationFormRepository applicationFormRepository, ApplyRepository applyRepository, RecruitmentRepository recruitmentRepository, ResumeRepository resumeRepository, CompanyRepository companyRepository, - ForeignerInformationRepository foreignerInformationRepository,SignRepository signRepository) { + 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; + this.signRepository = signRepository; } public Long createApplicationForm(ApplicationFormRequest applicationFormRequest, @@ -127,7 +125,7 @@ public MandatoryResponse checkMandatory(User user) { boolean signExistence = signRepository.findByUser(user).isPresent(); MandatoryResponse mandatoryResponse = new MandatoryResponse(resumeExistence, visaExistence, - foreignerIdNumberExistence,signExistence); + foreignerIdNumberExistence, signExistence); return mandatoryResponse; } diff --git a/src/main/java/team18/team18_be/config/swagger/SwaggerConfig.java b/src/main/java/team18/team18_be/config/swagger/SwaggerConfig.java index e699c4eb..8eedd9f1 100644 --- a/src/main/java/team18/team18_be/config/swagger/SwaggerConfig.java +++ b/src/main/java/team18/team18_be/config/swagger/SwaggerConfig.java @@ -4,15 +4,10 @@ import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.HeaderParameter; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme.In; import io.swagger.v3.oas.models.security.SecurityScheme.Type; -import java.util.Set; -import org.springdoc.core.customizers.OpenApiCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -38,38 +33,4 @@ public OpenAPI api() { .components(new Components().addSecuritySchemes("Bearer Token", apiKey)) .addSecurityItem(securityRequirement); } - - @Bean - public OpenApiCustomizer customAuthParameter() { - Set targetPaths = Set.of( - "/api/register" - ); - - return openApi -> openApi - .getPaths() - .forEach((path, pathItem) -> { - boolean isTargetPath = false; - for (String targetPath : targetPaths) { - if (path.startsWith(targetPath)) { - isTargetPath = true; - break; - } - } - - if (isTargetPath) { - pathItem.readOperations().forEach( - this::addAuthParam - ); - } - }); - } - - private void addAuthParam(Operation operation) { - operation.addParametersItem(new HeaderParameter() - .name("Authorization") - .description("액세스 토큰") - .required(true) - .schema(new StringSchema())); - } - } From 047ef5bedec181c99040fb7088d37666da3512f5 Mon Sep 17 00:00:00 2001 From: Minji Kim <101392857+alsswl@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:16:23 +0900 Subject: [PATCH 56/56] =?UTF-8?q?fix=20:=20pageable=EC=97=90=20totalpage?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecruitmentController.java | 7 ++- .../recruitment/dto/response/PageDto.java | 7 +++ .../dto/response/RecruitmentAllResponse.java | 10 +++ .../service/RecruitmentService.java | 63 +++++++++++-------- 4 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java create mode 100644 src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java diff --git a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java index a07b81f3..32f759f5 100644 --- a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java +++ b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java @@ -18,6 +18,7 @@ import team18.team18_be.auth.entity.User; import team18.team18_be.config.resolver.LoginUser; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.dto.response.RecruitmentAllResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponseForCompany; import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; @@ -46,7 +47,7 @@ public ResponseEntity saveRecruitment( @Operation(summary = "구인글 전체 조회 메서드") @GetMapping - public ResponseEntity> getAllRecruitments( + public ResponseEntity getAllRecruitments( @RequestParam int page ) { int fixedPageSize = 4; @@ -83,7 +84,7 @@ public ResponseEntity setRecruitmentHiringFalse( @Operation(summary = "최근 올라온 구인글 순서대로 정렬") @GetMapping("/latestRegistration") - public ResponseEntity> getAllRecruitmentsLatestRegistration( + public ResponseEntity getAllRecruitmentsLatestRegistration( @RequestParam int page ) { int fixedPageSize = 4; @@ -93,7 +94,7 @@ public ResponseEntity> getAllRecruitmentsLate @Operation(summary = "급여 높은 순서대로 정리해서 전체 구인글 반환하는 메서드") @GetMapping("/salary") - public ResponseEntity> getAllRecruitmentsSalary( + public ResponseEntity getAllRecruitmentsSalary( @RequestParam int page ) { int fixedPageSize = 4; diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java b/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java new file mode 100644 index 00000000..e127c500 --- /dev/null +++ b/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java @@ -0,0 +1,7 @@ +package team18.team18_be.recruitment.dto.response; + +public record PageDto( + Integer totalPage +) { + +} diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java new file mode 100644 index 00000000..90beb638 --- /dev/null +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java @@ -0,0 +1,10 @@ +package team18.team18_be.recruitment.dto.response; + +import java.util.List; + +public record RecruitmentAllResponse( + List content, + PageDto pageable +) { + +} diff --git a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java index 7ae0e7e7..9ae60ca2 100644 --- a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java +++ b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java @@ -10,6 +10,8 @@ import org.springframework.stereotype.Service; import team18.team18_be.config.infrastructure.OpenAiService; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.dto.response.PageDto; +import team18.team18_be.recruitment.dto.response.RecruitmentAllResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponseForCompany; import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; @@ -58,9 +60,10 @@ public void saveRecruitment(RecruitmentRequest recruitmentRequest) } - public List getAllRecruitment(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitment(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrue(pageable); - return recruitments.stream() + List recruitmentSummationResponseList = + recruitments.stream() .map(recruitment -> new RecruitmentSummationResponse( recruitment.getRecruitmentId(), recruitment.getCompany().getLogoImage(), @@ -71,38 +74,46 @@ public List getAllRecruitment(Pageable pageable) { recruitment.getArea() )) .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } - public List getAllRecruitmentAndSortBySalary(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitmentAndSortBySalary(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrueOrderBySalaryDesc( pageable); - return recruitments.stream() - .map(recruitment -> new RecruitmentSummationResponse( - recruitment.getRecruitmentId(), - recruitment.getCompany().getLogoImage(), - recruitment.getKoreanTitle(), - recruitment.getVietnameseTitle(), - recruitment.getCompanyName(), - recruitment.getSalary(), - recruitment.getArea() - )) - .collect(Collectors.toList()); + List recruitmentSummationResponseList = + recruitments.stream() + .map(recruitment -> new RecruitmentSummationResponse( + recruitment.getRecruitmentId(), + recruitment.getCompany().getLogoImage(), + recruitment.getKoreanTitle(), + recruitment.getVietnameseTitle(), + recruitment.getCompanyName(), + recruitment.getSalary(), + recruitment.getArea() + )) + .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } - public List getAllRecruitmentAndSortByDate(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitmentAndSortByDate(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrueOrderByUploadDateDesc( pageable); - return recruitments.stream() - .map(recruitment -> new RecruitmentSummationResponse( - recruitment.getRecruitmentId(), - recruitment.getCompany().getLogoImage(), - recruitment.getKoreanTitle(), - recruitment.getVietnameseTitle(), - recruitment.getCompanyName(), - recruitment.getSalary(), - recruitment.getArea() - )) - .collect(Collectors.toList()); + List recruitmentSummationResponseList = + recruitments.stream() + .map(recruitment -> new RecruitmentSummationResponse( + recruitment.getRecruitmentId(), + recruitment.getCompany().getLogoImage(), + recruitment.getKoreanTitle(), + recruitment.getVietnameseTitle(), + recruitment.getCompanyName(), + recruitment.getSalary(), + recruitment.getArea() + )) + .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } public RecruitmentResponse getRecruitmentResponseByRecruitmentId(Long userId) {