Skip to content
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

Feat: 가이드라인 삭제 기능 추가 #108

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ public ResponseEntity<GuardGuidelineResponse> getGuardGuideline(@RequestParam("c
return ResponseEntity.ok(guardGuidelineService.readGuardGuideline(callbackId, guidelineId));
}

@Operation(summary = "특정 가이드라인 삭제", description = "보호자용 API입니다.")
@DeleteMapping("/delete")
public ResponseEntity<String> deleteGuardGuideline(@MemberId Long memberId, @RequestParam("guidelineId") Long guidelineId) {
guardGuidelineService.deleteGuardGuideline(memberId, guidelineId);
return ResponseEntity.ok("가이드라인이 삭제되었습니다.");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.example.sinitto.guardGuideline.entity.GuardGuideline;

public record GuardGuidelineResponse(
Long Id,
Long id,
GuardGuideline.Type type,
String title,
String content) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ public void updateGuardGuideline(Long memberId, Long guidelineId, GuardGuideline
guardGuideline.updateGuardGuideline(guardGuidelineRequest.type(), guardGuidelineRequest.title(), guardGuidelineRequest.content());
}

@Transactional
public void deleteGuardGuideline(Long memberId, Long guidelineId) {
GuardGuideline guardGuideline = guardGuidelineRepository.findById(guidelineId).orElseThrow(
() -> new NotFoundException("해당 가이드라인이 존재하지 않습니다.")
);
if (guardGuideline.getSenior().isNotGuard(memberId)) {
throw new BadRequestException("해당 Guard의 Senior가 아닙니다.");
}
guardGuidelineRepository.delete(guardGuideline);
}

@Transactional(readOnly = true)
public List<GuardGuidelineResponse> readAllGuardGuidelinesBySenior(Long memberId, Long seniorId) {
Senior senior = seniorRepository.findById(seniorId).orElseThrow(
Expand Down