diff --git a/build.gradle.kts b/build.gradle.kts index 1fc8a49..f396e33 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { kotlin("jvm") version "1.6.21" kotlin("plugin.spring") version "1.6.21" kotlin("plugin.jpa") version "1.6.21" + kotlin("kapt") version "1.7.10" //Querydsl } group = "com.boribori" @@ -26,6 +27,9 @@ allOpen { annotation("javax.persistence.MappedSuperclass") annotation("javax.persistence.Embeddable") } +sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { + kotlin.srcDir("$buildDir/generated/source/kapt/main") +} dependencies { implementation("org.springframework.boot:spring-boot-starter-data-jpa") @@ -46,6 +50,10 @@ dependencies { implementation("io.jsonwebtoken:jjwt-api:0.11.2") runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2") runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2") + val querydslVersion = "5.0.0" //querydsl + implementation("com.querydsl:querydsl-jpa:$querydslVersion") + kapt("com.querydsl:querydsl-apt:$querydslVersion:jpa") + } tasks.withType { @@ -58,3 +66,4 @@ tasks.withType { tasks.withType { useJUnitPlatform() } + diff --git a/src/main/kotlin/com/boribori/boardserver/comment/CommentController.kt b/src/main/kotlin/com/boribori/boardserver/comment/CommentController.kt index 30ea489..a262bd7 100644 --- a/src/main/kotlin/com/boribori/boardserver/comment/CommentController.kt +++ b/src/main/kotlin/com/boribori/boardserver/comment/CommentController.kt @@ -2,6 +2,7 @@ package com.boribori.boardserver.comment import com.boribori.boardserver.auth.dto.AuthUser import com.boribori.boardserver.comment.dto.RequestOfCreateComment +import com.boribori.boardserver.comment.dto.RequestOfGetComment import com.boribori.boardserver.comment.dto.ResponseOfCreateComment import com.boribori.boardserver.common.Response import org.springframework.http.HttpStatus @@ -10,6 +11,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController @@ -17,9 +19,9 @@ class CommentController ( private val commentService: CommentService ){ - @GetMapping("/api/sample") - fun getComment(boardId : String, @AuthenticationPrincipal authUser: AuthUser): String{ - return authUser.id + "---" + boardId + @GetMapping("/api/board/{boardId}/comment") + fun getComment(boardId : String, @RequestParam requestOfGetComment: RequestOfGetComment): String{ + TODO() } @PostMapping("/api/board/{boardId}/comment") diff --git a/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepository.kt b/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepository.kt new file mode 100644 index 0000000..2ca919a --- /dev/null +++ b/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepository.kt @@ -0,0 +1,4 @@ +package com.boribori.boardserver.comment + +interface CommentCustomRepository { +} \ No newline at end of file diff --git a/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepositoryImpl.kt b/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepositoryImpl.kt new file mode 100644 index 0000000..0e240a1 --- /dev/null +++ b/src/main/kotlin/com/boribori/boardserver/comment/CommentCustomRepositoryImpl.kt @@ -0,0 +1,9 @@ +package com.boribori.boardserver.comment + +import com.querydsl.jpa.impl.JPAQueryFactory + +class CommentCustomRepositoryImpl( + private val query: JPAQueryFactory +) : CommentCustomRepository { + +} \ No newline at end of file diff --git a/src/main/kotlin/com/boribori/boardserver/comment/CommentRepository.kt b/src/main/kotlin/com/boribori/boardserver/comment/CommentRepository.kt index ca5365a..f50d888 100644 --- a/src/main/kotlin/com/boribori/boardserver/comment/CommentRepository.kt +++ b/src/main/kotlin/com/boribori/boardserver/comment/CommentRepository.kt @@ -2,5 +2,5 @@ package com.boribori.boardserver.comment import org.springframework.data.jpa.repository.JpaRepository -interface CommentRepository : JpaRepository{ +interface CommentRepository : JpaRepository, CommentCustomRepository{ } \ No newline at end of file diff --git a/src/main/kotlin/com/boribori/boardserver/comment/CommentService.kt b/src/main/kotlin/com/boribori/boardserver/comment/CommentService.kt index 1d9dcd6..7c1a2f5 100644 --- a/src/main/kotlin/com/boribori/boardserver/comment/CommentService.kt +++ b/src/main/kotlin/com/boribori/boardserver/comment/CommentService.kt @@ -3,6 +3,7 @@ package com.boribori.boardserver.comment import com.boribori.boardserver.auth.dto.AuthUser import com.boribori.boardserver.board.BoardService import com.boribori.boardserver.comment.dto.RequestOfCreateComment +import com.boribori.boardserver.comment.dto.RequestOfGetComment import org.springframework.stereotype.Service @Service @@ -24,4 +25,8 @@ class CommentService ( ); return commentRepository.save(comment); } + + fun getComment(boardId: String, requestOfGetComment: RequestOfGetComment){ + + } } \ No newline at end of file diff --git a/src/main/kotlin/com/boribori/boardserver/comment/dto/RequestOfGetComment.kt b/src/main/kotlin/com/boribori/boardserver/comment/dto/RequestOfGetComment.kt new file mode 100644 index 0000000..31a2f3b --- /dev/null +++ b/src/main/kotlin/com/boribori/boardserver/comment/dto/RequestOfGetComment.kt @@ -0,0 +1,9 @@ +package com.boribori.boardserver.comment.dto + +data class RequestOfGetComment( + val order : String? = null, + val pageNum : Int? = null, + val size : Int? = 5, + val offset : Int? = null +) { +} \ No newline at end of file diff --git a/src/main/kotlin/com/boribori/boardserver/config/QuerydslConfig.kt b/src/main/kotlin/com/boribori/boardserver/config/QuerydslConfig.kt new file mode 100644 index 0000000..b7378aa --- /dev/null +++ b/src/main/kotlin/com/boribori/boardserver/config/QuerydslConfig.kt @@ -0,0 +1,15 @@ +package com.boribori.boardserver.config + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import javax.persistence.EntityManager +import javax.persistence.PersistenceContext +import com.querydsl.jpa.impl.JPAQueryFactory + +@Configuration +class QuerydslConfig( + @PersistenceContext val em: EntityManager +) { + @Bean + fun jpaQueryFactory() = JPAQueryFactory(em) +} \ No newline at end of file