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