From 4bf8233dc4d695222b7cab4173e5a7db2c1f51e1 Mon Sep 17 00:00:00 2001 From: mythpoy Date: Sun, 19 Nov 2023 22:58:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?style:=20userId=20->=20patientId=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rehab/domain/program/dto/MetricsUpdateRequestDTO.java | 2 +- .../rehab/domain/program/repository/ProgramRepository.java | 4 ++-- .../rehab/domain/video/controller/VideoController.java | 6 +++--- .../com/hallym/rehab/domain/video/service/VideoService.java | 2 +- .../hallym/rehab/domain/video/service/VideoServiceImpl.java | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/hallym/rehab/domain/program/dto/MetricsUpdateRequestDTO.java b/src/main/java/com/hallym/rehab/domain/program/dto/MetricsUpdateRequestDTO.java index 015a626..92f4769 100644 --- a/src/main/java/com/hallym/rehab/domain/program/dto/MetricsUpdateRequestDTO.java +++ b/src/main/java/com/hallym/rehab/domain/program/dto/MetricsUpdateRequestDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @NoArgsConstructor public class MetricsUpdateRequestDTO { - private String userId; + private String patient_id; private Long pno; private Long vno; private int ord; diff --git a/src/main/java/com/hallym/rehab/domain/program/repository/ProgramRepository.java b/src/main/java/com/hallym/rehab/domain/program/repository/ProgramRepository.java index d74741d..576c511 100644 --- a/src/main/java/com/hallym/rehab/domain/program/repository/ProgramRepository.java +++ b/src/main/java/com/hallym/rehab/domain/program/repository/ProgramRepository.java @@ -9,6 +9,6 @@ public interface ProgramRepository extends JpaRepository { - @Query("SELECT p from Program p where p.patient.mid = :userId") - Optional findByUserId(@Param("userId") String userId); + @Query("SELECT p from Program p where p.patient.mid = :patient_id") + Optional findByPatientId(@Param("patient_id") String patient_id); } diff --git a/src/main/java/com/hallym/rehab/domain/video/controller/VideoController.java b/src/main/java/com/hallym/rehab/domain/video/controller/VideoController.java index 4ea2a8f..e58d196 100644 --- a/src/main/java/com/hallym/rehab/domain/video/controller/VideoController.java +++ b/src/main/java/com/hallym/rehab/domain/video/controller/VideoController.java @@ -18,10 +18,10 @@ public class VideoController { private final VideoService videoService; - @GetMapping("/list/{userId}") + @GetMapping("/list/{patient_id}") public Pair> getListByUser(VideoPageRequestDTO pageRequestDTO, - @PathVariable("userId") String userId) { - return videoService.getVideoListByUser(pageRequestDTO, userId); + @PathVariable("patient_id") String patient_id) { + return videoService.getVideoListByUser(pageRequestDTO, patient_id); } @GetMapping("/list") diff --git a/src/main/java/com/hallym/rehab/domain/video/service/VideoService.java b/src/main/java/com/hallym/rehab/domain/video/service/VideoService.java index 33d56e5..ab14d17 100644 --- a/src/main/java/com/hallym/rehab/domain/video/service/VideoService.java +++ b/src/main/java/com/hallym/rehab/domain/video/service/VideoService.java @@ -17,7 +17,7 @@ public interface VideoService { VideoPageResponseDTO getVideoListByAdmin(VideoPageRequestDTO requestDTO); Pair> getVideoListByUser(VideoPageRequestDTO requestDTO, - String userId); + String patient_id); VideoDetailResponseDTO getVideo(Long vno); diff --git a/src/main/java/com/hallym/rehab/domain/video/service/VideoServiceImpl.java b/src/main/java/com/hallym/rehab/domain/video/service/VideoServiceImpl.java index 3e788bb..83e2cdc 100644 --- a/src/main/java/com/hallym/rehab/domain/video/service/VideoServiceImpl.java +++ b/src/main/java/com/hallym/rehab/domain/video/service/VideoServiceImpl.java @@ -68,9 +68,9 @@ public VideoPageResponseDTO getVideoListByAdmin(VideoPageReque @Override public Pair> getVideoListByUser(VideoPageRequestDTO requestDTO, - String userId) { - Program program = programRepository.findByUserId(userId) - .orElseThrow(() -> new NotFoundException("not found program for userId : " + userId)); + String patient_id) { + Program program = programRepository.findByPatientId(patient_id) + .orElseThrow(() -> new NotFoundException("not found program for patient_id : " + patient_id)); Pageable pageable = requestDTO.getPageable(); From 1525f322a1c17bc3f6c1ed75356cd5f0f4bb6261 Mon Sep 17 00:00:00 2001 From: mythpoy Date: Sun, 19 Nov 2023 22:59:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=A8=20=EC=83=9D=EC=84=B1=EC=8B=9C=2010=EA=B0=9C=EC=9D=98?= =?UTF-8?q?=20ProgramDetail=20=EA=BB=8D=EB=8D=B0=EA=B8=B0=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../program/service/ProgramServiceImpl.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/hallym/rehab/domain/program/service/ProgramServiceImpl.java b/src/main/java/com/hallym/rehab/domain/program/service/ProgramServiceImpl.java index 3e9f37c..7d18b0d 100644 --- a/src/main/java/com/hallym/rehab/domain/program/service/ProgramServiceImpl.java +++ b/src/main/java/com/hallym/rehab/domain/program/service/ProgramServiceImpl.java @@ -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; @@ -35,32 +35,26 @@ public class ProgramServiceImpl implements ProgramService{ @Override public String createProgramAndDetail(ProgramRequestDTO requestDTO) { String adminId = requestDTO.getStaff_id(); - String userId = requestDTO.getPatient_id(); + String patient_id = requestDTO.getPatient_id(); Staff staff = staffRepository.findById(adminId) .orElseThrow(() -> new NotFoundException("not found admin for Id : " + adminId)); - Patient patient = patientRepository.findById(userId) - .orElseThrow(() -> new NotFoundException("not found user for Id : " + userId)); + Patient patient = patientRepository.findById(patient_id) + .orElseThrow(() -> new NotFoundException("not found user for Id : " + patient_id)); Program program = Program.builder() .staff(staff) .patient(patient) - .description(requestDTO.getDescription()) + .description("") .build(); Program savedProgram = programRepository.save(program); - for (Map.Entry entry : requestDTO.getOrd_map().entrySet()) { - int ord = entry.getKey(); - Long vno = entry.getValue(); - - Video video = videoRepository.findById(vno) - .orElseThrow(() -> new RuntimeException("Video not found for Id : " + vno)); - + for (int i = 1; i <= 10; i++) { ProgramDetail programDetail = ProgramDetail.builder() .program(savedProgram) - .video(video) - .ord(ord) + .video(null) + .ord(i) .build(); VideoMetrics videoMetrics = VideoMetrics.builder() @@ -80,13 +74,12 @@ public String createProgramAndDetail(ProgramRequestDTO requestDTO) { @Override public String updateProgramAndDetail(ProgramRequestDTO requestDTO, String patient_id) { String adminId = requestDTO.getStaff_id(); - String userId = requestDTO.getPatient_id(); 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.findByUserId(patient_id) + patientRepository.findById(patient_id) + .orElseThrow(() -> new NotFoundException("not found user for patient_id : " + patient_id)); + Program program = programRepository.findByPatientId(patient_id) .orElseThrow(() -> new NotFoundException("not found for patient_id : " + patient_id)); program.changeDescription(requestDTO.getDescription()); // change description @@ -112,14 +105,14 @@ public String updateProgramAndDetail(ProgramRequestDTO requestDTO, String patien @Override public String updateMetrics(MetricsUpdateRequestDTO metricsUpdateRequestDTO) { - String userId = metricsUpdateRequestDTO.getUserId(); + String patient_id = metricsUpdateRequestDTO.getPatient_id(); Long pno = metricsUpdateRequestDTO.getPno(); Long vno = metricsUpdateRequestDTO.getVno(); int ord = metricsUpdateRequestDTO.getOrd(); double metrics = metricsUpdateRequestDTO.getMetrics(); - patientRepository.findById(userId) - .orElseThrow(() -> new NotFoundException("not found user for Id : " + userId)); + patientRepository.findById(patient_id) + .orElseThrow(() -> new NotFoundException("not found user for Id : " + patient_id)); programRepository.findById(pno) .orElseThrow(() -> new NotFoundException("not found for Id : " + pno)); From 7d827b9ad67b0da1a7fed52b621fc1203280a96c Mon Sep 17 00:00:00 2001 From: mythpoy Date: Sun, 19 Nov 2023 23:00:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?style:=20userId=20->=20patientId=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProgramServiceImplTest.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/hallym/rehab/domain/program/service/ProgramServiceImplTest.java b/src/test/java/com/hallym/rehab/domain/program/service/ProgramServiceImplTest.java index ecda953..9ded4e9 100644 --- a/src/test/java/com/hallym/rehab/domain/program/service/ProgramServiceImplTest.java +++ b/src/test/java/com/hallym/rehab/domain/program/service/ProgramServiceImplTest.java @@ -93,23 +93,9 @@ void setUp() { @Test @Rollback(value = false) void createProgramAndDetail() { - Map ord_map = new HashMap<>(); - ord_map.put(1, 10L); - ord_map.put(2, 10L); - ord_map.put(3, 3L); - ord_map.put(4, 3L); - ord_map.put(5, 1L); - ord_map.put(6, 1L); - ord_map.put(7, 3L); - ord_map.put(8, 6L); - ord_map.put(9, 6L); - ord_map.put(10, 9L); - ProgramRequestDTO programRequestDTO = ProgramRequestDTO.builder() .staff_id("ldh") .patient_id("jyp") - .description("몸이 아프다구요!") - .ord_map(ord_map) .build(); String result = programService.createProgramAndDetail(programRequestDTO); @@ -120,10 +106,10 @@ void createProgramAndDetail() { @Rollback(value = false) void updateMetrics() { MetricsUpdateRequestDTO requestDTO = MetricsUpdateRequestDTO.builder() - .userId(patient.getMid()) + .patient_id(patient.getMid()) .pno(1L) .vno(3L) - .ord(7) + .ord(2) .metrics(83.2) .build();