Skip to content

Commit

Permalink
Refactor: 약 재고 업데이트 api 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
noeyoes authored Mar 12, 2024
2 parents cfbd797 + b75115a commit 60f37b8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface DrugRepository extends JpaRepository<DrugInfo, Long> {
@Override
List<DrugInfo> findAll();
List<DrugInfo> findByDrugName(String drugName);
boolean existsByDrugName(String drugName);
boolean existsById(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ResponseEntity<?> updateDrugInfo(@RequestBody List<DrugRequestDto> drugRe
try {
for (DrugRequestDto drugRequestDto : drugRequestDtoList) {
// 해당 약물 정보가 이미 존재하는지 확인
if (drugService.existsByDrugName(drugRequestDto.getDrugName())) {
if (drugService.existsByDrugId(drugRequestDto.getDrugId())) {
// 이미 존재하는 경우에는 업데이트 수행
drugService.update(drugRequestDto);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public interface DrugService {
void save(DrugRequestDto drugRequestDto);
List<DrugResponseDto> findAll();
List<DrugResponseDto> findByDrugName(String drugName);
boolean existsByDrugName(String drugName);
boolean existsByDrugId(Long id);
void update(DrugRequestDto drugRequestDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public List<DrugResponseDto> findByDrugName(String drugName) {
}

@Override
public boolean existsByDrugName(String drugName) {
return drugRepository.existsByDrugName(drugName);
public boolean existsByDrugId(Long id) {
return drugRepository.existsById(id);
}

@Override
Expand Down

0 comments on commit 60f37b8

Please sign in to comment.