From 7074b5120bf4f6926b64f2c48dd4ac12d66df746 Mon Sep 17 00:00:00 2001 From: noeyoes Date: Mon, 6 May 2024 00:20:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat:=20=EC=A3=BC=EB=AF=BC=20=EC=83=81?= =?UTF-8?q?=EB=8B=B4=20=EB=82=B4=EC=9A=A9=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../neulpeum/Repository/ConsultRepository.java | 2 ++ .../neulpeum/controller/ConsultController.java | 13 ++++++++++++- .../medicare/neulpeum/service/ConsultService.java | 1 + .../neulpeum/service/ConsultServiceImpl.java | 8 +++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/medicare/neulpeum/Repository/ConsultRepository.java b/src/main/java/com/medicare/neulpeum/Repository/ConsultRepository.java index 3498e01..7eb31ad 100644 --- a/src/main/java/com/medicare/neulpeum/Repository/ConsultRepository.java +++ b/src/main/java/com/medicare/neulpeum/Repository/ConsultRepository.java @@ -12,4 +12,6 @@ public interface ConsultRepository extends JpaRepository findAllByPatientId(PatientInfo patientId); Optional findByConsultId(Long consultId); + + Optional deleteByConsultId(Long consultId); } diff --git a/src/main/java/com/medicare/neulpeum/controller/ConsultController.java b/src/main/java/com/medicare/neulpeum/controller/ConsultController.java index a2bcb65..6f50de9 100644 --- a/src/main/java/com/medicare/neulpeum/controller/ConsultController.java +++ b/src/main/java/com/medicare/neulpeum/controller/ConsultController.java @@ -65,5 +65,16 @@ public ResponseEntity updateConsultInfo(@RequestBody ConsultUpdateRequestDto } } - + @DeleteMapping("/patient/consultDelete") + public ResponseEntity deleteConsultInfo(@RequestParam Long consultId) { + try { + consultService.delete(consultId); + return ResponseEntity.status(HttpStatus.OK).body("주민 상담 상세 내용 삭제 완료"); + } catch (IllegalArgumentException e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body("상담 정보를 찾을 수 없습니다."); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("주민 상담 내용 삭제 중 오류 발생: " + e.getMessage()); + } + } } diff --git a/src/main/java/com/medicare/neulpeum/service/ConsultService.java b/src/main/java/com/medicare/neulpeum/service/ConsultService.java index 55ba7c5..57155e8 100644 --- a/src/main/java/com/medicare/neulpeum/service/ConsultService.java +++ b/src/main/java/com/medicare/neulpeum/service/ConsultService.java @@ -14,4 +14,5 @@ public interface ConsultService { void update(ConsultUpdateRequestDto consultUpdateRequestDto); + void delete(Long consultId); } diff --git a/src/main/java/com/medicare/neulpeum/service/ConsultServiceImpl.java b/src/main/java/com/medicare/neulpeum/service/ConsultServiceImpl.java index b95a198..4aea50f 100644 --- a/src/main/java/com/medicare/neulpeum/service/ConsultServiceImpl.java +++ b/src/main/java/com/medicare/neulpeum/service/ConsultServiceImpl.java @@ -87,5 +87,11 @@ public void update(ConsultUpdateRequestDto consultUpdateRequestDto) { } } - + @Override + public void delete(Long consultId) { + Optional optionalConsultContentInfo = consultRepository.findByConsultId(consultId); + if (optionalConsultContentInfo.isPresent()) { + consultRepository.deleteByConsultId(consultId); + } + } } From 89189b241aaadf2388a832eae38667bddc9e711a Mon Sep 17 00:00:00 2001 From: noeyoes Date: Mon, 6 May 2024 00:21:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20=EC=A0=9C=EA=B3=B5=ED=95=9C=20?= =?UTF-8?q?=EC=95=BD=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/entity/ProvidedDrugInfo.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/medicare/neulpeum/domain/entity/ProvidedDrugInfo.java diff --git a/src/main/java/com/medicare/neulpeum/domain/entity/ProvidedDrugInfo.java b/src/main/java/com/medicare/neulpeum/domain/entity/ProvidedDrugInfo.java new file mode 100644 index 0000000..45c6f30 --- /dev/null +++ b/src/main/java/com/medicare/neulpeum/domain/entity/ProvidedDrugInfo.java @@ -0,0 +1,31 @@ +package com.medicare.neulpeum.domain.entity; + +import jakarta.persistence.*; +import lombok.*; + +import static jakarta.persistence.FetchType.LAZY; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "providedDrugInfo") +public class ProvidedDrugInfo { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(nullable = false, name = "providedId") + private Long id; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "drugInfo", nullable = false) + private DrugInfo drugId; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "consultContentInfo", nullable = false) + private ConsultContentInfo consultId; + + @Column(nullable = false) + private Long providedAmount; +}