Skip to content

Commit

Permalink
Merge pull request #254 from Onion-City/feat/clubJoinApi
Browse files Browse the repository at this point in the history
Feat: 모임 삭제 기능 구현
  • Loading branch information
Ji-minhyeok authored Aug 11, 2024
2 parents 42f93e8 + c542d12 commit 68af6fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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");
}
}
9 changes: 9 additions & 0 deletions src/main/java/GDG/whatssue/domain/club/entity/Club.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -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<ClubJoinRequest> clubJoinRequests;

@OneToMany(mappedBy = "club", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ClubMember> clubMembers;

//==연관관계 메서드==//

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

0 comments on commit 68af6fe

Please sign in to comment.