Skip to content

Commit

Permalink
Merge pull request #32 from jyp-on/main
Browse files Browse the repository at this point in the history
[BE/refactor] 프론트엔드 수정 요구사항 반영
  • Loading branch information
jyp-on authored Nov 16, 2023
2 parents 2d221bf + 8d27d67 commit 3b8e859
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public ResponseEntity<String> createProgramAndDetail(@RequestBody ProgramRequest
return ResponseEntity.ok(result);
}

@PutMapping("/program/{pno}")
@PutMapping("/program/{patient_id}")
public ResponseEntity<String> updateProgramAndDetail(@RequestBody ProgramRequestDTO requestDTO,
@PathVariable("pno") Long pno) {
String result = programService.updateProgramAndDetail(requestDTO, pno);
@PathVariable("patient_id") String patient_id) {
String result = programService.updateProgramAndDetail(requestDTO, patient_id);
return ResponseEntity.ok(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

public interface ProgramService {
String createProgramAndDetail(ProgramRequestDTO programRequestDTO);
String updateProgramAndDetail(ProgramRequestDTO programRequestDTO, Long pno);

String updateProgramAndDetail(ProgramRequestDTO programRequestDTO, String patient_id);

String updateMetrics(MetricsUpdateRequestDTO metricsUpdateRequestDTO);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@Service
@Transactional
@RequiredArgsConstructor
public class ProgramServiceImpl implements ProgramService{
public class ProgramServiceImpl implements ProgramService {
private final StaffRepository staffRepository;
private final PatientRepository patientRepository;
private final VideoRepository videoRepository;
Expand Down Expand Up @@ -78,16 +78,16 @@ public String createProgramAndDetail(ProgramRequestDTO requestDTO) {
}

@Override
public String updateProgramAndDetail(ProgramRequestDTO requestDTO, Long pno) {
public String updateProgramAndDetail(ProgramRequestDTO requestDTO, String patient_id) {
String adminId = requestDTO.getAdminId();
String userId = requestDTO.getUserId();

staffRepository.findById(adminId)
.orElseThrow(() -> new NotFoundException("not found admin for adminId : " + adminId));
patientRepository.findById(userId)
.orElseThrow(() -> new NotFoundException("not found user for userId : " + userId));
Program program = programRepository.findById(pno)
.orElseThrow(() -> new NotFoundException("not found for pno : " + pno));
Program program = programRepository.findByUserId(patient_id)
.orElseThrow(() -> new NotFoundException("not found for patient_id : " + patient_id));

program.changeDescription(requestDTO.getDescription()); // change description
programRepository.save(program);
Expand All @@ -99,7 +99,7 @@ public String updateProgramAndDetail(ProgramRequestDTO requestDTO, Long pno) {
Video video = videoRepository.findById(vno)
.orElseThrow(() -> new RuntimeException("Video not found for Id : " + vno));

ProgramDetail programDetail = programDetailRepository.findByPnoAndOrd(pno, ord)
ProgramDetail programDetail = programDetailRepository.findByPnoAndOrd(program.getPno(), ord)
.orElseThrow(() -> new NotFoundException("Detail not found"));

programDetail.changeOrd(ord, video); // change ord, vno
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ReservationResponseByStaffDTO {
private String patientName;
private String patientId; // 환자 상세정보 보기 위한 Id
private UUID rno;
private Long rvno;
private LocalDate date;
private int index;
private String content; // 진료 희망 사유
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static ReservationResponseByStaffDTO toAdminDTO(Reservation reservation)
.patientName(reservation.getPatient().getName())
.patientId(reservation.getPatient().getMid())
.rno(reservation.getRoom().getRno())
.rvno(reservation.getRvno())
.date(reservation.getDate())
.index(reservation.getIndex())
.summary(summary)
Expand Down

0 comments on commit 3b8e859

Please sign in to comment.