Skip to content

Commit

Permalink
release v1.1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Nov 24, 2024
2 parents ebe9d70 + 21cfeeb commit 4f5b963
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,27 @@ import org.springframework.data.jpa.repository.support.Querydsl
import java.time.LocalDateTime

fun <T> Querydsl?.execute(query: JPAQuery<T>, pageable: Pageable): Page<T> {
return this.takeUnless { querydsl -> querydsl == null }
?.let { queryDsl ->
queryDsl.applyPagination(pageable, query).run {
PageImpl(this.fetch(), pageable, this.fetchCount())
}
} ?: throw SusuException(ErrorCode.QUERY_DSL_NOT_EXISTS_ERROR)
return this?.let { queryDsl ->
queryDsl.applyPagination(pageable, query).run {
PageImpl(this.fetch(), pageable, this.fetchCount())
}
} ?: throw SusuException(ErrorCode.QUERY_DSL_NOT_EXISTS_ERROR)
}

fun <T> Querydsl?.executeSlice(query: JPAQuery<T>, pageable: Pageable): Slice<T> {
return this.takeUnless { querydsl -> querydsl == null }
?.let { queryDsl ->
queryDsl.applyPagination(pageable, query).run {
this.limit(pageable.pageSize + 1L)
.fetch()
}.run {
var hasNext = false
if (this.size > pageable.pageSize) {
hasNext = true
this.removeAt(pageable.pageSize)
}
SliceImpl(this, pageable, hasNext)
return this?.let { queryDsl ->
queryDsl.applyPagination(pageable, query).run {
this.limit(pageable.pageSize + 1L)
.fetch()
}.run {
var hasNext = false
if (this.size > pageable.pageSize) {
hasNext = true
this.removeAt(pageable.pageSize)
}
} ?: throw SusuException(ErrorCode.QUERY_DSL_NOT_EXISTS_ERROR)
SliceImpl(this, pageable, hasNext)
}
} ?: throw SusuException(ErrorCode.QUERY_DSL_NOT_EXISTS_ERROR)
}

fun StringPath.isEquals(parameter: String?): BooleanExpression? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.oksusu.susu.domain.friend.domain.QFriend
import com.oksusu.susu.domain.friend.domain.QFriendRelationship
import com.oksusu.susu.domain.user.domain.QUser
import com.querydsl.core.types.dsl.CaseBuilder
import com.querydsl.jpa.JPAExpressions
import com.querydsl.jpa.impl.JPAQuery
import jakarta.persistence.EntityManager
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -468,13 +469,22 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E
}

override fun findLatestFriendEnvelopes(friendIds: Set<Long>): List<Envelope> {
/** sub query 질의를 위해, 별칭 지정 */
val qSubEnvelope = QEnvelope("subEnvelope")

/** 전달 기준 점에 대한 정보를 찾기 위한 sub query */
val subQuery = JPAExpressions
.select(qSubEnvelope.handedOverAt.max())
.from(qSubEnvelope)
.where(qSubEnvelope.friendId.eq(qEnvelope.friendId))

return JPAQuery<Envelope>(entityManager)
.select(qEnvelope)
.from(qEnvelope)
.where(qEnvelope.friendId.`in`(friendIds))
.groupBy(qEnvelope.friendId)
.having(qEnvelope.handedOverAt.eq(qEnvelope.handedOverAt.max()))
.fetch()
.where(
qEnvelope.friendId.`in`(friendIds),
qEnvelope.handedOverAt.eq(subQuery)
).fetch()
}

override fun getMaxAmountEnvelopeInfoByUid(uid: Long, type: EnvelopeType): EnvelopeAndFriendModel? {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.1.23
version=1.1.24
kotlin.code.style=official

0 comments on commit 4f5b963

Please sign in to comment.