From 1f8e2670ab5d57e80e05df6fc5204dd75529faeb Mon Sep 17 00:00:00 2001 From: soeunkk Date: Sun, 28 Aug 2022 18:53:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=EC=A0=9C=ED=92=88=EB=AA=85?= =?UTF-8?q?=EC=9D=84=20=ED=86=B5=ED=95=9C=20=EC=9A=A9=EA=B8=B0=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B1=B0=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MedicineController.java | 23 +++++++------------ .../pillaroid/service/MedicineService.java | 15 ------------ 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java b/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java index f88d035..d21f95d 100644 --- a/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java +++ b/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java @@ -55,20 +55,10 @@ public ApiResponse getMedicineInfo(HttpServletRequest request, throw NotFoundException.MEDICINE_NOT_FOUND; } - // 의약품 용기(제품명, 바코드)로 정보 조회 + // 의약품 용기(바코드)로 정보 조회 @GetMapping("/case") - public ApiResponse getMedicineInfo(HttpServletRequest request, - @RequestParam(required = false) String name, - @RequestParam(required = false) String barcode) throws IOException { - if (name != null && !name.equals("")) { // 제품명 - Optional medicineResponse = medicineService.getMedicineInfoByCaseName(name); - - if (medicineResponse.isPresent()) { - return reflectFavoritesAboutMedicine(request, medicineResponse.get()); - } - else - throw NotFoundException.MEDICINE_NOT_FOUND; - } else if (barcode != null && !barcode.equals("")) { // 바코드 + public ApiResponse getMedicineInfo(HttpServletRequest request, @RequestParam String barcode) throws IOException { + if (barcode != null && !barcode.equals("")) { // 바코드 Optional medicineResponse = medicineService.getMedicineInfoByStandardCode(barcode); if (medicineResponse.isPresent()) { @@ -81,12 +71,14 @@ public ApiResponse getMedicineInfo(HttpServletRequest request, if (medicineResponse.isPresent()) { return reflectFavoritesAboutMedicine(request, medicineResponse.get()); } - else + else { throw NotFoundException.BARCODE_NOT_FOUND; + } } } - else + else { throw BadRequestException.BAD_PARAMETER; + } } // 음성을 통한 의약품명으로 의약품 리스트 조회 @@ -138,6 +130,7 @@ private ApiResponse reflectFavoritesAboutMedicine(HttpServletR medicineResponse.setFavoritesIdx(favorites.get().getFavoritesIdx()); } } + System.out.println("medicineResponse = " + medicineResponse); return ApiResponse.success(medicineResponse); } } diff --git a/src/main/java/com/nadoyagsa/pillaroid/service/MedicineService.java b/src/main/java/com/nadoyagsa/pillaroid/service/MedicineService.java index 0094e65..a164630 100644 --- a/src/main/java/com/nadoyagsa/pillaroid/service/MedicineService.java +++ b/src/main/java/com/nadoyagsa/pillaroid/service/MedicineService.java @@ -48,21 +48,6 @@ public Optional getMedicineInfoBySerialNumber(int serialNumber return Optional.ofNullable(medicine.get().toMedicineResponse()); } - public Optional getMedicineInfoByCaseName(String name) { - List medicineList = medicineRepository.findMedicinesByStartingName(name); - - // DB에 저장된 제품명에서 괄호를 제거하고 동일한 의약품명이 있다면 해당 의약품 정보 전달 else 가장 먼저 조회된 결과 전달 - for (Medicine medicine : medicineList) { - if (medicine.getName().strip().equals(name)) - return Optional.ofNullable(medicine.toMedicineResponse()); - } - - if (medicineList.size() == 0) - return Optional.empty(); - else - return Optional.ofNullable(medicineList.get(0).toMedicineResponse()); - } - public Optional getMedicineInfoByStandardCode(String barcode) { Optional medicine = medicineRepository.findMedicineByStandardCode(barcode); if (medicine.isEmpty()) From a23f0e34a53214b9d883a95a4ef9e50fd178e11d Mon Sep 17 00:00:00 2001 From: soeunkk Date: Mon, 29 Aug 2022 16:09:27 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20=EB=94=94=EB=B2=84=EA=B9=85=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nadoyagsa/pillaroid/controller/MedicineController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java b/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java index d21f95d..e883135 100644 --- a/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java +++ b/src/main/java/com/nadoyagsa/pillaroid/controller/MedicineController.java @@ -130,7 +130,6 @@ private ApiResponse reflectFavoritesAboutMedicine(HttpServletR medicineResponse.setFavoritesIdx(favorites.get().getFavoritesIdx()); } } - System.out.println("medicineResponse = " + medicineResponse); return ApiResponse.success(medicineResponse); } }