diff --git a/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java b/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java index 8508baa..dfff7d0 100644 --- a/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java +++ b/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java @@ -12,6 +12,7 @@ import zipdabang.server.repository.UuidRepository; import java.io.IOException; +import java.util.List; import java.util.UUID; @Slf4j @@ -39,6 +40,13 @@ public String getPattern(){ public void deleteFile(String keyname) { log.info("KEY NAME : " + keyname); amazonS3.deleteObject(amazonConfig.getBucket(),keyname); + + String[] keynameSplit = keyname.split("/"); + String getUuid = keynameSplit[keynameSplit.length-1]; + log.info(getUuid); + + uuidRepository.deleteByUuid(getUuid); + log.info("해당 uuid 삭제: "+ !uuidRepository.existsByUuid(getUuid)); } public String generateMemberKeyName(Uuid uuid, String originalFilename) { @@ -61,6 +69,7 @@ public Uuid createUUID() { savedUuid = createUUID(); } savedUuid = uuidRepository.save(Uuid.builder().uuid(candidate).build()); + return savedUuid; } } diff --git a/src/main/java/zipdabang/server/converter/RecipeConverter.java b/src/main/java/zipdabang/server/converter/RecipeConverter.java index 2aebc28..ad01d8b 100644 --- a/src/main/java/zipdabang/server/converter/RecipeConverter.java +++ b/src/main/java/zipdabang/server/converter/RecipeConverter.java @@ -11,6 +11,7 @@ import zipdabang.server.domain.member.Member; import zipdabang.server.domain.recipe.*; import zipdabang.server.repository.recipeRepositories.*; +import zipdabang.server.utils.converter.TimeConverter; import zipdabang.server.web.dto.requestDto.RecipeRequestDto; import zipdabang.server.web.dto.responseDto.RecipeResponseDto; @@ -37,10 +38,12 @@ public class RecipeConverter { private final RecipeBannerRepository recipeBannerRepository; private final CommentRepository commentRepository; private final AmazonS3Manager amazonS3Manager; + private final TimeConverter timeConverter; private static RecipeRepository staticRecipeRepository; private static RecipeCategoryMappingRepository staticRecipeCategoryMappingRepository; + private static LikesRepository staticLikesRepository; private static ScrapRepository staticScrapRepository; @@ -49,6 +52,7 @@ public class RecipeConverter { private static RecipeBannerRepository staticRecipeBannerRepository; private static CommentRepository staticCommentRepository; private static AmazonS3Manager staticAmazonS3Manager; + private static TimeConverter staticTimeConverter; @PostConstruct @@ -61,6 +65,7 @@ public void init() { this.staticAmazonS3Manager = this.amazonS3Manager; this.staticLikesRepository = this.likesRepository; this.staticScrapRepository = this.scrapRepository; + this.staticTimeConverter = this.timeConverter; } public static RecipeResponseDto.RecipePageListDto toPagingRecipeDtoList(Page recipes, Member member) { @@ -113,7 +118,8 @@ private static RecipeResponseDto.RecipeSimpleDto toResponseRecipeSimpleDto(Recip .recipeName(recipe.getName()) .nickname(recipe.getMember().getNickname()) .thumbnailUrl(recipe.getThumbnailUrl()) - .createdAt(recipe.getCreatedAt().toLocalDate()) + .createdAt(staticTimeConverter.ConvertTime(recipe.getCreatedAt())) + .updatedAt(staticTimeConverter.ConvertTime(recipe.getUpdatedAt())) .likes(recipe.getTotalLike()) .scraps(recipe.getTotalScrap()) .isLiked(staticLikesRepository.findByRecipeAndMember(recipe, member).isPresent()) @@ -148,7 +154,7 @@ public static List toIngredient(RecipeRequestDto.CreateRecipeDto req public static RecipeResponseDto.RecipeStatusDto toRecipeStatusDto(Recipe recipe) { return RecipeResponseDto.RecipeStatusDto.builder() .recipeId(recipe.getId()) - .calledAt(recipe.getCreatedAt()) + .calledAt(staticTimeConverter.ConvertTime(recipe.getCreatedAt())) .build(); } @@ -200,7 +206,8 @@ public static RecipeResponseDto.RecipeDto toResponseRecipeDto(Recipe recipe, Boo .time(recipe.getTime()) .intro(recipe.getIntro()) .recipeTip(recipe.getRecipeTip()) - .createdAt(recipe.getCreatedAt().toLocalDate()) + .createdAt(staticTimeConverter.ConvertTime(recipe.getCreatedAt())) + .updatedAt(staticTimeConverter.ConvertTime(recipe.getUpdatedAt())) .likes(recipe.getTotalLike()) .comments(Long.valueOf(recipe.getCommentList().size())) .scraps(recipe.getTotalScrap()) @@ -360,7 +367,8 @@ public static RecipeResponseDto.CommentDto toCommentDto(Comment createdComment, .ownerNickname(createdComment.getMember().getNickname()) .ownerImage(createdComment.getMember().getProfileUrl()) .isOwner(createdComment.getMember() == member) - .createdAt(createdComment.getCreatedAt().toLocalDate()) + .createdAt(staticTimeConverter.ConvertTime(createdComment.getCreatedAt())) + .updatedAt(staticTimeConverter.ConvertTime(createdComment.getUpdatedAt())) .ownerId(createdComment.getMember().getMemberId()) .commentId(createdComment.getId()) .build(); diff --git a/src/main/java/zipdabang/server/repository/UuidRepository.java b/src/main/java/zipdabang/server/repository/UuidRepository.java index 4a693e1..595d689 100644 --- a/src/main/java/zipdabang/server/repository/UuidRepository.java +++ b/src/main/java/zipdabang/server/repository/UuidRepository.java @@ -5,4 +5,6 @@ public interface UuidRepository extends JpaRepository { boolean existsByUuid(String uuid); + + void deleteByUuid(String uuid); } diff --git a/src/main/java/zipdabang/server/web/controller/RecipeRestController.java b/src/main/java/zipdabang/server/web/controller/RecipeRestController.java index 9c044da..ccc800e 100644 --- a/src/main/java/zipdabang/server/web/controller/RecipeRestController.java +++ b/src/main/java/zipdabang/server/web/controller/RecipeRestController.java @@ -109,9 +109,9 @@ public ResponseDto recipeDetail(@PathVariable(n }) @DeleteMapping("/members/recipes/{recipeId}") public ResponseDto deleteRecipe(@PathVariable(name = "recipeId") Long recipeId, @CheckTempMember @AuthMember Member member) { - Boolean reicpeDeleteBoolean = recipeService.deleteRecipe(recipeId, member); + Boolean recipeDeleteBoolean = recipeService.deleteRecipe(recipeId, member); - if (reicpeDeleteBoolean) + if (recipeDeleteBoolean) return ResponseDto.of(recipeId + " 레시피 삭제 완료"); else throw new RecipeException(Code.INTERNAL_ERROR); diff --git a/src/main/java/zipdabang/server/web/dto/responseDto/RecipeResponseDto.java b/src/main/java/zipdabang/server/web/dto/responseDto/RecipeResponseDto.java index a9685de..37ce0c8 100644 --- a/src/main/java/zipdabang/server/web/dto/responseDto/RecipeResponseDto.java +++ b/src/main/java/zipdabang/server/web/dto/responseDto/RecipeResponseDto.java @@ -17,7 +17,7 @@ public class RecipeResponseDto { @NoArgsConstructor(access = AccessLevel.PROTECTED) public static class RecipeStatusDto{ private Long recipeId; - private LocalDateTime calledAt; + private String calledAt; } @Builder @@ -30,7 +30,8 @@ public static class RecipeSimpleDto { private String recipeName; private String nickname; private String thumbnailUrl; - private LocalDate createdAt; + private String createdAt; + private String updatedAt; private Long likes; private Long comments; private Long scraps; @@ -52,7 +53,8 @@ public static class RecipeDto { private String time; private String intro; private String recipeTip; - private LocalDate createdAt; + private String createdAt; + private String updatedAt; private Long likes; private Long comments; private Long scraps; @@ -139,7 +141,8 @@ public static class CommentDto{ private String ownerImage; private Boolean isOwner; private String content; - private LocalDate createdAt; + private String createdAt; + private String updatedAt; private Long ownerId; private Long commentId; }