From 39a221c0d8d0b115826dba30d0cdf8a0f954ef11 Mon Sep 17 00:00:00 2001 From: dgjinsu Date: Fri, 16 Feb 2024 15:11:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=BC=EC=9E=90=EB=A6=AC=20=EC=A0=9C?= =?UTF-8?q?=EC=95=88=20api=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeadHuntingCompanyController.java | 9 ++++---- .../company/offer/OfferJobPostRequest.java | 18 +++++++++++++++ .../company/{ => offer}/OfferRequest.java | 8 ++++--- .../SelectOfferJobPostResponse.java | 2 +- .../service/HeadHuntingCompanyService.java | 22 ++++++++++++++++--- .../service/NotificationService.java | 2 +- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferJobPostRequest.java rename src/main/java/jikgong/domain/headHunting/dtos/company/{ => offer}/OfferRequest.java (63%) rename src/main/java/jikgong/domain/headHunting/dtos/company/{ => offer}/SelectOfferJobPostResponse.java (96%) diff --git a/src/main/java/jikgong/domain/headHunting/controller/HeadHuntingCompanyController.java b/src/main/java/jikgong/domain/headHunting/controller/HeadHuntingCompanyController.java index 25c2605..719048a 100644 --- a/src/main/java/jikgong/domain/headHunting/controller/HeadHuntingCompanyController.java +++ b/src/main/java/jikgong/domain/headHunting/controller/HeadHuntingCompanyController.java @@ -2,7 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import jikgong.domain.headHunting.dtos.company.HeadHuntingListResponse; -import jikgong.domain.headHunting.dtos.company.SelectOfferJobPostResponse; +import jikgong.domain.headHunting.dtos.company.offer.OfferRequest; +import jikgong.domain.headHunting.dtos.company.offer.SelectOfferJobPostResponse; import jikgong.domain.headHunting.dtos.company.WorkerInfoResponse; import jikgong.domain.headHunting.entity.SortType; import jikgong.domain.headHunting.service.HeadHuntingCompanyService; @@ -59,10 +60,10 @@ public ResponseEntity findAvailableJobPosts(@AuthenticationPrincipal P } @Operation(summary = "기업: 일자리 제안 하기") - @PostMapping("/api/head-hunting/offer/{memberId}") + @PostMapping("/api/head-hunting/offer") public ResponseEntity offerJobPost(@AuthenticationPrincipal PrincipalDetails principalDetails, - @PathVariable("memberId") Long memberId) { - headHuntingCompanyService.offerJobPost(principalDetails.getMember().getId(), memberId); + @RequestBody OfferRequest request) { + headHuntingCompanyService.offerJobPost(principalDetails.getMember().getId(), request); return ResponseEntity.ok(new Response("기업: 일자리 제안 완료")); } diff --git a/src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferJobPostRequest.java b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferJobPostRequest.java new file mode 100644 index 0000000..4ec6533 --- /dev/null +++ b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferJobPostRequest.java @@ -0,0 +1,18 @@ +package jikgong.domain.headHunting.dtos.company.offer; + +import io.swagger.v3.oas.annotations.media.Schema; +import jikgong.domain.workDate.entity.WorkDate; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.List; + +@NoArgsConstructor +@Getter +public class OfferJobPostRequest { + @Schema(description = "jobPostId", example = "1") + private Long jobPostId; + @Schema(description = "제안 날짜 목록", example = "[\"2024-02-01\", \"2024-02-02\"]") + private List workDateList; +} diff --git a/src/main/java/jikgong/domain/headHunting/dtos/company/OfferRequest.java b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferRequest.java similarity index 63% rename from src/main/java/jikgong/domain/headHunting/dtos/company/OfferRequest.java rename to src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferRequest.java index d33ffe3..1f9d5ea 100644 --- a/src/main/java/jikgong/domain/headHunting/dtos/company/OfferRequest.java +++ b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/OfferRequest.java @@ -1,15 +1,17 @@ -package jikgong.domain.headHunting.dtos.company; +package jikgong.domain.headHunting.dtos.company.offer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @Getter public class OfferRequest { @Schema(description = "memberId", example = "1") private Long memberId; - @Schema(description = "jobPostId", example = "1") - private Long jobPostId; + + private List offerJobPostRequest; } diff --git a/src/main/java/jikgong/domain/headHunting/dtos/company/SelectOfferJobPostResponse.java b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/SelectOfferJobPostResponse.java similarity index 96% rename from src/main/java/jikgong/domain/headHunting/dtos/company/SelectOfferJobPostResponse.java rename to src/main/java/jikgong/domain/headHunting/dtos/company/offer/SelectOfferJobPostResponse.java index b5ea222..81ca5fd 100644 --- a/src/main/java/jikgong/domain/headHunting/dtos/company/SelectOfferJobPostResponse.java +++ b/src/main/java/jikgong/domain/headHunting/dtos/company/offer/SelectOfferJobPostResponse.java @@ -1,4 +1,4 @@ -package jikgong.domain.headHunting.dtos.company; +package jikgong.domain.headHunting.dtos.company.offer; import jikgong.domain.jobPost.dtos.headhunting.JobPostListResponse; import jikgong.domain.jobPost.entity.JobPost; diff --git a/src/main/java/jikgong/domain/headHunting/service/HeadHuntingCompanyService.java b/src/main/java/jikgong/domain/headHunting/service/HeadHuntingCompanyService.java index b0e9255..351cb96 100644 --- a/src/main/java/jikgong/domain/headHunting/service/HeadHuntingCompanyService.java +++ b/src/main/java/jikgong/domain/headHunting/service/HeadHuntingCompanyService.java @@ -3,7 +3,9 @@ import jikgong.domain.apply.entity.Apply; import jikgong.domain.apply.repository.ApplyRepository; import jikgong.domain.headHunting.dtos.company.HeadHuntingListResponse; -import jikgong.domain.headHunting.dtos.company.SelectOfferJobPostResponse; +import jikgong.domain.headHunting.dtos.company.offer.OfferJobPostRequest; +import jikgong.domain.headHunting.dtos.company.offer.OfferRequest; +import jikgong.domain.headHunting.dtos.company.offer.SelectOfferJobPostResponse; import jikgong.domain.headHunting.dtos.company.WorkerInfoResponse; import jikgong.domain.headHunting.entity.HeadHunting; import jikgong.domain.headHunting.entity.SortType; @@ -13,6 +15,7 @@ import jikgong.domain.jobPost.repository.JobPostRepository; import jikgong.domain.member.entity.Member; import jikgong.domain.member.repository.MemberRepository; +import jikgong.domain.notification.entity.NotificationType; import jikgong.domain.notification.service.NotificationService; import jikgong.domain.project.entity.Project; import jikgong.domain.project.repository.ProjectRepository; @@ -54,12 +57,25 @@ public Page findHeadHuntingList(Long memberId, Long pro return headHuntingRepository.findHeadHuntingMemberList(project.getAddress(), tech, bound, sortType, pageable); } - public void offerJobPost(Long companyId, Long workerId) { + public void offerJobPost(Long companyId, OfferRequest request) { Member company = memberRepository.findById(companyId) .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); + List offerJobPostRequestList = request.getOfferJobPostRequest(); + for (OfferJobPostRequest offerJobPostRequest : offerJobPostRequestList) { + JobPost jobPost = jobPostRepository.findById(offerJobPostRequest.getJobPostId()) + .orElseThrow(() -> new CustomException(ErrorCode.JOB_POST_NOT_FOUND)); -// notificationService.saveNotification(workerId, NotificationType.OFFER, ); + String dateList = offerJobPostRequest.getWorkDateList().stream() + .map(date -> date.toString().substring(5, 10)) + .collect(Collectors.joining(", ")); + + // todo: 일자리 제안 메시지, url 변경 + String content = "[" + company.getPhone() + "] 에서 " + dateList + "에 일자리를 제안했습니다."; + String url = "test"; + + notificationService.saveNotification(request.getMemberId(), NotificationType.OFFER, content, url); + } } public WorkerInfoResponse findWorkerInfo(Long companyId, Long workerId, LocalDate selectMonth) { diff --git a/src/main/java/jikgong/domain/notification/service/NotificationService.java b/src/main/java/jikgong/domain/notification/service/NotificationService.java index 5cc7de5..b726012 100644 --- a/src/main/java/jikgong/domain/notification/service/NotificationService.java +++ b/src/main/java/jikgong/domain/notification/service/NotificationService.java @@ -42,6 +42,6 @@ public void saveNotification(Long receiverId, NotificationType type, String cont .title(content) .body(content) .build(); - fcmNotificationService.sendNotificationByToken(request); +// fcmNotificationService.sendNotificationByToken(request); } }