Skip to content

Commit

Permalink
[feat] 리뷰 전체 삭제하는 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
syyling committed Apr 11, 2024
1 parent 866267b commit 1aaf2d9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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) {
Expand All @@ -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);
}

}

0 comments on commit 1aaf2d9

Please sign in to comment.