Skip to content

Commit

Permalink
Merge pull request #131 from zipdabang/feature/121
Browse files Browse the repository at this point in the history
Feature/121 ♻️ ✨ QueryDsl refactoring, 레시피 신고 api 완성
  • Loading branch information
Hanvp authored Sep 15, 2023
2 parents 40e268e + d6c1629 commit 754e7bf
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 214 deletions.
24 changes: 23 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -52,4 +60,18 @@ tasks.named('test') {

jar {
enabled = false
}
}

//querydsl 추가 시작
def querydslDir = "$buildDir/generated/querydsl"

// java source set 에 querydsl QClass 위치 추가
sourceSets {
main.java.srcDirs += [ querydslDir ]
}

// gradle clean 시에 QClass 디렉토리 삭제
clean {
delete file(querydslDir)
}
//querydsl 추가 끝
20 changes: 20 additions & 0 deletions src/main/java/zipdabang/server/config/QueryDslConfig.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
14 changes: 8 additions & 6 deletions src/main/java/zipdabang/server/converter/RecipeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,20 @@ public static RecipeResponseDto.CommentPageListDto toPagingCommentDtoList(Page<C
.build();
}

public static ReportedComment toCommentReport(Report report, Comment comment, Member member) {
return ReportedComment.builder()
public static ReportedRecipe toRecipeReport(Report report, Recipe recipe, Member member) {
return ReportedRecipe.builder()
.reportId(report)
.reported(comment)
.reported(recipe)
.owner(member)
.build();
}

public static BlockedComment toCommentBlock(Comment comment, Member member) {
return BlockedComment.builder()
.blocked(comment)
public static ReportedComment toCommentReport(Report report, Comment comment, Member member) {
return ReportedComment.builder()
.reportId(report)
.reported(comment)
.owner(member)
.build();
}

}
33 changes: 0 additions & 33 deletions src/main/java/zipdabang/server/domain/recipe/BlockedComment.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/zipdabang/server/domain/recipe/BlockedRecipe.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
import zipdabang.server.domain.recipe.ReportedComment;

public interface ReportedCommentRepository extends JpaRepository<ReportedComment, Long> {
Boolean existsByReportIdAndReportedAndOwner(Report findReport, Comment findComment, Member member);
}
Original file line number Diff line number Diff line change
@@ -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<ReportedRecipe, Long> {
}
4 changes: 2 additions & 2 deletions src/main/java/zipdabang/server/service/RecipeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading

0 comments on commit 754e7bf

Please sign in to comment.