시그니처 캔 리스트
- 총 개수 추가
This commit is contained in:
		| @@ -9,15 +9,25 @@ import org.springframework.data.jpa.repository.JpaRepository | ||||
| interface AdminAdminSignatureCanRepository : JpaRepository<SignatureCan, Long>, AdminSignatureCanQueryRepository | ||||
|  | ||||
| interface AdminSignatureCanQueryRepository { | ||||
|     fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListResponse> | ||||
|     fun getSignatureCanListTotalCount(): Int | ||||
|  | ||||
|     fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListItem> | ||||
| } | ||||
|  | ||||
| class AdminSignatureCanQueryRepositoryImpl( | ||||
|     private val queryFactory: JPAQueryFactory | ||||
| ) : AdminSignatureCanQueryRepository { | ||||
|     override fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListResponse> { | ||||
|     override fun getSignatureCanListTotalCount(): Int { | ||||
|         return queryFactory.select(signatureCan.id) | ||||
|             .from(signatureCan) | ||||
|             .where(signatureCan.isActive.isTrue) | ||||
|             .fetch() | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     override fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListItem> { | ||||
|         return queryFactory.select( | ||||
|             QGetSignatureCanListResponse( | ||||
|             QGetSignatureCanListItem( | ||||
|                 signatureCan.id, | ||||
|                 signatureCan.can, | ||||
|                 signatureCan.image.prepend("/").prepend(imageHost), | ||||
|   | ||||
| @@ -25,12 +25,15 @@ class AdminSignatureCanService( | ||||
|     @Value("\${cloud.aws.cloud-front.host}") | ||||
|     private val imageHost: String | ||||
| ) { | ||||
|     fun getSignatureCanList(pageable: Pageable): List<GetSignatureCanListResponse> { | ||||
|         return repository.getSignatureCanList( | ||||
|     fun getSignatureCanList(pageable: Pageable): GetSignatureCanListResponse { | ||||
|         val totalCount = repository.getSignatureCanListTotalCount() | ||||
|         val items = repository.getSignatureCanList( | ||||
|             imageHost = imageHost, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|         ) | ||||
|  | ||||
|         return GetSignatureCanListResponse(totalCount, items) | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|   | ||||
| @@ -2,7 +2,12 @@ package kr.co.vividnext.sodalive.admin.live.signature | ||||
|  | ||||
| import com.querydsl.core.annotations.QueryProjection | ||||
|  | ||||
| data class GetSignatureCanListResponse @QueryProjection constructor( | ||||
| data class GetSignatureCanListResponse( | ||||
|     val totalCount: Int, | ||||
|     val items: List<GetSignatureCanListItem> | ||||
| ) | ||||
|  | ||||
| data class GetSignatureCanListItem @QueryProjection constructor( | ||||
|     val id: Long, | ||||
|     val can: Int, | ||||
|     val image: String, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user