Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,26 @@ public ResponseEntity<?> getRecruitPersonalList(@AuthenticationPrincipal UserDet
})
public ResponseEntity<?> getOneRecruitPatientInfo(@AuthenticationPrincipal UserDetails userDetails,
@PathVariable("patientLogSeq") Long patientLogSeq) {
return ResponseEntity.ok().body(noticeService.getOneRecruitPatientInfo(userDetails.getUsername(), patientLogSeq));
return ResponseEntity.ok().body(noticeService.getOneRecruitPatientInfo(userDetails.getUsername(), patientLogSeq, true));
}

@GetMapping("/{patientLogSeq}/detail-helper")
@Operation(summary = "요양보호사 - 어르신 공고 상세 조회 API", description = "어르신 공고를 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공",
content = @Content(schema = @Schema(implementation = RecruitResponseDto.GetOneRecruitPatientInfo.class))),
@ApiResponse(responseCode = "4008", description = "사용자정의에러코드:로그인이 정보 없음(쿠키 없음)",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "8001", description = "사용자정의에러코드:NOT_FOUND_PATIENT_RECRUIT",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "8000", description = "사용자정의에러코드:해당 어르신 정보를 찾을 수 없습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "7001", description = "사용자정의에러코드:조회 권한 없음",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
public ResponseEntity<?> getOneRecruitPatientInfoToHelper(@AuthenticationPrincipal UserDetails userDetails,
@PathVariable("patientLogSeq") Long patientLogSeq) {
return ResponseEntity.ok().body(noticeService.getOneRecruitPatientInfo(userDetails.getUsername(), patientLogSeq, false));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface RecruitService {
RecruitResponseDto.RecruitHelper recruitHelper(UserDetails userDetails, RecruitRequestDto.RecruitHelper dto); // 어르신 공고 등록
RecruitResponseDto.GetRecruitList getRecruitList(String userEmail, RecruitRequestDto.GetRecruitList dto); // 어르신 공고 리스트 조회
RecruitResponseDto.GetRecruitList getRecruitPersonalList(String userEmail, RecruitRequestDto.GetRecruitPersonalList dto); // 어르신 개인 공고 리스트 조회
RecruitResponseDto.GetOneRecruitPatientInfo getOneRecruitPatientInfo(String userEmail, Long patientLogSeq); // 어르신 정보 상세 조회
RecruitResponseDto.GetOneRecruitPatientInfo getOneRecruitPatientInfo(String userEmail, Long patientLogSeq, boolean managerYn); // 어르신 정보 상세 조회
RecruitResponseDto.UpdateRecruitPatientInfo updateRecruitPatientInfo(String userEmail, RecruitRequestDto.UpdateRecruitPatientInfo dto); // 어르신 정보 상세 조회
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.balybus.galaxy.patient.recruit.service;

import com.balybus.galaxy.careAssistant.domain.TblHelper;
import com.balybus.galaxy.global.domain.tblAddressFirst.TblAddressFirst;
import com.balybus.galaxy.global.domain.tblAddressSecond.TblAddressSecond;
import com.balybus.galaxy.global.domain.tblAddressThird.TblAddressThird;
Expand All @@ -8,6 +9,8 @@
import com.balybus.galaxy.global.domain.tblCare.service.TblCareServiceImpl;
import com.balybus.galaxy.global.domain.tblCenterManager.TblCenterManager;
import com.balybus.galaxy.global.domain.tblMatching.MatchingServiceImpl;
import com.balybus.galaxy.global.domain.tblMatching.TblMatching;
import com.balybus.galaxy.global.domain.tblMatching.TblMatchingRepository;
import com.balybus.galaxy.global.exception.BadRequestException;
import com.balybus.galaxy.global.exception.ExceptionCode;
import com.balybus.galaxy.global.utils.address.service.serviceImpl.TblAddressFirstServiceImpl;
Expand Down Expand Up @@ -51,6 +54,7 @@ public class RecruitServiceImpl implements RecruitService {
private final TblPatientLogRepository patientLogRepository;
private final TblPatientTimeLogRepository patientTimeLogRepository;
private final TblCareRepository careRepository;
private final TblMatchingRepository matchingRepository;

private final LoginAuthCheckServiceImpl loginAuthCheckService;
private final MatchingServiceImpl matchingService;
Expand Down Expand Up @@ -257,17 +261,24 @@ public RecruitResponseDto.GetRecruitList getRecruitPersonalList(String userEmail
* @return PatientResponseDto.GetOnePatientInfo
*/
@Override
public RecruitResponseDto.GetOneRecruitPatientInfo getOneRecruitPatientInfo(String userEmail, Long patientLogSeq) {
//1. 관리자 정보 조회
TblCenterManager centerManager = loginAuthCheckService.checkManager(userEmail);

//어르신 로그 정보 조회
Optional<TblPatientLog> patientLogOpt = patientLogRepository.findById(patientLogSeq);
if(patientLogOpt.isEmpty()) throw new BadRequestException(ExceptionCode.NOT_FOUND_PATIENT_RECRUIT);
TblPatientLog patientLog = patientLogOpt.get();

//2. 어르신 정보 조회 (어르신 구분자 & 관리자 구분자)
TblPatient patient = loginAuthCheckService.checkPatientManagerAuth(patientLog.getPatient().getId(), centerManager.getId());
public RecruitResponseDto.GetOneRecruitPatientInfo getOneRecruitPatientInfo(String userEmail, Long patientLogSeq, boolean managerYn) {
//1. 어르신 로그 정보 조회
TblPatientLog patientLog = getPatientLog(patientLogSeq);

//2. 로그인 정보 조회
if(managerYn) {
//2-1-1. 관리자 정보 조회
TblCenterManager centerManager = loginAuthCheckService.checkManager(userEmail);
//2-1-2. 어르신 정보 조회 가능 여부 확인(어르신 구분자 & 관리자 구분자)
TblPatient patient = loginAuthCheckService.checkPatientManagerAuth(patientLog.getPatient().getId(), centerManager.getId());
} else {
//2-2-1. 요양보호사 정보 조회
TblHelper helper = loginAuthCheckService.checkHelper(userEmail);

//2-2-2. 어르신 정보 조회 가능 여부 확인(매칭 확인 - 요양보호사)
Optional<TblMatching> matchingOpt = matchingRepository.findByPatientLog_idAndHelper_id(patientLogSeq, helper.getId());
if(matchingOpt.isEmpty()) throw new BadRequestException(ExceptionCode.NOT_FOUND_PATIENT_RECRUIT);
}

//3. 어르신 돌봄 시간 요일 조회
List<TblPatientTimeLog> patientTimeLogList = patientTimeLogRepository.findByPatientLog_Id(patientLog.getId());
Expand All @@ -279,6 +290,17 @@ public RecruitResponseDto.GetOneRecruitPatientInfo getOneRecruitPatientInfo(Stri
return resultDto;
}

/**
* 어르신 로그 정보 조회
* @param patientLogSeq 어르신로그(공고) 구분자
* @return TblPatientLog 엔티티
*/
private TblPatientLog getPatientLog(Long patientLogSeq){
Optional<TblPatientLog> patientLogOpt = patientLogRepository.findById(patientLogSeq);
if(patientLogOpt.isEmpty()) throw new BadRequestException(ExceptionCode.NOT_FOUND_PATIENT_RECRUIT);
return patientLogOpt.get();
}


/**
* 어르신 공고 등록
Expand Down
Loading