Skip to content

Commit

Permalink
Merge pull request #307 from ODOICHON/refactor/query
Browse files Browse the repository at this point in the history
[Refactor/query] ๊ฒŒ์‹œ๊ธ€, ๋นˆ์ง‘, ์‚ฌ์šฉ์ž ํ…Œ์ด๋ธ” ์ธ๋ฑ์Šค ์ถ”๊ฐ€ ( BTREE ๋ฐฉ์‹ ) ๋ฐ ์กฐํšŒ ์ฟผ๋ฆฌ ํŠœ๋‹
  • Loading branch information
dldmsql authored Nov 2, 2023
2 parents 8ad682c + dc41a77 commit cc7b61e
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 36 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/CD-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ jobs:

steps:
#jdk ์„ธํŒ…
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
java-version: 17
distribution: 'zulu'

#gradle ์บ์‹ฑ
- name: Gradle Caching
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ jobs:

steps:
#jdk ์„ธํŒ…
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
java-version: 17
distribution: 'zulu'

#gradle ์บ์‹ฑ
- name: Gradle Caching
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/CI-Sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'temurin' # Alternative distribution options are available
java-version: 17
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ jobs:

steps:
#jdk ์„ธํŒ…
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
java-version: 17
distribution: 'zulu'

#gradle ์บ์‹ฑ
- name: Gradle Caching
Expand Down
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.kapt3.base.Kapt.kapt

