Skip to content

Commit

Permalink
feat: 일자리 제안 api 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjinsu committed Feb 16, 2024
1 parent 0c4488c commit 39a221c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,10 +60,10 @@ public ResponseEntity<Response> findAvailableJobPosts(@AuthenticationPrincipal P
}

@Operation(summary = "기업: 일자리 제안 하기")
@PostMapping("/api/head-hunting/offer/{memberId}")
@PostMapping("/api/head-hunting/offer")
public ResponseEntity<Response> 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("기업: 일자리 제안 완료"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<LocalDate> workDateList;
}
Original file line number Diff line number Diff line change
@@ -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> offerJobPostRequest;

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -54,12 +57,25 @@ public Page<HeadHuntingListResponse> 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<OfferJobPostRequest> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public void saveNotification(Long receiverId, NotificationType type, String cont
.title(content)
.body(content)
.build();
fcmNotificationService.sendNotificationByToken(request);
// fcmNotificationService.sendNotificationByToken(request);
}
}

0 comments on commit 39a221c

Please sign in to comment.