-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#161 hotfix: 잘못된 jpa 쿼리 -> queryDSL로 변경
- Loading branch information
1 parent
32918fd
commit a71803c
Showing
4 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.psr.psr.order.repository | ||
|
||
import com.psr.psr.order.entity.Order | ||
import com.psr.psr.order.entity.OrderStatus | ||
|
||
interface OrderCustom { | ||
fun find2MonthAgoOrders(orderStatus: OrderStatus): List<Order> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/psr/psr/order/repository/OrderRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.psr.psr.order.repository | ||
|
||
import com.psr.psr.global.Constant.UserStatus.UserStatus.ACTIVE_STATUS | ||
import com.psr.psr.order.entity.Order | ||
import com.psr.psr.order.entity.OrderStatus | ||
import com.psr.psr.order.entity.QOrder.order | ||
import com.querydsl.core.types.dsl.Expressions | ||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import org.springframework.stereotype.Component | ||
|
||
import java.time.LocalDate | ||
|
||
@Component | ||
class OrderRepositoryImpl( | ||
private val queryFactory: JPAQueryFactory | ||
): OrderCustom { | ||
override fun find2MonthAgoOrders(orderStatus: OrderStatus): List<Order> { | ||
val dateTemplate = Expressions.dateTemplate(LocalDate::class.java, "date({0})", order.createdAt) | ||
val date = LocalDate.now().minusMonths(2) | ||
return queryFactory | ||
.selectFrom(order) | ||
.where(dateTemplate.eq(date) | ||
.and(order.orderStatus.eq(orderStatus)) | ||
.and(order.status.eq(ACTIVE_STATUS))) | ||
.fetch() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters