Skip to content

Commit

Permalink
Merge pull request #104 from WooRibound/fix/#34-ent-jobposting
Browse files Browse the repository at this point in the history
[fix] #34 -  기업 관련 기능 수정
  • Loading branch information
soljjang777 authored Nov 18, 2024
2 parents c99de97 + 75433b2 commit cdfea0b
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public String updateEnterpriseInfo(@RequestBody EnterpriseInfoReqDTO enterpriseI

@Operation(summary = "고용 직원 목록 조회", description = "고용 직원 목록 조회")
@GetMapping("/employee")
public List<EmployeeDTO> getJobEmployees(@RequestParam String entId) {
return enterpriseInfoFacade.getEmployees(entId);
public List<EmployeeDTO> getJobEmployees(Authentication authentication) {
return enterpriseInfoFacade.getEmployees(authentication);
}

@Operation(summary = "고용 직원 평가", description = "고용 직원 평가")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.wooribound.api.corporate.dto.JobPostingReqDTO;
import com.wooribound.api.corporate.facade.EnterpriseJobPostingFacade;
import com.wooribound.domain.jobposting.dto.JobPostingDetailDTO;
import com.wooribound.domain.resume.dto.ResumeDTO;
import com.wooribound.domain.resume.dto.ResumeDetailDTO;
import com.wooribound.domain.userapply.dto.ApplicantResultReqDTO;
import com.wooribound.global.util.AuthenticateUtil;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -49,8 +49,8 @@ public List<ApplicantsDTO> getJobApplicants(@RequestParam int postId) {

// 5. 공고 지원자 이력서 조회
@GetMapping("/applicant/detail")
public ResumeDTO getApplicantResume(Authentication authentication) {
return enterpriseJobPostingFacade.getApplicantResume(authentication);
public ResumeDetailDTO getApplicantResume(@RequestParam String userId) {
return enterpriseJobPostingFacade.getApplicantResume(userId);
}

// TODO: 합격여부 설정 시 버튼 컴포넌트 비활성화
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wooribound.api.corporate.dto;

import com.wooribound.global.constant.ApplyResult;
import com.wooribound.global.constant.Gender;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -15,4 +16,7 @@ public class ApplicantsDTO {
private String applicantName;
private Gender applicantGender;
private int applicantAge;
private String userId;
private Long applyId;
private ApplyResult result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class EmployeeDTO {
private String userName;
private String jobName;
private YN empRecomm;
private Long empId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public String updateEnterpriseInfo(EnterpriseInfoReqDTO enterpriseInfoReqDTO ) {

// 3. 고용 직원 목록 조회
@Transactional(readOnly = true)
public List<EmployeeDTO> getEmployees(String entId) {
public List<EmployeeDTO> getEmployees(Authentication authentication) {
String entId = authenticateUtil.CheckEnterpriseAuthAndGetUserId(authentication);
return employmentService.getEmployees(entId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.wooribound.domain.jobposting.dto.JobPostingDetailProjection;
import com.wooribound.domain.resume.ResumeService;
import com.wooribound.domain.resume.dto.ResumeDTO;
import com.wooribound.domain.resume.dto.ResumeDetailDTO;
import com.wooribound.domain.userapply.dto.ApplicantResultReqDTO;
import com.wooribound.global.util.AuthenticateUtil;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -52,8 +53,8 @@ public List<ApplicantsDTO> getJobApplicants(int postId) {

// 4. 공고 지원자 이력서 조회
@Transactional(readOnly = true)
public ResumeDTO getApplicantResume(Authentication authentication) {
return resumeService.getResume(authentication);
public ResumeDetailDTO getApplicantResume(String userId) {
return resumeService.getWbUserResume(userId);
}

// 5. 지원자 결과 설정
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.wooribound.api.corporate.dto.EmployeeDTO;
import com.wooribound.api.corporate.dto.EmploymentReqDTO;
import com.wooribound.domain.userapply.Service.UserApplyServiceImpl;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -14,12 +16,14 @@
public class EmploymentServiceImpl implements EmploymentService{

private final EmploymentRepository employmentRepository;
Logger logger = org.slf4j.LoggerFactory.getLogger(UserApplyServiceImpl.class);

// 1. 고용 직원 목록 조회
@Override
public List<EmployeeDTO> getEmployees(String entId) {
return employmentRepository.findByEnterprise_EntId(entId).stream()
.map(employment -> EmployeeDTO.builder()
.empId(employment.getEmpId())
.hireDate(employment.getHireDate())
.userName(employment.getWbUser().getName())
.jobName(employment.getJob().getJobName())
Expand All @@ -31,6 +35,7 @@ public List<EmployeeDTO> getEmployees(String entId) {
// 2. 고용 직원 평가
@Override
public String evaluateEmployee(EmploymentReqDTO employmentReqDTO) {
logger.info("고용 직원 평가 시작, empId: {}, empRecomm: {}", employmentReqDTO.getEmpId(), employmentReqDTO.getEmpRecomm());
Long empId = employmentReqDTO.getEmpId();
Optional<Employment> employee = employmentRepository.findById(empId);
if (employee.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ List<JobPostingProjection> findJobPostingsNew(@Param("exJobs") List<String> exJo

// 3. 내 기업 공고 목록 조회
// JOBPOSTING + COUNT(쿼리연산) 반환해야해서 프로젝션 인터페이스로 리턴값 설정 JobPostingDetailProjection
@Query("SELECT jp.postTitle AS postTitle, jp.enterprise.entName AS entName, jp.postImg AS postImg, " +
@Query("SELECT jp.postId AS postId, jp.postTitle AS postTitle, jp.enterprise.entName AS entName, jp.postImg AS postImg, " +
"jp.startDate AS startDate, jp.endDate AS endDate, " +
"jp.job.jobName AS jobName, jp.enterprise.entAddr1 AS entAddr1, jp.enterprise.entAddr2 AS entAddr2, " +
"(SELECT COUNT(ua) FROM UserApply ua WHERE ua.jobPosting = jp) AS applicantCount " +
"(SELECT COUNT(ua) FROM UserApply ua WHERE ua.jobPosting = jp) AS applicantCount, " +
"CASE " +
"WHEN jp.startDate > CURRENT_DATE THEN 'PENDING' " +
"WHEN jp.startDate <= CURRENT_DATE AND jp.endDate >= CURRENT_DATE THEN 'ACTIVE' " +
"WHEN jp.endDate < CURRENT_DATE THEN 'CLOSED' " +
"END AS postState " +
"FROM JobPosting jp " +
"WHERE jp.enterprise.entId = :entId")
List<JobPostingDetailProjection> getMyJobPostings(@Param("entId") String entId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,18 @@ public JobPostingDetailDTO getJobPostingDetail(Long postId) {
JobPosting jobPosting = jobPostingOptional.get();

// log4j - 조회된 공고 상세 로그
logger.info("공고 상세 조회 결과 - ID: {}, Title: {}", jobPosting.getPostId(), jobPosting.getPostTitle());
logger.info("공고 상세 조회 결과 - ID: {}, Title: {}, entName: {}, postImg: {}, startDate: {}, endDate: {}, jobName: {}, entAddr1: {}, entAddr2: {}",
jobPosting.getPostId(), jobPosting.getPostTitle(), jobPosting.getEnterprise().getEntName(), jobPosting.getPostImg(), jobPosting.getStartDate(), jobPosting.getEndDate(), jobPosting.getJob().getJobName(), jobPosting.getEnterprise().getEntAddr1(), jobPosting.getEnterprise().getEntAddr2());
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())
.jobId(jobPosting.getJob().getJobId())
.build();
} else {
// 공고가 존재하지 않는 경우 예외 로그
Expand All @@ -114,8 +115,10 @@ public JobPostingDetailDTO getJobPostingDetail(Long postId) {
// 3. 내 기업 공고 목록 조회
@Override
public List<JobPostingDetailDTO> getJobPostingList(String entId) {
logger.info(entId + " - 내 기업 공고 목록 조회 시작");
List<JobPostingDetailProjection> jobPostings = jobPostingRepository.getMyJobPostings(entId);
return jobPostings.stream().map(jp -> JobPostingDetailDTO.builder()
List<JobPostingDetailDTO> response = jobPostings.stream().map(jp -> JobPostingDetailDTO.builder()
.postId(jp.getPostId())
.entAddr1(jp.getEntAddr1())
.entAddr2(jp.getEntAddr2())
.entName(jp.getEntName())
Expand All @@ -125,9 +128,12 @@ public List<JobPostingDetailDTO> getJobPostingList(String entId) {
.startDate(jp.getStartDate())
.endDate(jp.getEndDate())
.applicantCount(jp.getApplicantCount())
.postState(jp.getPostState())
.build()
)
.collect(Collectors.toList());
logger.info(response.toString());
return response;
}

// 4. 공고 지원자 전체 조회
Expand All @@ -151,19 +157,23 @@ public List<ApplicantsDTO> getJobApplicants(int postId) {

// DTO 생성
return ApplicantsDTO.builder()
.userId(applicant.getWbUser().getUserId())
.applicantName(applicant.getWbUser().getName())
.applicantGender(applicant.getWbUser().getGender())
.applicantAge(age)
.applyId(applicant.getApplyId())
.result(applicant.getResult())
.build();
}).collect(Collectors.toList());
}

// 5. 지원자 결과 설정
@Override
public String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO) {
int applyId = applicantResultReqDTO.getApplyId();
Long applyId = applicantResultReqDTO.getApplyId();
ApplyResult applyResult = applicantResultReqDTO.getApplyResult();

logger.info("지원자 결과 설정 START, applyId: {}, applyResult: {}", applyId, applyResult);
if (userApplyRepository.setApplicantResult(applyId, applyResult) == 1) {

UserApply userApply = userApplyRepository.findById((long)applyId)
Expand All @@ -174,13 +184,19 @@ public String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO) {
String applyResultKorean = switch (applyResult.name()) {
case "PENDING" -> "발표 전";
case "ACCEPTED" -> "합격";
case "FAILED" -> "탈락";
case "REJECTED" -> "탈락";
case "CANCELED" -> "지원취소됨";
default -> "";
};

Long maxId = notificationRepository.findMaxId();
Long nextId = maxId + 1;
logger.info("nextId: {}", nextId.toString());

// 알림 생성
logger.info("알림 생성 시작");
Notification notification = Notification.builder()
.notiId(nextId)
.wbUser(wbUser)
.userApply(userApply)
.notice(entName+" 지원결과 : "+ applyResultKorean)
Expand All @@ -200,6 +216,7 @@ public String setApplicantResult(ApplicantResultReqDTO applicantResultReqDTO) {
@Override
public List<ApplicantsDTO> getApplicantRecommendation(int jobId) {

logger.info("공고 직무별 지원자 추천 시작 - jobId: {}", jobId);
List<WbUser> recommendedUsers = jobPostingRepository.findApplicantRecommendation(jobId);

return recommendedUsers.stream().map(user -> {
Expand All @@ -218,6 +235,7 @@ public List<ApplicantsDTO> getApplicantRecommendation(int jobId) {
.applicantName(user.getName())
.applicantGender(user.getGender())
.applicantAge(age)
.userId(user.getUserId())
.build();
}).collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
@Setter
@AllArgsConstructor
public class JobPostingDetailDTO {
private Long postId; // 공고 id
private String postTitle; // 공고 제목
private String entName; // 기업 이름
private String postImg; // 공고 이미지
private Date startDate; // 공고 시작 날짜
private Date endDate; // 공고 종료 날짜
private String jobName; // 직무 이름
private Long jobId; // 직무 id
private String entAddr1; // 기업 주소 1
private String entAddr2; // 기업 주소 2
private int applicantCount; // 지원자 수
private String postState; // 공고 상태
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Date;

public interface JobPostingDetailProjection {
Long getPostId();
String getPostTitle();
String getEntName();
String getPostImg();
Expand All @@ -12,4 +13,5 @@ public interface JobPostingDetailProjection {
String getEntAddr1();
String getEntAddr2();
int getApplicantCount();
String getPostState();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
)
public class Notification {
@Id
@GeneratedValue(
strategy = GenerationType.AUTO,
generator = "notification_seq_generator"
)
// @GeneratedValue(
// strategy = GenerationType.AUTO,
// generator = "notification_seq_generator"
// )
@Column(name = "noti_id")
private Long notiId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
@Query("SELECT n FROM Notification n WHERE n.wbUser.userId = :userId")
List<Notification> findByUserId(@Param("userId") String userId);

@Query("SELECT COALESCE(MAX(n.notiId), 0) FROM Notification n")
Long findMaxId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface UserApplyRepository extends JpaRepository<UserApply, Long> {
// 3. 지원자 결과 설정
@Modifying
@Query("UPDATE UserApply ua SET ua.result = :applyResult WHERE ua.applyId = :applyId")
int setApplicantResult(@Param("applyId") int applyId,
int setApplicantResult(@Param("applyId") Long applyId,
@Param("applyResult") ApplyResult applyResult);

// 4. 지원 결과 대기 중인 지원현황 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
@AllArgsConstructor
public class ApplicantResultReqDTO {

private int applyId;
private Long applyId;
private ApplyResult applyResult;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.wooribound.global.constant;

public enum ApplyResult {
PENDING, ACCEPTED, FAILED, CANCELED
PENDING, ACCEPTED, REJECTED, CANCELED
}

0 comments on commit cdfea0b

Please sign in to comment.