유저 행동 데이터, 포인트 추가 #309

Merged
klaus merged 25 commits from test into main 2025-04-24 02:44:58 +00:00
3 changed files with 23 additions and 6 deletions
Showing only changes of commit a70b5d89ec - Show all commits

View File

@ -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,

View File

@ -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,

View File

@ -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) {