Skip to content

Commit

Permalink
feat: 특정 인부에게 출역 가능한 모집 공고 리스트 조회 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjinsu committed Feb 15, 2024
1 parent 51b24db commit 9284454
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.swagger.v3.oas.annotations.Operation;
import jikgong.domain.headHunting.dtos.HeadHuntingListResponse;
import jikgong.domain.headHunting.dtos.SelectOfferJobPostResponse;
import jikgong.domain.headHunting.dtos.WorkerInfoResponse;
import jikgong.domain.headHunting.entity.SortType;
import jikgong.domain.headHunting.service.HeadHuntingCompanyService;
Expand Down Expand Up @@ -53,7 +54,8 @@ public ResponseEntity<Response> findWorkerInfo(@AuthenticationPrincipal Principa
public ResponseEntity<Response> findAvailableJobPosts(@AuthenticationPrincipal PrincipalDetails principalDetails,
@RequestParam(name = "memberId") Long memberId,
@RequestParam(name = "projectId") Long projectId) {
headHuntingCompanyService.findAvailableJobPosts(principalDetails.getMember().getId(), memberId, projectId);
SelectOfferJobPostResponse selectOfferJobPostResponse = headHuntingCompanyService.findAvailableJobPosts(principalDetails.getMember().getId(), memberId, projectId);
return ResponseEntity.ok(new Response(selectOfferJobPostResponse, "기업: 출역 가능한 현장 목록 반환 완료"));
}

@Operation(summary = "기업: 일자리 제안 하기")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package jikgong.domain.headHunting.dtos;

import jikgong.domain.jobPost.dtos.headhunting.JobPostListResponse;
import jikgong.domain.jobPost.entity.JobPost;
import jikgong.domain.member.entity.Member;
import jikgong.domain.workDate.entity.WorkDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@AllArgsConstructor
@Getter
@Builder
public class SelectOfferJobPostResponse {
private String workerName;
private List<JobPostListResponse> jobPostListResponseList;

public static SelectOfferJobPostResponse from(List<JobPost> jobPostList, Member member, Set<LocalDate> cantWorkDateSet) {
List<JobPostListResponse> jobPostListResponseList = new ArrayList<>();

for (JobPost jobPost : jobPostList) {
List<LocalDate> availableDate = new ArrayList<>();
List<WorkDate> jobPostWorkDateList = jobPost.getWorkDateList();
for (WorkDate jobPostWorkDate : jobPostWorkDateList) {
// 노동자가 이미 일하는 날짜를 제외
if (!cantWorkDateSet.contains(jobPostWorkDate.getWorkDate())) {
availableDate.add(jobPostWorkDate.getWorkDate());
}
}
jobPostListResponseList.add(JobPostListResponse.from(jobPost, availableDate));
}

return SelectOfferJobPostResponse.builder()
.workerName(member.getWorkerInfo().getWorkerName())
.jobPostListResponseList(jobPostListResponseList)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jikgong.domain.apply.entity.Apply;
import jikgong.domain.apply.repository.ApplyRepository;
import jikgong.domain.headHunting.dtos.HeadHuntingListResponse;
import jikgong.domain.headHunting.dtos.SelectOfferJobPostResponse;
import jikgong.domain.headHunting.dtos.WorkerInfoResponse;
import jikgong.domain.headHunting.entity.HeadHunting;
import jikgong.domain.headHunting.entity.SortType;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void offerJobPost(Long companyId, Long workerId) {
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND));


notificationService.saveNotification(workerId, NotificationType.OFFER, );
// notificationService.saveNotification(workerId, NotificationType.OFFER, );
}

public WorkerInfoResponse findWorkerInfo(Long companyId, Long workerId, LocalDate selectMonth) {
Expand All @@ -82,7 +83,7 @@ public WorkerInfoResponse findWorkerInfo(Long companyId, Long workerId, LocalDat
return WorkerInfoResponse.from(headHunting, findCantWorkDate);
}

public void findAvailableJobPosts(Long companyId, Long workerId, Long projectId) {
public SelectOfferJobPostResponse findAvailableJobPosts(Long companyId, Long workerId, Long projectId) {
Member company = memberRepository.findById(companyId)
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND));

Expand All @@ -92,13 +93,14 @@ public void findAvailableJobPosts(Long companyId, Long workerId, Long projectId)
Project project = projectRepository.findById(projectId)
.orElseThrow(() -> new CustomException(ErrorCode.PROJECT_NOT_FOUND));

List<JobPost> jobPostList = jobPostRepository.findByProject(project.getId());

List<LocalDate> cantWorkDate = applyRepository.findAllCantWorkDate(worker.getId()).stream()
.map(apply -> apply.getWorkDate().getWorkDate())
.collect(Collectors.toList());

Set<LocalDate> cantWorkDateSet = new HashSet<>(cantWorkDate);
// todo: 이어서 개발 예정

List<JobPost> jobPostList = jobPostRepository.findByProject(project.getId());

return SelectOfferJobPostResponse.from(jobPostList, worker, cantWorkDateSet);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jikgong.domain.jobPost.dtos.headhunting;

import jikgong.domain.headHunting.dtos.SelectOfferJobPostResponse;
import jikgong.domain.jobPost.entity.JobPost;
import jikgong.domain.jobPost.entity.Tech;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

@AllArgsConstructor
@Getter
@Builder
public class JobPostListResponse {
private Long jobPostId;
private Tech tech; // 타입
private String title; // 모집 공고 제목
private List<LocalDate> availableDate; // 제안 가능 날짜
private LocalTime startTime; // 시작 시간
private LocalTime endTime; // 종료 시간
private Integer wage; // 임금

public static JobPostListResponse from(JobPost jobPost, List<LocalDate> availableDate) {
return JobPostListResponse.builder()
.jobPostId(jobPost.getId())
.tech(jobPost.getTech())
.title(jobPost.getTitle())
.availableDate(availableDate)
.startTime(jobPost.getStartTime())
.endTime(jobPost.getEndTime())
.wage(jobPost.getWage())
.build();
}
}

0 comments on commit 9284454

Please sign in to comment.