Skip to content

Commit

Permalink
chore : querydsl 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Cha-Young-Ho committed Nov 6, 2022
1 parent 2610afc commit f7900da
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 4 deletions.
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand All @@ -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<KotlinCompile> {
Expand All @@ -58,3 +66,4 @@ tasks.withType<KotlinCompile> {
tasks.withType<Test> {
useJUnitPlatform()
}

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -10,16 +11,17 @@ 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
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")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.boribori.boardserver.comment

interface CommentCustomRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.boribori.boardserver.comment

import com.querydsl.jpa.impl.JPAQueryFactory

class CommentCustomRepositoryImpl(
private val query: JPAQueryFactory
) : CommentCustomRepository {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.boribori.boardserver.comment

import org.springframework.data.jpa.repository.JpaRepository

interface CommentRepository : JpaRepository<Comment, String>{
interface CommentRepository : JpaRepository<Comment, String>, CommentCustomRepository{
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,4 +25,8 @@ class CommentService (
);
return commentRepository.save(comment);
}

fun getComment(boardId: String, requestOfGetComment: RequestOfGetComment){

}
}
Original file line number Diff line number Diff line change
@@ -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
) {
}
15 changes: 15 additions & 0 deletions src/main/kotlin/com/boribori/boardserver/config/QuerydslConfig.kt
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit f7900da

Please sign in to comment.