유저 행동 데이터, 포인트 추가 #309
|
@ -3,7 +3,12 @@ package kr.co.vividnext.sodalive.admin.point
|
|||
import com.querydsl.core.annotations.QueryProjection
|
||||
import kr.co.vividnext.sodalive.useraction.ActionType
|
||||
|
||||
data class GetPointRewardPolicyResponse @QueryProjection constructor(
|
||||
data class GetPointRewardPolicyListResponse(
|
||||
val totalCount: Int,
|
||||
val items: List<GetPointRewardPolicyListItem>
|
||||
)
|
||||
|
||||
data class GetPointRewardPolicyListItem @QueryProjection constructor(
|
||||
val id: Long,
|
||||
val title: String,
|
||||
val actionType: ActionType,
|
|
@ -12,16 +12,25 @@ import java.time.LocalDateTime
|
|||
interface PointPolicyRepository : JpaRepository<PointRewardPolicy, Long>, PointPolicyQueryRepository
|
||||
|
||||
interface PointPolicyQueryRepository {
|
||||
fun getAll(offset: Long, limit: Long): List<GetPointRewardPolicyResponse>
|
||||
fun getTotalCount(): Int
|
||||
fun getAll(offset: Long, limit: Long): List<GetPointRewardPolicyListItem>
|
||||
}
|
||||
|
||||
class PointPolicyQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : PointPolicyQueryRepository {
|
||||
override fun getAll(offset: Long, limit: Long): List<GetPointRewardPolicyResponse> {
|
||||
override fun getTotalCount(): Int {
|
||||
return queryFactory
|
||||
.select(pointRewardPolicy.id)
|
||||
.from(pointRewardPolicy)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
|
||||
override fun getAll(offset: Long, limit: Long): List<GetPointRewardPolicyListItem> {
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetPointRewardPolicyResponse(
|
||||
QGetPointRewardPolicyListItem(
|
||||
pointRewardPolicy.id,
|
||||
pointRewardPolicy.title,
|
||||
pointRewardPolicy.actionType,
|
||||
|
|
|
@ -9,8 +9,11 @@ import java.time.format.DateTimeFormatter
|
|||
|
||||
@Service
|
||||
class PointPolicyService(private val repository: PointPolicyRepository) {
|
||||
fun getAll(offset: Long, limit: Long): List<GetPointRewardPolicyResponse> {
|
||||
return repository.getAll(offset, limit)
|
||||
fun getAll(offset: Long, limit: Long): GetPointRewardPolicyListResponse {
|
||||
val totalCount = repository.getTotalCount()
|
||||
val items = repository.getAll(offset, limit)
|
||||
|
||||
return GetPointRewardPolicyListResponse(totalCount, items)
|
||||
}
|
||||
|
||||
fun create(request: CreatePointRewardPolicyRequest) {
|
||||
|
|
Loading…
Reference in New Issue