diff --git a/src/main/java/GDG/whatssue/domain/club/controller/ClubController.java b/src/main/java/GDG/whatssue/domain/club/controller/ClubController.java index 9afac44f..3b01b125 100644 --- a/src/main/java/GDG/whatssue/domain/club/controller/ClubController.java +++ b/src/main/java/GDG/whatssue/domain/club/controller/ClubController.java @@ -26,15 +26,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; /** @@ -132,9 +124,11 @@ public ResponseEntity getClubInfo(@PathVariable("clubId") Long clubId) { return ResponseEntity.status(HttpStatus.OK).body(responseDto); } -// @DeleteMapping -// public ResponseEntity deleteClub() { -// //TODO -// return null; -// } + @ClubManager + @Operation(summary = "모임 삭제") + @DeleteMapping("/{clubId}/delete") + public ResponseEntity deleteClub(@PathVariable("clubId") Long clubId){ + clubService.deleteClub(clubId); + return ResponseEntity.status(HttpStatus.OK).body("OK"); + } } diff --git a/src/main/java/GDG/whatssue/domain/club/entity/Club.java b/src/main/java/GDG/whatssue/domain/club/entity/Club.java index d27b3933..cfc614ae 100644 --- a/src/main/java/GDG/whatssue/domain/club/entity/Club.java +++ b/src/main/java/GDG/whatssue/domain/club/entity/Club.java @@ -3,11 +3,14 @@ import GDG.whatssue.domain.club.dto.UpdateClubInfoRequest; import GDG.whatssue.domain.club.exception.ClubErrorCode; +import GDG.whatssue.domain.clubjoinrequest.entity.ClubJoinRequest; import GDG.whatssue.domain.file.entity.ClubProfileImage; +import GDG.whatssue.domain.member.entity.ClubMember; import GDG.whatssue.global.common.BaseEntity; import GDG.whatssue.global.error.CommonException; import jakarta.persistence.*; +import java.util.List; import java.util.UUID; import lombok.*; @@ -46,6 +49,12 @@ public class Club extends BaseEntity { @OneToOne(mappedBy = "club", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) //지연 로딩 private ClubProfileImage profileImage; + @OneToMany(mappedBy = "club", cascade = CascadeType.ALL, orphanRemoval = true) + private List clubJoinRequests; + + @OneToMany(mappedBy = "club", cascade = CascadeType.ALL, orphanRemoval = true) + private List clubMembers; + //==연관관계 메서드==// /** diff --git a/src/main/java/GDG/whatssue/domain/club/service/ClubService.java b/src/main/java/GDG/whatssue/domain/club/service/ClubService.java index b55f17f4..a6286e8b 100644 --- a/src/main/java/GDG/whatssue/domain/club/service/ClubService.java +++ b/src/main/java/GDG/whatssue/domain/club/service/ClubService.java @@ -127,5 +127,10 @@ private Club findClub(Long clubId) { return clubRepository.findById(clubId).orElseThrow(() -> new CommonException(ClubErrorCode.EX3100)); } + @Transactional + public void deleteClub(Long clubId) { + Club club = findClub(clubId); + clubRepository.delete(club); + } }