parent
5b3c5731ee
commit
3e25accaa3
|
@ -5,6 +5,7 @@ import org.springframework.data.domain.Pageable
|
|||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
|
@ -12,8 +13,14 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/admin/marketing/statistics")
|
||||
class AdminAdStatisticsController(private val service: AdminAdStatisticsService) {
|
||||
@GetMapping
|
||||
fun getStatistics(pageable: Pageable) = ApiResponse.ok(
|
||||
fun getStatistics(
|
||||
@RequestParam startDateStr: String,
|
||||
@RequestParam endDateStr: String,
|
||||
pageable: Pageable
|
||||
) = ApiResponse.ok(
|
||||
service.getStatistics(
|
||||
startDateStr = startDateStr,
|
||||
endDateStr = endDateStr,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
|
|
|
@ -28,7 +28,12 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) {
|
|||
).toInt()
|
||||
}
|
||||
|
||||
fun getAdStatisticsDataList(offset: Long, limit: Long): List<GetAdminAdStatisticsItem> {
|
||||
fun getAdStatisticsDataList(
|
||||
startDate: LocalDateTime,
|
||||
endDate: LocalDateTime,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetAdminAdStatisticsItem> {
|
||||
val signUpCount = CaseBuilder()
|
||||
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.SIGNUP))
|
||||
.then(1)
|
||||
|
@ -101,6 +106,10 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) {
|
|||
)
|
||||
)
|
||||
.from(adTrackingHistory)
|
||||
.where(
|
||||
adTrackingHistory.id.createdAt.goe(startDate),
|
||||
adTrackingHistory.id.createdAt.loe(endDate)
|
||||
)
|
||||
.groupBy(
|
||||
getFormattedDate(adTrackingHistory.id.createdAt),
|
||||
adTrackingHistory.mediaGroup,
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
package kr.co.vividnext.sodalive.admin.marketing.statistics
|
||||
|
||||
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class AdminAdStatisticsService(
|
||||
private val repository: AdminAdStatisticsRepository
|
||||
) {
|
||||
fun getStatistics(offset: Long, limit: Long): GetAdminAdStatisticsResponse {
|
||||
fun getStatistics(
|
||||
startDateStr: String,
|
||||
endDateStr: String,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): GetAdminAdStatisticsResponse {
|
||||
val startDate = startDateStr.convertLocalDateTime()
|
||||
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
|
||||
|
||||
val totalCount = repository.getAdStatisticsDataTotalCount()
|
||||
val items = repository.getAdStatisticsDataList(offset, limit)
|
||||
val items = repository.getAdStatisticsDataList(startDate, endDate, offset, limit)
|
||||
|
||||
return GetAdminAdStatisticsResponse(
|
||||
totalCount = totalCount,
|
||||
|
|
Loading…
Reference in New Issue