From 945aa57f09251241a6ee37ff1db41597ee40f7a3 Mon Sep 17 00:00:00 2001 From: Jenny Kim <88226911+kmjenny@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:02:14 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"[feat]=20#16=20Post=20Delete=20Api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/harang/server/controller/PostController.java | 6 +----- src/main/java/org/harang/server/domain/Category.java | 2 +- src/main/java/org/harang/server/domain/Help.java | 2 +- src/main/java/org/harang/server/domain/Location.java | 2 +- src/main/java/org/harang/server/domain/MemberInfo.java | 4 ++-- src/main/java/org/harang/server/domain/Post.java | 4 ++-- .../org/harang/server/repository/LocationRepository.java | 9 --------- src/main/java/org/harang/server/service/PostService.java | 7 ------- 8 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/harang/server/controller/PostController.java b/src/main/java/org/harang/server/controller/PostController.java index ff2a8e0..0c021d2 100644 --- a/src/main/java/org/harang/server/controller/PostController.java +++ b/src/main/java/org/harang/server/controller/PostController.java @@ -11,6 +11,7 @@ import org.harang.server.dto.type.SuccessMessage; import org.harang.server.service.PostService; import org.springframework.web.bind.annotation.*; + import java.util.List; @Slf4j @@ -29,11 +30,6 @@ public ApiResponse createPost(@MemberId Long memberId, @Valid @RequestBody Po return ApiResponse.success(SuccessMessage.CREATED); } - @DeleteMapping("/{postId}") - public ApiResponse deletePost(@MemberId Long memberId, @PathVariable Long postId) { - postService.deletePost(memberId, postId); - return ApiResponse.success(SuccessMessage.OK); - @GetMapping public ApiResponse> getAllPosts() { return ApiResponse.success(postService.getAllPosts()); diff --git a/src/main/java/org/harang/server/domain/Category.java b/src/main/java/org/harang/server/domain/Category.java index 36d6854..f3f79d3 100644 --- a/src/main/java/org/harang/server/domain/Category.java +++ b/src/main/java/org/harang/server/domain/Category.java @@ -21,7 +21,7 @@ public class Category { @Column(name = "name", nullable = false) private String name; - @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "category") private List postCategoryList = new ArrayList<>(); @Builder diff --git a/src/main/java/org/harang/server/domain/Help.java b/src/main/java/org/harang/server/domain/Help.java index 9a0f2e1..07dd418 100644 --- a/src/main/java/org/harang/server/domain/Help.java +++ b/src/main/java/org/harang/server/domain/Help.java @@ -22,7 +22,7 @@ public class Help { private String name; /* Relation Parent Mapping */ - @OneToMany(mappedBy = "help", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "help") private List memberHelpList = new ArrayList<>(); @Builder diff --git a/src/main/java/org/harang/server/domain/Location.java b/src/main/java/org/harang/server/domain/Location.java index f54751c..ad08ce8 100644 --- a/src/main/java/org/harang/server/domain/Location.java +++ b/src/main/java/org/harang/server/domain/Location.java @@ -15,7 +15,7 @@ public class Location { @Column(name = "id", nullable = false) private Long id; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "post_id") private Post post; diff --git a/src/main/java/org/harang/server/domain/MemberInfo.java b/src/main/java/org/harang/server/domain/MemberInfo.java index 94509e3..4dc4339 100644 --- a/src/main/java/org/harang/server/domain/MemberInfo.java +++ b/src/main/java/org/harang/server/domain/MemberInfo.java @@ -32,10 +32,10 @@ public class MemberInfo { private String refreshToken; /* Relation Parent Mapping */ - @OneToMany(mappedBy = "memberInfo", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "memberInfo") private List memberHelpList = new ArrayList<>(); - @OneToMany(mappedBy = "memberInfo", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "memberInfo") private List certificationList = new ArrayList<>(); @Builder diff --git a/src/main/java/org/harang/server/domain/Post.java b/src/main/java/org/harang/server/domain/Post.java index bac69a9..381f609 100644 --- a/src/main/java/org/harang/server/domain/Post.java +++ b/src/main/java/org/harang/server/domain/Post.java @@ -55,10 +55,10 @@ public class Post { private Status status = Status.WAITING; /* Relation Parent Mapping */ - @OneToMany(mappedBy = "post", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "post") private List matchingList = new ArrayList<>(); - @OneToMany(mappedBy = "post", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "post") private List postCategoryList = new ArrayList<>(); @OneToMany(mappedBy = "post") diff --git a/src/main/java/org/harang/server/repository/LocationRepository.java b/src/main/java/org/harang/server/repository/LocationRepository.java index 0e8dd3e..05ce167 100644 --- a/src/main/java/org/harang/server/repository/LocationRepository.java +++ b/src/main/java/org/harang/server/repository/LocationRepository.java @@ -1,16 +1,7 @@ package org.harang.server.repository; -import jakarta.transaction.Transactional; import org.harang.server.domain.Location; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; public interface LocationRepository extends JpaRepository { - Location findByPostId(Long PostId); - - @Transactional - @Modifying - @Query("DELETE FROM Location l WHERE l.post.id = :postId") - void deleteByPostId(Long postId); } diff --git a/src/main/java/org/harang/server/service/PostService.java b/src/main/java/org/harang/server/service/PostService.java index a435847..46e0900 100644 --- a/src/main/java/org/harang/server/service/PostService.java +++ b/src/main/java/org/harang/server/service/PostService.java @@ -70,13 +70,6 @@ public Post createPost(Long memberId, PostRequest request) { return savedPost; } - @Transactional - public void deletePost(Long memberId, Long postId) { - Post post = postRepository.findByIdOrThrow(postId); - - locationRepository.deleteByPostId(postId); - postRepository.delete(post); - public List getAllPosts() { return postRepository.findAll() .stream()