From 6aa74a3df9e3c5f7eca8124c9d464fe52a180903 Mon Sep 17 00:00:00 2001 From: Hanvp Date: Fri, 15 Sep 2023 16:48:18 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20=EB=8F=99=EC=A0=81=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=9C=84=ED=95=9C=20QueryDsl=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 그런데 이제 레시피 신고를 곁들인 --- build.gradle | 24 ++- .../server/config/QueryDslConfig.java | 20 ++ .../server/converter/RecipeConverter.java | 14 +- .../server/domain/recipe/BlockedComment.java | 33 --- .../server/domain/recipe/BlockedRecipe.java | 33 --- .../BlockedCommentRepository.java | 15 -- .../BlockedRecipeRepository.java | 7 - .../ReportedCommentRepository.java | 1 - .../ReportedRecipeRepository.java | 10 + .../server/service/RecipeService.java | 4 +- .../serviceImpl/RecipeServiceImpl.java | 202 ++++++++++-------- .../web/controller/RecipeRestController.java | 95 +++++--- .../web/dto/requestDto/RecipeRequestDto.java | 5 - 13 files changed, 249 insertions(+), 214 deletions(-) create mode 100644 src/main/java/zipdabang/server/config/QueryDslConfig.java delete mode 100644 src/main/java/zipdabang/server/domain/recipe/BlockedComment.java delete mode 100644 src/main/java/zipdabang/server/domain/recipe/BlockedRecipe.java delete mode 100644 src/main/java/zipdabang/server/repository/recipeRepositories/BlockedCommentRepository.java delete mode 100644 src/main/java/zipdabang/server/repository/recipeRepositories/BlockedRecipeRepository.java create mode 100644 src/main/java/zipdabang/server/repository/recipeRepositories/ReportedRecipeRepository.java diff --git a/build.gradle b/build.gradle index 76e3b6c..7c6e1e2 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,14 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE' implementation platform("org.springframework.cloud:spring-cloud-dependencies:2021.0.5") + // queryDSL 설정 + implementation "com.querydsl:querydsl-jpa" + implementation "com.querydsl:querydsl-core" + implementation "com.querydsl:querydsl-collections" + annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa" + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.mysql:mysql-connector-j' @@ -52,4 +60,18 @@ tasks.named('test') { jar { enabled = false -} \ No newline at end of file +} + +//querydsl 추가 시작 +def querydslDir = "$buildDir/generated/querydsl" + +// java source set 에 querydsl QClass 위치 추가 +sourceSets { + main.java.srcDirs += [ querydslDir ] +} + +// gradle clean 시에 QClass 디렉토리 삭제 +clean { + delete file(querydslDir) +} +//querydsl 추가 끝 \ No newline at end of file diff --git a/src/main/java/zipdabang/server/config/QueryDslConfig.java b/src/main/java/zipdabang/server/config/QueryDslConfig.java new file mode 100644 index 0000000..eb435a5 --- /dev/null +++ b/src/main/java/zipdabang/server/config/QueryDslConfig.java @@ -0,0 +1,20 @@ +package zipdabang.server.config; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +@Configuration +public class QueryDslConfig { + + @PersistenceContext + private EntityManager em; + + @Bean + JPAQueryFactory queryFactory(){ + return new JPAQueryFactory(em); + } +} diff --git a/src/main/java/zipdabang/server/converter/RecipeConverter.java b/src/main/java/zipdabang/server/converter/RecipeConverter.java index fe84d2a..121f754 100644 --- a/src/main/java/zipdabang/server/converter/RecipeConverter.java +++ b/src/main/java/zipdabang/server/converter/RecipeConverter.java @@ -387,18 +387,20 @@ public static RecipeResponseDto.CommentPageListDto toPagingCommentDtoList(Page { - List findByOwner(Member member); - - Boolean existsByOwnerAndBlocked(Member member, Comment findComment); -} diff --git a/src/main/java/zipdabang/server/repository/recipeRepositories/BlockedRecipeRepository.java b/src/main/java/zipdabang/server/repository/recipeRepositories/BlockedRecipeRepository.java deleted file mode 100644 index 63fe831..0000000 --- a/src/main/java/zipdabang/server/repository/recipeRepositories/BlockedRecipeRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package zipdabang.server.repository.recipeRepositories; - -import org.springframework.data.jpa.repository.JpaRepository; -import zipdabang.server.domain.recipe.BlockedComment; - -public interface BlockedRecipeRepository extends JpaRepository { -} diff --git a/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedCommentRepository.java b/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedCommentRepository.java index 8431dbc..e7bdef0 100644 --- a/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedCommentRepository.java +++ b/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedCommentRepository.java @@ -7,5 +7,4 @@ import zipdabang.server.domain.recipe.ReportedComment; public interface ReportedCommentRepository extends JpaRepository { - Boolean existsByReportIdAndReportedAndOwner(Report findReport, Comment findComment, Member member); } diff --git a/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedRecipeRepository.java b/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedRecipeRepository.java new file mode 100644 index 0000000..a86441f --- /dev/null +++ b/src/main/java/zipdabang/server/repository/recipeRepositories/ReportedRecipeRepository.java @@ -0,0 +1,10 @@ +package zipdabang.server.repository.recipeRepositories; + +import org.springframework.data.jpa.repository.JpaRepository; +import zipdabang.server.domain.Report; +import zipdabang.server.domain.member.Member; +import zipdabang.server.domain.recipe.Comment; +import zipdabang.server.domain.recipe.ReportedRecipe; + +public interface ReportedRecipeRepository extends JpaRepository { +} diff --git a/src/main/java/zipdabang/server/service/RecipeService.java b/src/main/java/zipdabang/server/service/RecipeService.java index 8436cb3..c038568 100644 --- a/src/main/java/zipdabang/server/service/RecipeService.java +++ b/src/main/java/zipdabang/server/service/RecipeService.java @@ -53,7 +53,7 @@ public interface RecipeService { Comment updateComment(RecipeRequestDto.updateCommentDto request, Long recipeId, Long commentId, Member member); - Long reportComment(RecipeRequestDto.reportCommentDto request, Long recipeId, Long commentId, Member member); + Long reportComment(Long recipeId, Long commentId, Long reportId, Member member); - Long blockComment(Long recipeId, Long commentId, Member member); + Long reportRecipe(Long recipeId, Long reportId, Member member); } diff --git a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java index f78bc0b..60e633e 100644 --- a/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java +++ b/src/main/java/zipdabang/server/service/serviceImpl/RecipeServiceImpl.java @@ -1,11 +1,13 @@ package zipdabang.server.service.serviceImpl; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; +import org.springframework.data.domain.*; +import org.springframework.data.support.PageableExecutionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -29,6 +31,10 @@ import java.util.Optional; import java.util.stream.Collectors; +import static zipdabang.server.domain.recipe.QComment.comment; +import static zipdabang.server.domain.recipe.QRecipe.recipe; +import static zipdabang.server.domain.recipe.QRecipeCategoryMapping.*; + @Slf4j @Service @RequiredArgsConstructor @@ -47,13 +53,20 @@ public class RecipeServiceImpl implements RecipeService { private final BlockedMemberRepository blockedMemberRepository; private final CommentRepository commentRepository; - private final BlockedCommentRepository blockedCommentRepository; private final ReportRepository reportRepository; private final ReportedCommentRepository reportedCommentRepository; + private final ReportedRecipeRepository reportedRecipeRepository; + + private final JPAQueryFactory queryFactory; + + private final JPAQueryFactory jpaQueryFactory; @Value("${paging.size}") Integer pageSize; + @Value("5") + Integer previewSize; + @Override @Transactional(readOnly = false) public Recipe create(RecipeRequestDto.CreateRecipeDto request, MultipartFile thumbnail, List stepImages, Member member) throws IOException { @@ -123,62 +136,82 @@ public Boolean getScrap(Recipe recipe, Member member) { @Override public Page searchRecipe(Long categoryId, String keyword, Integer pageIndex, Member member) { - List blockedMember = getBlockedMembers(member); - List recipeCategory = recipeCategoryRepository.findAllById(categoryId); if(recipeCategory.isEmpty()) throw new RecipeException(Code.RECIPE_NOT_FOUND); - List recipeIdList = recipeCategoryMappingRepository.findByCategoryIn(recipeCategory).stream() - .map(categoryMapping -> categoryMapping.getRecipe().getId()) - .collect(Collectors.toList()); - - if(blockedMember.isEmpty()) - return recipeRepository.findByIdInAndNameContaining(recipeIdList, keyword, - PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - else - return recipeRepository.findByIdInAndNameContainingAndMemberNotIn(recipeIdList, keyword,blockedMember, - PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - + QRecipe qRecipe = recipe; + QRecipeCategoryMapping qRecipeCategoryMapping = recipeCategoryMapping; + + List content = queryFactory + .selectFrom(recipe) + .join(recipe.categoryMappingList, recipeCategoryMapping).fetchJoin() + .where(blockedMemberNotInForRecipe(member), + recipe.name.contains(keyword), + recipeCategoryMapping.category.id.eq(categoryId) + ) + .orderBy(recipe.createdAt.desc()) + .offset(pageIndex*pageSize) + .limit(pageSize) + .fetch(); + + JPAQuery count = queryFactory + .select(recipe.count()) + .from(recipe) + .join(recipe.categoryMappingList, recipeCategoryMapping) + .where(blockedMemberNotInForRecipe(member), + recipe.name.contains(keyword), + recipeCategoryMapping.category.id.eq(categoryId) + ); + + return new PageImpl<>(content,PageRequest.of(pageIndex,pageSize), count.fetchOne()); } @Override public List getWrittenByRecipePreview(String writtenby, Member member) { - List recipeList = new ArrayList<>(); - List blockedMember = getBlockedMembers(member); + QRecipe qRecipe = recipe; - if (!blockedMember.isEmpty()) { - if (writtenby.equals("all")) { - recipeList = recipeRepository.findTop5ByMemberNotInOrderByCreatedAtDesc(blockedMember); - log.info("all: ", recipeList.toString()); - } else if (writtenby.equals("influencer")) { - recipeList = recipeRepository.findTop5ByIsInfluencerTrueAndMemberNotInOrderByCreatedAtDesc(blockedMember); - log.info("influencer: ", recipeList.toString()); - } else if (writtenby.equals("common")) { - recipeList = recipeRepository.findTop5ByIsInfluencerFalseAndMemberNotInOrderByCreatedAtDesc(blockedMember); - log.info("common: ", recipeList.toString()); - } else - throw new RecipeException(Code.WRITTEN_BY_TYPE_ERROR); - } - else{ - if (writtenby.equals("all")) { - recipeList = recipeRepository.findTop5ByOrderByCreatedAtDesc(); - log.info("all: ", recipeList.toString()); - } else if (writtenby.equals("influencer")) { - recipeList = recipeRepository.findTop5ByIsInfluencerTrueOrderByCreatedAtDesc(); - log.info("influencer: ", recipeList.toString()); - } else if (writtenby.equals("common")) { - recipeList = recipeRepository.findTop5ByIsInfluencerFalseOrderByCreatedAtDesc(); - log.info("common: ", recipeList.toString()); - } else - throw new RecipeException(Code.WRITTEN_BY_TYPE_ERROR); - } + List recipeList = queryFactory + .selectFrom(recipe) + .where(blockedMemberNotInForRecipe(member), + checkWrittenBy(writtenby) + ) + .limit(previewSize) + .orderBy(recipe.createdAt.desc()) + .fetch(); + + log.info(recipeList.toString()); return recipeList; } + private BooleanExpression checkWrittenBy(String writtenby) { + if (writtenby.equals("influencer")) + return recipe.isInfluencer.eq(true); + else if (writtenby.equals("common")) + return recipe.isInfluencer.eq(false); + else if (writtenby.equals("all")) + return null; + else + throw new RecipeException(Code.WRITTEN_BY_TYPE_ERROR); + } + + private BooleanExpression blockedMemberNotInForRecipe(Member member) { + List blockedMember = getBlockedMember(member); + + return blockedMember.isEmpty() ? null : recipe.member.notIn(blockedMember); + } + + private List getBlockedMember(Member member) { + List blockedMember = blockedMemberRepository.findByOwner(member).stream() + .map(blockedInfo -> blockedInfo.getBlocked()) + .collect(Collectors.toList()); + return blockedMember; + } + + @Override @Transactional(readOnly = false) public Recipe updateLikeOnRecipe(Long recipeId, Member member) { @@ -297,9 +330,8 @@ public List> searchRecipePreview(String keyword, Member member) { } private List getBlockedMembers(Member member) { - List blockedMember = blockedMemberRepository.findByOwner(member).stream() - .map(blockedInfo -> blockedInfo.getBlocked()) - .collect(Collectors.toList()); + List blockedMember = getBlockedMember(member); + return blockedMember; } @@ -324,6 +356,22 @@ public Boolean deleteRecipe(Long recipeId, Member member) { return recipeRepository.existsById(recipeId) == false; } + @Transactional(readOnly = false) + @Override + public Long reportRecipe(Long recipeId, Long reportId, Member member) { + Recipe findRecipe = recipeRepository.findById(recipeId).orElseThrow(() -> new RecipeException(Code.NO_RECIPE_EXIST)); + Report findReport = reportRepository.findById(reportId).orElseThrow(() -> new RecipeException(Code.NO_REPORT_EXIST)); + + if (!findRecipe.getMember().equals(member)) { + ReportedRecipe mapping = RecipeConverter.toRecipeReport(findReport, findRecipe, member); + reportedRecipeRepository.save(mapping); + + return findRecipe.getId(); + } + else + throw new RecipeException(Code.RECIPE_OWNER); + } + @Transactional(readOnly = false) @Override public Comment createComment(String content, Long recipeId, Member member) { @@ -337,27 +385,29 @@ public Comment createComment(String content, Long recipeId, Member member) { public Page commentList(Integer pageIndex, Long recipeId, Member member) { recipeRepository.findById(recipeId).orElseThrow(() -> new RecipeException(Code.NO_RECIPE_EXIST)); - List blockedMember = getBlockedMembers(member); - List blockedComment = getBlockedComment(member); - - if(blockedMember.isEmpty() && blockedComment.isEmpty()) - return commentRepository.findAll( - PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - else if(!blockedMember.isEmpty() && blockedComment.isEmpty()) - return commentRepository.findByMemberNotIn(blockedMember, PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - else if(blockedMember.isEmpty() && !blockedComment.isEmpty()) - return commentRepository.findByIdNotIn(blockedComment, PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - else - return commentRepository.findByIdNotInAndMemberNotIn(blockedComment, blockedMember, PageRequest.of(pageIndex, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"))); - } + QComment qComment = comment; - private List getBlockedComment(Member member) { + List content = queryFactory + .selectFrom(comment) + .where(blockedMemberNotInForComment(member)) + .orderBy(comment.createdAt.desc()) + .offset(pageIndex*pageSize) + .limit(pageSize) + .fetch(); - List blockedCommentIdList = blockedCommentRepository.findByOwner(member).stream() - .map(blockedInfo -> blockedInfo.getBlocked().getId()) - .collect(Collectors.toList()); - return blockedCommentIdList; + JPAQuery count = queryFactory + .select(comment.count()) + .from(comment) + .where(blockedMemberNotInForComment(member)); + + return PageableExecutionUtils.getPage(content,PageRequest.of(pageIndex,pageSize), ()->count.fetchOne()); + } + + private BooleanExpression blockedMemberNotInForComment(Member member) { + List blockedMember = getBlockedMember(member); + + return blockedMember.isEmpty() ? null : comment.member.notIn(blockedMember); } @Transactional(readOnly = false) @@ -391,10 +441,10 @@ public Comment updateComment(RecipeRequestDto.updateCommentDto request, Long rec @Transactional(readOnly = false) @Override - public Long reportComment(RecipeRequestDto.reportCommentDto request, Long recipeId, Long commentId, Member member) { + public Long reportComment(Long recipeId, Long commentId, Long reportId, Member member) { Recipe findRecipe = recipeRepository.findById(recipeId).orElseThrow(() -> new RecipeException(Code.NO_RECIPE_EXIST)); Comment findComment = commentRepository.findById(commentId).orElseThrow(() -> new RecipeException(Code.NO_COMMENT_EXIST)); - Report findReport = reportRepository.findById(request.getReportId()).orElseThrow(() -> new RecipeException(Code.NO_REPORT_EXIST)); + Report findReport = reportRepository.findById(reportId).orElseThrow(() -> new RecipeException(Code.NO_REPORT_EXIST)); if (!findComment.getMember().equals(member) && findComment.getRecipe().equals(findRecipe)) { ReportedComment mapping = RecipeConverter.toCommentReport(findReport, findComment, member); @@ -405,20 +455,4 @@ public Long reportComment(RecipeRequestDto.reportCommentDto request, Long recipe else throw new RecipeException(Code.COMMENT_OWNER); } - - @Transactional(readOnly = false) - @Override - public Long blockComment(Long recipeId, Long commentId, Member member) { - Recipe findRecipe = recipeRepository.findById(recipeId).orElseThrow(() -> new RecipeException(Code.NO_RECIPE_EXIST)); - Comment findComment = commentRepository.findById(commentId).orElseThrow(() -> new RecipeException(Code.NO_COMMENT_EXIST)); - - if (!findComment.getMember().equals(member) && findComment.getRecipe().equals(findRecipe)) { - BlockedComment mapping = RecipeConverter.toCommentBlock(findComment, member); - blockedCommentRepository.save(mapping); - - return findComment.getId(); - } - else - throw new RecipeException(Code.COMMENT_OWNER); - } } diff --git a/src/main/java/zipdabang/server/web/controller/RecipeRestController.java b/src/main/java/zipdabang/server/web/controller/RecipeRestController.java index d5adaab..28e8608 100644 --- a/src/main/java/zipdabang/server/web/controller/RecipeRestController.java +++ b/src/main/java/zipdabang/server/web/controller/RecipeRestController.java @@ -162,7 +162,7 @@ public ResponseDto searchRecipePre @Parameter(name = "keyword", description = "query string 검색할 단어") }) @GetMapping(value = "/members/recipes/search/{categoryId}") - public ResponseDto searchRecipe(@PathVariable Long categoryId, @RequestParam(name = "keyword", required = false) String keyword, @RequestParam(name = "pageIndex", required = false) Integer pageIndex, @AuthMember Member member) { + public ResponseDto searchRecipe(@PathVariable Long categoryId, @RequestParam(name = "keyword") String keyword, @RequestParam(name = "pageIndex", required = false) Integer pageIndex, @AuthMember Member member) { if (recipeService.checkRecipeCategoryExist(categoryId) == false) throw new RecipeException(Code.NO_RECIPE_CATEGORY_EXIST); @@ -176,8 +176,6 @@ else if (pageIndex < 1) Page recipes = recipeService.searchRecipe(categoryId, keyword, pageIndex, member); - log.info(recipes.toString()); - if (recipes.getTotalElements() == 0) throw new RecipeException(Code.RECIPE_NOT_FOUND); if (pageIndex >= recipes.getTotalPages()) @@ -372,6 +370,49 @@ public ResponseDto showCategoryList() { return ResponseDto.of(RecipeConverter.RecipeCategoryListDto(allCategories)); } + @Operation(summary = "레시피 신고 API 🔑 ✔", description = "레시피 신고 API입니다.") + @ApiResponses({ + @ApiResponse(responseCode = "2000", description = "OK, 레시피가 신고 되었습니다."), + @ApiResponse(responseCode = "4003", description = "UNAUTHORIZED, 토큰 모양이 이상함, 토큰 제대로 주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4005", description = "UNAUTHORIZED, 엑세스 토큰 만료, 리프레시 토큰 사용", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4008", description = "UNAUTHORIZED, 토큰 없음, 토큰 줘요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4052", description = "BAD_REQUEST, 사용자가 없습니다. 이 api에서 이거 생기면 백앤드 개발자 호출", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4060", description = "BAD_REQUEST, 해당 id를 가진 신고 목록이 없습니다. 잘못 보내줬어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4101", description = "BAD_REQUEST, 해당 recipeId를 가진 recipe가 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4109", description = "BAD_REQUEST, 본인의 레시피입니다. 신고/차단할 수 없습니다", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "5000", description = "SERVER ERROR, 백앤드 개발자에게 알려주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + }) + @Parameters({ + @Parameter(name = "member", hidden = true), + }) + @GetMapping("/members/recipes/{recipeId}/report/{reportId}") + public ResponseDto reportRecipe(@PathVariable Long recipeId, @PathVariable Long reportId, @CheckTempMember @AuthMember Member member) { + Long reportedRecipeId = recipeService.reportRecipe(recipeId, reportId, member); + + return ResponseDto.of(reportedRecipeId+"번 레시피가 신고되었습니다."); + } + +// @Operation(summary = "레시피 차단 API 🔑 ✔", description = "래시피 차단 API입니다.") +// @ApiResponses({ +// @ApiResponse(responseCode = "2000", description = "OK, 레시피가 차단 되었습니다."), +// @ApiResponse(responseCode = "4003", description = "UNAUTHORIZED, 토큰 모양이 이상함, 토큰 제대로 주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4005", description = "UNAUTHORIZED, 엑세스 토큰 만료, 리프레시 토큰 사용", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4008", description = "UNAUTHORIZED, 토큰 없음, 토큰 줘요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4052", description = "BAD_REQUEST, 사용자가 없습니다. 이 api에서 이거 생기면 백앤드 개발자 호출", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4101", description = "BAD_REQUEST, 해당 recipeId를 가진 recipe가 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4109", description = "BAD_REQUEST, 본인의 레시피입니다. 신고/차단할 수 없습니다", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "5000", description = "SERVER ERROR, 백앤드 개발자에게 알려주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// }) +// @Parameters({ +// @Parameter(name = "member", hidden = true), +// }) +// @GetMapping("/members/recipes/{recipeId}/block") +// public ResponseDto blockRecipe(@PathVariable(name = "recipeId") Long recipeId, @CheckTempMember @AuthMember Member member) { +// Long blockRecipeId = recipeService.blockRecipe(recipeId, member); +// +// return ResponseDto.of(blockRecipeId+"번 레시피가 차단되었습니다."); +// } + @Operation(summary = "댓글 등록 API 🔑 ✔", description = "레시피 (작성)등록 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "2000"), @@ -493,32 +534,32 @@ public ResponseDto updateComment(@RequestBody Reci @Parameters({ @Parameter(name = "member", hidden = true), }) - @PostMapping("/members/recipes/{recipeId}/{commentId}/report") - public ResponseDto reportComment(@RequestBody RecipeRequestDto.reportCommentDto request, @PathVariable(name = "recipeId") Long recipeId, @PathVariable(name = "commentId") Long commentId, @CheckTempMember @AuthMember Member member) { - Long reportedCommentId = recipeService.reportComment(request, recipeId,commentId, member); + @GetMapping("/members/recipes/{recipeId}/{commentId}/report/{reportId}") + public ResponseDto reportComment(@PathVariable Long recipeId, @PathVariable Long commentId,@PathVariable Long reportId, @CheckTempMember @AuthMember Member member) { + Long reportedCommentId = recipeService.reportComment(recipeId,commentId, reportId, member); return ResponseDto.of(reportedCommentId+"번 댓글이 신고되었습니다."); } - @Operation(summary = "댓글 차단 API 🔑 ✔", description = "댓글 차단 API입니다.") - @ApiResponses({ - @ApiResponse(responseCode = "2000", description = "OK, 댓글이 차단 되었습니다."), - @ApiResponse(responseCode = "4003", description = "UNAUTHORIZED, 토큰 모양이 이상함, 토큰 제대로 주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4005", description = "UNAUTHORIZED, 엑세스 토큰 만료, 리프레시 토큰 사용", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4008", description = "UNAUTHORIZED, 토큰 없음, 토큰 줘요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4052", description = "BAD_REQUEST, 사용자가 없습니다. 이 api에서 이거 생기면 백앤드 개발자 호출", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4101", description = "BAD_REQUEST, 해당 recipeId를 가진 recipe가 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4107", description = "BAD_REQUEST, 해당 commentId를 가진 댓글이 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "4110", description = "BAD_REQUEST, 본인의 댓글입니다. 신고/차단할 수 없습니다", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - @ApiResponse(responseCode = "5000", description = "SERVER ERROR, 백앤드 개발자에게 알려주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), - }) - @Parameters({ - @Parameter(name = "member", hidden = true), - }) - @GetMapping("/members/recipes/{recipeId}/{commentId}/block") - public ResponseDto blockComment(@PathVariable(name = "recipeId") Long recipeId, @PathVariable(name = "commentId") Long commentId, @CheckTempMember @AuthMember Member member) { - Long blockCommentId = recipeService.blockComment(recipeId, commentId, member); - - return ResponseDto.of(blockCommentId+"번 댓글이 차단되었습니다."); - } +// @Operation(summary = "댓글 차단 API 🔑 ✔", description = "댓글 차단 API입니다.") +// @ApiResponses({ +// @ApiResponse(responseCode = "2000", description = "OK, 댓글이 차단 되었습니다."), +// @ApiResponse(responseCode = "4003", description = "UNAUTHORIZED, 토큰 모양이 이상함, 토큰 제대로 주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4005", description = "UNAUTHORIZED, 엑세스 토큰 만료, 리프레시 토큰 사용", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4008", description = "UNAUTHORIZED, 토큰 없음, 토큰 줘요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4052", description = "BAD_REQUEST, 사용자가 없습니다. 이 api에서 이거 생기면 백앤드 개발자 호출", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4101", description = "BAD_REQUEST, 해당 recipeId를 가진 recipe가 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4107", description = "BAD_REQUEST, 해당 commentId를 가진 댓글이 없어요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "4110", description = "BAD_REQUEST, 본인의 댓글입니다. 신고/차단할 수 없습니다", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// @ApiResponse(responseCode = "5000", description = "SERVER ERROR, 백앤드 개발자에게 알려주세요", content = @Content(schema = @Schema(implementation = ResponseDto.class))), +// }) +// @Parameters({ +// @Parameter(name = "member", hidden = true), +// }) +// @GetMapping("/members/recipes/{recipeId}/{commentId}/block") +// public ResponseDto blockComment(@PathVariable(name = "recipeId") Long recipeId, @PathVariable(name = "commentId") Long commentId, @CheckTempMember @AuthMember Member member) { +// Long blockCommentId = recipeService.blockComment(recipeId, commentId, member); +// +// return ResponseDto.of(blockCommentId+"번 댓글이 차단되었습니다."); +// } } diff --git a/src/main/java/zipdabang/server/web/dto/requestDto/RecipeRequestDto.java b/src/main/java/zipdabang/server/web/dto/requestDto/RecipeRequestDto.java index 62773dc..e814c78 100644 --- a/src/main/java/zipdabang/server/web/dto/requestDto/RecipeRequestDto.java +++ b/src/main/java/zipdabang/server/web/dto/requestDto/RecipeRequestDto.java @@ -45,9 +45,4 @@ public static class createCommentDto { public static class updateCommentDto { private String comment; } - - @Getter - public static class reportCommentDto { - private Long reportId; - } }