Skip to content

Commit

Permalink
Merge pull request #87 from WooRibound/feature/#34-enterprise
Browse files Browse the repository at this point in the history
[feat] #34 -기업 회원 관련 기능 수정 및 구현
  • Loading branch information
cshharry authored Nov 13, 2024
2 parents 23c78cd + 5dbc20b commit 6b07ffa
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.wooribound.api.corporate.dto.ApplicantsDTO;
import com.wooribound.api.corporate.dto.JobPostingReqDTO;
import com.wooribound.api.corporate.facade.EnterpriseJobPostingFacade;
import com.wooribound.domain.jobposting.dto.JobPostingDTO;
import com.wooribound.domain.jobposting.dto.JobPostingDetailDTO;
import com.wooribound.domain.jobposting.dto.JobPostingDetailProjection;
import com.wooribound.domain.resume.dto.ResumeDTO;
import com.wooribound.domain.userapply.dto.ApplicantResultReqDTO;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -57,6 +57,11 @@ public String setApplicantResult(@RequestBody ApplicantResultReqDTO applicantRes
return enterpriseJobPostingFacade.setApplicantResult(applicantResultReqDTO);
}

// 7. 공고별 지원자 추천 (헤드헌팅기능)
@GetMapping("/applicant-recommend")
public List<ApplicantsDTO> getApplicantRecommendation(@RequestParam int jobId) {
return enterpriseJobPostingFacade.getApplicantRecommendation(jobId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO) {
return entJobPostingService.setApplicantResult(applicantResultReqDTO);
}

// 6. 공고별 지원자 추천 (헤드헌팅기능)
public List<ApplicantsDTO> getApplicantRecommendation(int jobId) {
return entJobPostingService.getApplicantRecommendation(jobId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.wooribound.api.individual.dto.JobPostingProjection;
import com.wooribound.domain.jobposting.dto.JobPostingDetailProjection;
import com.wooribound.domain.wbuser.WbUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -81,4 +82,11 @@ List<JobPostingProjection> findJobPostingsNew(@Param("exJobs") List<String> exJo
@Modifying
@Query("UPDATE JobPosting jp SET jp.isDeleted = 'Y' WHERE jp.postId = :postId")
int updateIsDeletedByPostId(@Param("postId") Long postId);

// 6. 공고별 지원자 추천 (헤드헌팅기능)
@Query("SELECT w FROM WbUser w " +
"JOIN w.workHistories wh " +
"WHERE wh.job.jobId = :jobId " +
"ORDER BY w.jobPoint DESC")
List<WbUser> findApplicantRecommendation(@Param("jobId") int jobId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public interface EntJobPostingService {

// 5. 지원자 결과 설정
String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO);

// 6. 공고별 지원자 추천 (헤드헌팅기능)
List<ApplicantsDTO> getApplicantRecommendation(int jobId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
import com.wooribound.domain.jobposting.JobPostingRepository;
import com.wooribound.domain.jobposting.dto.JobPostingDetailDTO;
import com.wooribound.domain.jobposting.dto.JobPostingDetailProjection;
import com.wooribound.domain.notification.Notification;
import com.wooribound.domain.notification.NotificationRepository;
import com.wooribound.domain.userapply.UserApply;
import com.wooribound.domain.userapply.UserApplyRepository;
import com.wooribound.domain.userapply.dto.ApplicantResultReqDTO;
import com.wooribound.domain.wbuser.WbUser;
import com.wooribound.global.constant.ApplyResult;
import com.wooribound.global.constant.YN;
import com.wooribound.global.util.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
Expand All @@ -35,6 +39,7 @@ public class EntJobPostingServiceImpl implements EntJobPostingService {
private final JobRepository jobRepository;
private final EnterpriseRepository enterpriseRepository;
private final UserApplyRepository userApplyRepository;
private final NotificationRepository notificationRepository;
private final RedisUtil redisUtil;

// 1. 공고 등록
Expand All @@ -52,7 +57,7 @@ public String createJobPosting(JobPostingReqDTO jobPostingReqDTO) {
.startDate(jobPostingReqDTO.getStartDate())
.endDate(jobPostingReqDTO.getEndDate())
.build();

jobPostingRepository.save(jobPosting);
return "공고 등록이 완료되었습니다.";
}
Expand All @@ -70,16 +75,16 @@ public JobPostingDetailDTO getJobPostingDetail(Long postId) {
// log4j - 조회된 공고 상세 로그
logger.info("공고 상세 조회 결과 - ID: {}, Title: {}", jobPosting.getPostId(), jobPosting.getPostTitle());
return JobPostingDetailDTO.builder()
.postTitle(jobPosting.getPostTitle())
.entName(jobPosting.getEnterprise().getEntName())
.postImg(jobPosting.getPostImg())
.startDate(jobPosting.getStartDate())
.endDate(jobPosting.getEndDate())
// .postState(jobPosting.getPostState())
.jobName(jobPosting.getJob().getJobName())
.entAddr1(jobPosting.getEnterprise().getEntAddr1())
.entAddr2(jobPosting.getEnterprise().getEntAddr2())
.build();
.postTitle(jobPosting.getPostTitle())
.entName(jobPosting.getEnterprise().getEntName())
.postImg(jobPosting.getPostImg())
.startDate(jobPosting.getStartDate())
.endDate(jobPosting.getEndDate())
// .postState(jobPosting.getPostState())
.jobName(jobPosting.getJob().getJobName())
.entAddr1(jobPosting.getEnterprise().getEntAddr1())
.entAddr2(jobPosting.getEnterprise().getEntAddr2())
.build();
} else {
// 공고가 존재하지 않는 경우 예외 로그
logger.error("공고가 존재하지 않습니다 - ID: {}", postId);
Expand All @@ -103,7 +108,7 @@ public List<JobPostingDetailDTO> getJobPostingList(String entId) {
.endDate(jp.getEndDate())
.applicantCount(jp.getApplicantCount())
.build()
)
)
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -141,10 +146,62 @@ public String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO) {
int applyId = applicantResultReqDTO.getApplyId();
ApplyResult applyResult = applicantResultReqDTO.getApplyResult();

if(userApplyRepository.setApplicantResult(applyId, applyResult) == 1){
if (userApplyRepository.setApplicantResult(applyId, applyResult) == 1) {

UserApply userApply = userApplyRepository.findById((long)applyId)
.orElseThrow(() -> new RuntimeException("지원 정보를 찾을 수 없습니다."));
WbUser wbUser = userApply.getWbUser();
String entName = userApply.getJobPosting().getEnterprise().getEntName();

String applyResultKorean = switch (applyResult.name()) {
case "PENDING" -> "발표 전";
case "ACCEPTED" -> "합격";
case "FAILED" -> "탈락";
case "CANCELED" -> "지원취소됨";
default -> "";
};

// 알림 생성
Notification notification = Notification.builder()
.wbUser(wbUser)
.userApply(userApply)
.notice(entName+" 지원결과 : "+ applyResultKorean)
.isConfirmed(YN.N)
.createdAt(new Date())
.build();

notificationRepository.save(notification);

return "지원자 결과 설정이 완료되었습니다.";
}else
} else {
return "지원자 결과 설정에 실패했습니다.";
}
}

// 6. 공고 직무별 지원자 추천 (헤드헌팅기능)
@Override
public List<ApplicantsDTO> getApplicantRecommendation(int jobId) {

List<WbUser> recommendedUsers = jobPostingRepository.findApplicantRecommendation(jobId);

return recommendedUsers.stream().map(user -> {
// 생일 계산
Date birthDate = user.getBirth();
Calendar today = Calendar.getInstance();
Calendar birthCalendar = Calendar.getInstance();
birthCalendar.setTime(birthDate);

int age = today.get(Calendar.YEAR) - birthCalendar.get(Calendar.YEAR);
if (today.get(Calendar.DAY_OF_YEAR) < birthCalendar.get(Calendar.DAY_OF_YEAR)) {
age--;
}

return ApplicantsDTO.builder()
.applicantName(user.getName())
.applicantGender(user.getGender())
.applicantAge(age)
.build();
}).collect(Collectors.toList());

}
}

0 comments on commit 6b07ffa

Please sign in to comment.