plugins {
id("org.springframework.boot") version "2.7.8"
Expand Down Expand Up @@ -30,7 +29,7 @@ sonarqube {

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
Expand Down Expand Up @@ -87,7 +86,7 @@ dependencies {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
jvmTarget = "17"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.example.jhouse_server.domain.comment.dto.CommentResDto
import java.sql.Timestamp
import java.util.*
import javax.validation.constraints.NotNull
import kotlin.streams.toList
/**
* =============================================================================================
* REQUEST DTO
Expand Down Expand Up @@ -84,6 +83,12 @@ fun toListDto(board : Board) : BoardResDto {
fun toDto(board: Board) : BoardResOneDto {
return BoardResOneDto(board.id, board.title, board.boardCode.code, board.user.nickName, Timestamp.valueOf(board.createdAt), board.imageUrls, board.love.size, board.category.name, board.prefixCategory.name, board.comment.size, board.comment.stream().map { com.example.jhouse_server.domain.comment.dto.toDto(it) }.toList())
}

/**
* =============================================================================================
* UTIL FUNCTION
* =============================================================================================
* */
fun sliceContentWithRegex(content : String) : String {
return if (content.length >= 200) {
content.take(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import javax.persistence.*

@Entity
@Table(
name = "board"
name = "board", indexes = [Index(name = "idx__prefixCategory__category", columnList = "category, prefixCategory, useYn")]
)
class Board(
var title: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class BoardRepositoryImpl(
override fun getBoardAll(boardListDto: BoardListDto, pageable: Pageable): Page<BoardResDto> {
val result = jpaQueryFactory
.selectFrom(board)
.join(board.boardCode, boardCode).fetchJoin()
.join(board.user, user).fetchJoin()
.join(board.boardCode, boardCode)
.join(board.user, user)
.leftJoin(board.comment, comment)
.where(
board.useYn.eq(true),
Expand All @@ -114,6 +114,9 @@ class BoardRepositoryImpl(
.fetch()
val countQuery = jpaQueryFactory
.selectFrom(board)
.join(board.boardCode, boardCode)
.join(board.user, user)
.leftJoin(board.comment, comment)
.where(
board.useYn.eq(true),
filterWithPrefixCategory(boardListDto.prefix),
Expand Down Expand Up @@ -190,6 +193,7 @@ class BoardRepositoryImpl(
.fetch()
val countQuery = jpaQueryFactory
.selectFrom(board).distinct()
.join(board.comment, comment)
.where(
board.useYn.eq(true),
comment.user.eq(user)
Expand Down Expand Up @@ -217,6 +221,7 @@ class BoardRepositoryImpl(
.fetch()
val countQuery = jpaQueryFactory
.selectFrom(board).distinct()
.join(board.love, love)
.where(
board.useYn.eq(true),
love.user.eq(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import java.sql.Timestamp
import java.util.*
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import kotlin.streams.toList

/**
* ================================================================================================
Expand Down Expand Up @@ -79,7 +78,7 @@ data class MyHouseResDto(
* ๋นˆ์ง‘ ๋งค๋ฌผ ๊ฒŒ์‹œ๊ธ€ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์‹œ, ์‘๋‹ต DTO
* ================================================================================================
* */
class HouseResDto() {
class HouseResDto() : Serializable {
var houseId: Long = 0 // ๊ฒŒ์‹œ๊ธ€ ์•„์ด๋””
lateinit var rentalType: RentalType // ๋งค๋ฌผ ์œ ํ˜•
lateinit var city: String // ๋งค๋ฌผ ์œ„์น˜
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.example.jhouse_server.domain.house.entity

import com.example.jhouse_server.domain.board.entity.*
import com.example.jhouse_server.domain.board.entity.BoardImageUrlConverter
import com.example.jhouse_server.domain.scrap.entity.Scrap
import com.example.jhouse_server.domain.user.entity.User
import com.example.jhouse_server.global.entity.BaseEntity
import javax.persistence.*

@Table(name = "house",
indexes = [Index(name = "idx__rental_type", columnList = "rentalType, useYn, tmpYn, reported, applied"),
Index(name = "idx__title", columnList = "title, useYn, tmpYn, reported, applied")
])
@Entity
class House(
@Convert(converter = RentalTypeConverter::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class HouseRepositoryImpl(

val countQuery : Long = jpaQueryFactory
.selectFrom(house)
.innerJoin(house.user)
.leftJoin(house.houseTag)
.where(
house.useYn.eq(true), // ์‚ญ์ œ X
searchWithRentalType(houseListDto.rentalType),
Expand Down Expand Up @@ -97,6 +99,7 @@ class HouseRepositoryImpl(

val countQuery : Long = jpaQueryFactory
.selectFrom(house)
.innerJoin(house.user)
.where(
house.useYn.eq(true), // ์‚ญ์ œ X
house.reported.eq(false), // ์‹ ๊ณ  X
Expand All @@ -115,7 +118,7 @@ class HouseRepositoryImpl(
override fun getScrapHouseAll(user: User, filter: String?, pageable: Pageable): Page<House> {
val result = jpaQueryFactory
.selectFrom(house)
.join(house.user, QUser.user).fetchJoin()
.join(house.user, QUser.user)
.join(house.scrap, scrap)
.where(
house.useYn.eq(true), // ์‚ญ์ œ X
Expand All @@ -128,6 +131,8 @@ class HouseRepositoryImpl(
.fetch()
val countQuery = jpaQueryFactory
.selectFrom(house)
.join(house.user, QUser.user)
.join(house.scrap, scrap)
.where(
house.useYn.eq(true), // ์‚ญ์ œ X
house.reported.eq(false), // ์‹ ๊ณ  X
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.example.jhouse_server.domain.user.entity

import com.example.jhouse_server.domain.board.entity.Board
import com.example.jhouse_server.domain.scrap.entity.Scrap
import com.example.jhouse_server.domain.comment.entity.Comment
import com.example.jhouse_server.domain.house.entity.House
import com.example.jhouse_server.domain.notification.entity.Notification
import com.example.jhouse_server.domain.record.entity.Record
import com.example.jhouse_server.domain.record_comment.entity.RecordComment
import com.example.jhouse_server.domain.record_review.entity.RecordReview
import com.example.jhouse_server.domain.record_review_apply.entity.RecordReviewApply
import com.example.jhouse_server.domain.scrap.entity.Scrap
import com.example.jhouse_server.domain.user.WithdrawalUser
import com.example.jhouse_server.domain.user.entity.WithdrawalStatus.*
import com.example.jhouse_server.domain.user.entity.WithdrawalStatus.APPROVE
import com.example.jhouse_server.global.entity.BaseEntity
import org.springframework.util.StringUtils
import javax.persistence.*

@Table(name = "user",
indexes = [Index(name = "idx__email", columnList = "email"),
Index(name = "idx__nick_name", columnList = "nickName")
])
@Entity
@DiscriminatorValue("U")
class User(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UserRepositoryImpl(
val total = jpaQueryFactory
.selectFrom(user)
.where(user.authority.eq(Authority.USER))
.fetch().size.toLong()
.fetch().size.toLong()

return getOrderAgeRateResult(queryResult, total)
}
Expand All @@ -66,7 +66,7 @@ class UserRepositoryImpl(
.selectFrom(userJoinPath)
.join(userJoinPath.user, user)
.where(user.authority.eq(Authority.USER))
.fetch().size.toLong()
.fetch().size.toLong()

return getOrderJoinPathRateResult(queryResult, total)
}
Expand Down

0 comments on commit cc7b61e

Please sign in to comment.