Repository navigation
[Feat]: 약물노트 병원+처방일 그룹 상세 조회 API 구현 #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a75a2c
refactor: MedicationDetailResponse 제거, MedicationGroupItemResponse 추가
kangcheolung 822bae2
feat: 약물노트 그룹 상세 조회 쿼리 추가 (findByGroup)
kangcheolung b56a58e
refactor: toDetailResponse 제거, toGroupItemResponse 추가
kangcheolung ab374a6
refactor: getDetail 제거, getGroup으로 교체
kangcheolung f0af124
refactor: GET /detail 제거, GET /group 엔드포인트로 교체
kangcheolung af55d56
fix: getGroup userId null 시 FORBIDDEN 예외 처리
kangcheolung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...main/java/com/piuda/callcare/domain/medication/dto/response/MedicationDetailResponse.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
...n/java/com/piuda/callcare/domain/medication/dto/response/MedicationGroupItemResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.piuda.callcare.domain.medication.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Schema(description = "그룹 내 약 단건 응답") | ||
| public record MedicationGroupItemResponse( | ||
|
|
||
| @Schema(description = "약 ID") | ||
| Long medicationId, | ||
|
|
||
| @Schema(description = "약 이름") | ||
| String drugName, | ||
|
|
||
| @Schema(description = "약 종류 (없으면 null)") | ||
| String drugType, | ||
|
|
||
| @Schema(description = "약 이미지 URL (없으면 null)") | ||
| String imageUrl, | ||
|
|
||
| @Schema(description = "1일 복용 횟수") | ||
| Integer timesPerDay, | ||
|
|
||
| @Schema(description = "1회 복용량 (예: 1정, 5ml)") | ||
| String dosagePerTime, | ||
|
|
||
| @Schema(description = "복용 시작일") | ||
| LocalDate startDate, | ||
|
|
||
| @Schema(description = "복용 종료일 (없으면 null)") | ||
| LocalDate endDate, | ||
|
|
||
| @Schema(description = "총 복용 일수 (없으면 null)") | ||
| Integer totalDays, | ||
|
|
||
| @Schema(description = "메모 — OCR 자동 생성 또는 사용자 직접 입력 (없으면 null)") | ||
| String memo | ||
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 14 additions & 6 deletions
20
src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,37 @@ | ||
| package com.piuda.callcare.domain.medication.service.query; | ||
|
|
||
| import com.piuda.callcare.domain.medication.converter.MedicationConverter; | ||
| import com.piuda.callcare.domain.medication.dto.response.MedicationDetailResponse; | ||
| import com.piuda.callcare.domain.medication.dto.response.MedicationGroupItemResponse; | ||
| import com.piuda.callcare.domain.medication.entity.Medication; | ||
| import com.piuda.callcare.domain.medication.repository.MedicationRepository; | ||
| import com.piuda.callcare.domain.senior.repository.SeniorRepository; | ||
| import com.piuda.callcare.global.exception.CallCareException; | ||
| import com.piuda.callcare.global.exception.ErrorCode; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @Transactional(readOnly = true) | ||
| @RequiredArgsConstructor | ||
| public class MedicationQueryService { | ||
|
|
||
| private final MedicationRepository medicationRepository; | ||
| private final SeniorRepository seniorRepository; | ||
| private final MedicationConverter medicationConverter; | ||
|
|
||
| public MedicationDetailResponse getDetail(Long userId, Long medicationId) { | ||
| Medication medication = medicationRepository.findById(medicationId) | ||
| .orElseThrow(() -> new CallCareException(ErrorCode.MEDICATION_NOT_FOUND)); | ||
| if (userId != null && !medication.getSenior().getUser().getId().equals(userId)) { | ||
| public List<MedicationGroupItemResponse> getGroup(Long userId, Long seniorId, String hospitalName, LocalDate prescriptionDate) { | ||
| if (userId == null) { | ||
| throw new CallCareException(ErrorCode.FORBIDDEN); | ||
| } | ||
| return medicationConverter.toDetailResponse(medication); | ||
| seniorRepository.findByIdAndUser_Id(seniorId, userId) | ||
| .orElseThrow(() -> new CallCareException(ErrorCode.SENIOR_NOT_FOUND)); | ||
| List<Medication> medications = medicationRepository.findByGroup(seniorId, hospitalName, prescriptionDate); | ||
| return medications.stream() | ||
| .map(medicationConverter::toGroupItemResponse) | ||
| .toList(); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.