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

fix: /member/delete 허용 로직 구현 #102

Merged
merged 1 commit into from
Sep 22, 2023
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
@@ -1,5 +1,6 @@
package codingFriends_Server.domain.Member.entity;

import codingFriends_Server.domain.SummaryCode.entity.ScrapSummaryCode;
import codingFriends_Server.domain.SummaryCode.entity.SummaryCode;
import codingFriends_Server.global.auth.oauth.LoginProvider;
import lombok.*;
Expand Down Expand Up @@ -38,6 +39,8 @@ public class Member implements UserDetails {
@OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE)
private List<SummaryCode> summaryCodeList = new ArrayList<>();

@OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE)
private List<ScrapSummaryCode> scrapSummaryCodes = new ArrayList<>();
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authorities = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,11 @@ public ResponseEntity<?> deleteSummaryCode(@PathVariable Long id) {
return ResponseEntity.ok()
.body("summaryCode 삭제 완료");
}

@DeleteMapping("ai/summary/delete/scrap/{id}")
public ResponseEntity<?> deleteScrapSummaryCode(@PathVariable Long id) {
summaryService.deleteScrapSummaryCode(id);
return ResponseEntity.ok()
.body("ScrapSummaryCode 삭제 완료");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface ScrapSummaryCodeRepository extends JpaRepository<ScrapSummaryCo
Optional<ScrapSummaryCode> findScrapSummaryCodeByCreatedAt(LocalDateTime localDateTime);

List<ScrapSummaryCode> findScrapSummaryCodesByMemberOrderByCreatedAtDesc(Member member);

Optional<ScrapSummaryCode> findScrapSummaryCodeById(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ public List<SummaryCodeResponseDto> getScrapSummaryContents(Member member) {
}

public void deleteSummaryCode(Long id) {
SummaryCode summaryCode = summaryCodeRepository.findSummaryCodeById(id).orElseThrow(() -> new CustomException(HttpStatus.NOT_FOUND, "summaryCode를 찾을 수 없습니다."));
SummaryCode summaryCode = summaryCodeRepository.findSummaryCodeById(id).orElseThrow(
() -> new CustomException(HttpStatus.NOT_FOUND, "summaryCode를 찾을 수 없습니다."));
summaryCodeRepository.delete(summaryCode);
}

public void deleteScrapSummaryCode(Long id) {
ScrapSummaryCode scrapSummaryCode = scrapSummaryCodeRepository.findScrapSummaryCodeById(id).orElseThrow(
() -> new CustomException(HttpStatus.NOT_FOUND, "ScrapSummaryCode를 찾을 수 없습니다."));
scrapSummaryCodeRepository.delete(scrapSummaryCode);
}
}