diff --git a/src/main/java/com/mookive/mookive_backend/record/application/service/RecordDeleteService.java b/src/main/java/com/mookive/mookive_backend/record/application/service/RecordDeleteService.java new file mode 100644 index 0000000..4334360 --- /dev/null +++ b/src/main/java/com/mookive/mookive_backend/record/application/service/RecordDeleteService.java @@ -0,0 +1,25 @@ +package com.mookive.mookive_backend.record.application.service; + +import com.mookive.mookive_backend.keyword.domain.service.KeywordDeleteService; +import com.mookive.mookive_backend.record.domain.service.RecordDeleteDomainService; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Transactional +public class RecordDeleteService { + + /** + * 추후 annotation 도입 시 변경 예정 + */ + private final RecordDeleteDomainService recordDeleteDomainService; + private final KeywordDeleteService keywordDeleteService; + + public void deleteRecord(Long recordId) { + keywordDeleteService.deleteAllByRecordId(recordId); + recordDeleteDomainService.delete(recordId); + } + +} diff --git a/src/main/java/com/mookive/mookive_backend/record/domain/service/RecordDeleteDomainService.java b/src/main/java/com/mookive/mookive_backend/record/domain/service/RecordDeleteDomainService.java new file mode 100644 index 0000000..d26d583 --- /dev/null +++ b/src/main/java/com/mookive/mookive_backend/record/domain/service/RecordDeleteDomainService.java @@ -0,0 +1,18 @@ +package com.mookive.mookive_backend.record.domain.service; + +import com.mookive.mookive_backend.record.domain.repository.RecordRepository; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Transactional +public class RecordDeleteDomainService { + + private final RecordRepository recordRepository; + + public void delete(Long recordId) { + recordRepository.deleteById(recordId); + } +} diff --git a/src/main/java/com/mookive/mookive_backend/record/presentation/RecordController.java b/src/main/java/com/mookive/mookive_backend/record/presentation/RecordController.java index ea410af..080cdc6 100644 --- a/src/main/java/com/mookive/mookive_backend/record/presentation/RecordController.java +++ b/src/main/java/com/mookive/mookive_backend/record/presentation/RecordController.java @@ -3,6 +3,7 @@ import com.mookive.mookive_backend.record.application.dto.request.RecordRequest; import com.mookive.mookive_backend.record.application.dto.response.RecordResponse; import com.mookive.mookive_backend.record.application.service.RecordCreateService; +import com.mookive.mookive_backend.record.application.service.RecordDeleteService; import com.mookive.mookive_backend.record.application.service.RecordGetService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -13,6 +14,7 @@ public class RecordController { private final RecordCreateService recordCreateService; private final RecordGetService recordGetService; + private final RecordDeleteService recordDeleteService; @PostMapping("/record") public void createRecord(@RequestBody RecordRequest.RecordCreateRequest recordCreateRequest) { @@ -24,4 +26,9 @@ public RecordResponse.RecordDetailResponse getRecord(@PathVariable Long recordId return recordGetService.getRecord(recordId); } + @DeleteMapping("/record/{recordId}") + public void deleteRecord(@PathVariable Long recordId) { + recordDeleteService.deleteRecord(recordId); + } + }