Skip to content

Commit

Permalink
Feat: ProvidedDrugInfo 엔티티에 약 사용 History 저장 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
suminiee authored May 6, 2024
2 parents a323a95 + ef8d48d commit cc5c220
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.medicare.neulpeum.dto;

import com.medicare.neulpeum.domain.entity.ConsultContentInfo;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -8,6 +9,7 @@
@Setter
@NoArgsConstructor
public class DrugUpdateRequestDto {
private ConsultContentInfo consultId;
private String drugName;
private int usedAmount;

Expand Down

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/java/com/medicare/neulpeum/service/DrugServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.medicare.neulpeum.service;

import com.medicare.neulpeum.Repository.DrugRepository;
import com.medicare.neulpeum.Repository.ProvidedDrugRepository;
import com.medicare.neulpeum.domain.entity.DrugInfo;
import com.medicare.neulpeum.domain.entity.ProvidedDrugInfo;
import com.medicare.neulpeum.dto.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,6 +21,8 @@ public class DrugServiceImpl implements DrugService{

@Autowired
DrugRepository drugRepository;
@Autowired
ProvidedDrugRepository providedDrugRepository;

@Override
public void save(DrugRequestDto drugReq) {
Expand Down Expand Up @@ -101,6 +105,12 @@ public void updateUsedDrug(List<DrugUpdateRequestDto> drugUpdateRequestDtoList)
drugRepository.save(drug);

//ProvidedDrugInfo 테이블에 저장
ProvidedDrugInfo providedDrugInfo = ProvidedDrugInfo.builder()
.drugId(drug)
.consultId(updateRequestDto.getConsultId())
.providedAmount((long) remainingAmount)
.build();
providedDrugRepository.save(providedDrugInfo);

break;
} else {
Expand All @@ -109,6 +119,14 @@ public void updateUsedDrug(List<DrugUpdateRequestDto> drugUpdateRequestDtoList)
remainingAmount -= usableAmount;
drug.setUsableAmount(0);
drugRepository.save(drug);

//ProvidedDrugInfo 테이블에 저장
ProvidedDrugInfo providedDrugInfo = ProvidedDrugInfo.builder()
.drugId(drug)
.consultId(updateRequestDto.getConsultId())
.providedAmount((long) remainingAmount)
.build();
providedDrugRepository.save(providedDrugInfo);
}
}
}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit cc5c220

Please sign in to comment.