diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index b64cef6..9b13c4d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -2,7 +2,7 @@ name: ModernFarmer CI/CD on: push: - branches: ["feature_29/코드-정리"] + branches: ["feature_32/계정-삭제-api"] pull_request: branches: ["dev"] diff --git a/src/main/java/modernfarmer/server/farmususer/community/CommunityServiceFeignClient.java b/src/main/java/modernfarmer/server/farmususer/community/CommunityServiceFeignClient.java new file mode 100644 index 0000000..8046079 --- /dev/null +++ b/src/main/java/modernfarmer/server/farmususer/community/CommunityServiceFeignClient.java @@ -0,0 +1,20 @@ +package modernfarmer.server.farmususer.community; + + +import modernfarmer.server.farmususer.user.dto.response.BaseResponseDto; +import modernfarmer.server.farmususer.user.entity.BaseEntity; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(url = "http://3.38.2.59:8082", name = "community-service") +public interface CommunityServiceFeignClient { + + @DeleteMapping("/api/community/posting/all-posting/{userId}") + void deleteAllPosting(@PathVariable("userId") Long userId); + + + + +} diff --git a/src/main/java/modernfarmer/server/farmususer/farm/FarmServiceFeignClient.java b/src/main/java/modernfarmer/server/farmususer/farm/FarmServiceFeignClient.java new file mode 100644 index 0000000..667dcf9 --- /dev/null +++ b/src/main/java/modernfarmer/server/farmususer/farm/FarmServiceFeignClient.java @@ -0,0 +1,14 @@ +package modernfarmer.server.farmususer.farm; + + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient(url = "http://3.36.221.140:8081", name = "farm-service") +public interface FarmServiceFeignClient { + + @DeleteMapping("/api/veggie/{userId}") + void deleteAllVeggies(@PathVariable("userId") Long userId); + +} diff --git a/src/main/java/modernfarmer/server/farmususer/user/entity/UserFirebaseToken.java b/src/main/java/modernfarmer/server/farmususer/user/entity/UserFirebaseToken.java index d9ad3cb..6f6968f 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/entity/UserFirebaseToken.java +++ b/src/main/java/modernfarmer/server/farmususer/user/entity/UserFirebaseToken.java @@ -28,8 +28,7 @@ public class UserFirebaseToken extends BaseEntity{ private String token; @NotNull - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @OnDelete(action = OnDeleteAction.CASCADE) + @ManyToOne(fetch = FetchType.LAZY, optional = false, cascade = CascadeType.REMOVE) @JoinColumn(name = "user_id", nullable = false) private User user; diff --git a/src/main/java/modernfarmer/server/farmususer/user/entity/UserMotivation.java b/src/main/java/modernfarmer/server/farmususer/user/entity/UserMotivation.java index 9c5d852..1a7e9c6 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/entity/UserMotivation.java +++ b/src/main/java/modernfarmer/server/farmususer/user/entity/UserMotivation.java @@ -27,8 +27,7 @@ public class UserMotivation extends BaseEntity{ private User user; @NotNull - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @OnDelete(action = OnDeleteAction.CASCADE) + @ManyToOne(fetch = FetchType.LAZY, optional = false, cascade = CascadeType.REMOVE) @JoinColumn(name = "motivation_id", nullable = false) private Motivation motivation; diff --git a/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java b/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java index 43cc7ad..be251bf 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java +++ b/src/main/java/modernfarmer/server/farmususer/user/service/UserService.java @@ -2,6 +2,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import modernfarmer.server.farmususer.community.CommunityServiceFeignClient; +import modernfarmer.server.farmususer.farm.FarmServiceFeignClient; import modernfarmer.server.farmususer.global.config.s3.S3Uploader; import modernfarmer.server.farmususer.global.exception.fail.ErrorMessage; import modernfarmer.server.farmususer.global.exception.success.SuccessMessage; @@ -32,6 +34,8 @@ public class UserService { private final UserRepository userRepository; private final S3Uploader s3Uploader; private final TimeCalculator timeCalculator; + private final CommunityServiceFeignClient communityServiceFeignClient; + private final FarmServiceFeignClient farmServiceFeignClient; // public BaseResponseDto emitProfileImage(Long userId, MultipartFile multipartFile) throws IOException { @@ -113,6 +117,8 @@ public BaseResponseDto signUpComlete(Long userId){ public BaseResponseDto deleteUser(Long userId){ userRepository.deleteUser(userId); + communityServiceFeignClient.deleteAllPosting(userId); + farmServiceFeignClient.deleteAllVeggies(userId); log.info("유저 계정 삭제 완료");