diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java index 4f1089bb..bf32fd2f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java @@ -147,4 +147,11 @@ public BaseResponseDto withdrawFarmClub( farmClubService.withdrawFarmClub(farmClubId, user.getUserId(), deleteVeggie); return BaseResponseDto.of(SuccessCode.SUCCESS, null); } + + @GetMapping("/check") + public BaseResponseDto createFarmClubCheck( + @AuthenticationPrincipal CustomUser user + ) { + return BaseResponseDto.of(SuccessCode.SUCCESS, farmClubService.checkCreateFarmClub(user.getUserId())); + } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java index 82a85438..1c66ab4f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java @@ -41,6 +41,21 @@ public class FarmClubService { private final MissionPostRepository missionPostRepository; private final FarmClubRepository farmClubRepository; + public CreateFarmClubCheckResponseDto checkCreateFarmClub(Long userId) { + List myVeggieList = myVeggieHelper.getMyVeggieInfo(userId); + log.info("myVeggieList: {}", myVeggieList); + if (!myVeggieList.isEmpty()) { + return CreateFarmClubCheckResponseDto.of(true, 0L); + } else { + if (myVeggieHelper.checkMyVeggie(userId)) { + return CreateFarmClubCheckResponseDto.of(false, 1L); + } else { + return CreateFarmClubCheckResponseDto.of(false, 2L); + + } + } + } + @Transactional public CreateFarmClubResponseDto createFarmClub(CreateFarmClubRequestDto request, Long userId) { // 몽고에서 이미지, 난이도 가져오기