Compare commits
No commits in common. "5aef7dac3336f25e72113ab7a7d3cd7ccb303cb5" and "faf7aa06b63d131dd8a4e8d564d1d8bcd977869e" have entirely different histories.
5aef7dac33
...
faf7aa06b6
|
@ -43,7 +43,7 @@ interface AudioContentQueryRepository {
|
||||||
limit: Long = 10
|
limit: Long = 10
|
||||||
): List<GetAudioContentListItem>
|
): List<GetAudioContentListItem>
|
||||||
|
|
||||||
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false, categoryId: Long = 0): Int
|
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false): Int
|
||||||
fun getCreatorOtherContentList(
|
fun getCreatorOtherContentList(
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
contentId: Long,
|
contentId: Long,
|
||||||
|
@ -194,20 +194,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.where(where)
|
.where(where)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.orderBy(
|
.orderBy(pinContent.isActive.desc(), pinContent.updatedAt.desc(), orderBy, audioContent.id.desc())
|
||||||
pinContent.isActive.desc(),
|
|
||||||
pinContent.updatedAt.desc(),
|
|
||||||
orderBy,
|
|
||||||
audioContent.updatedAt.desc(),
|
|
||||||
audioContent.id.desc()
|
|
||||||
)
|
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findTotalCountByCreatorId(
|
override fun findTotalCountByCreatorId(
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean
|
||||||
categoryId: Long
|
|
||||||
): Int {
|
): Int {
|
||||||
var where = audioContent.member.id.eq(creatorId)
|
var where = audioContent.member.id.eq(creatorId)
|
||||||
.and(
|
.and(
|
||||||
|
@ -219,15 +212,8 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
where = where.and(audioContent.isAdult.isFalse)
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (categoryId > 0) {
|
|
||||||
where = where.and(categoryContent.category.id.eq(categoryId))
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(audioContent.id)
|
.selectFrom(audioContent)
|
||||||
.from(audioContent)
|
|
||||||
.leftJoin(categoryContent)
|
|
||||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(false)))
|
|
||||||
.where(where)
|
.where(where)
|
||||||
.fetch()
|
.fetch()
|
||||||
.size
|
.size
|
||||||
|
|
|
@ -630,8 +630,7 @@ class AudioContentService(
|
||||||
): GetAudioContentListResponse {
|
): GetAudioContentListResponse {
|
||||||
val totalCount = repository.findTotalCountByCreatorId(
|
val totalCount = repository.findTotalCountByCreatorId(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
isAdult = member.auth != null,
|
isAdult = member.auth != null
|
||||||
categoryId = categoryId
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val audioContentList = repository.findByCreatorId(
|
val audioContentList = repository.findByCreatorId(
|
||||||
|
|
|
@ -40,17 +40,6 @@ class CategoryController(private val service: CategoryService) {
|
||||||
ApiResponse.ok(service.modifyCategory(request = request, member = member))
|
ApiResponse.ok(service.modifyCategory(request = request, member = member))
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/orders")
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
fun updateCategoryOrders(
|
|
||||||
@RequestBody request: UpdateCategoryOrdersRequest,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(service.updateCategoryOrders(request = request, member = member))
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
@PreAuthorize("hasRole('CREATOR')")
|
||||||
fun deleteCategory(
|
fun deleteCategory(
|
||||||
|
|
|
@ -39,11 +39,7 @@ class CategoryQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : C
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(QGetCategoryListResponse(category.id, category.title))
|
.select(QGetCategoryListResponse(category.id, category.title))
|
||||||
.from(category)
|
.from(category)
|
||||||
.where(
|
.where(category.member.id.eq(creatorId))
|
||||||
category.member.id.eq(creatorId)
|
|
||||||
.and(category.isActive.isTrue)
|
|
||||||
)
|
|
||||||
.orderBy(category.orders.asc())
|
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,17 +86,6 @@ class CategoryService(
|
||||||
categoryContentRepository.deleteByCategoryId(categoryId = categoryId)
|
categoryContentRepository.deleteByCategoryId(categoryId = categoryId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun updateCategoryOrders(request: UpdateCategoryOrdersRequest, member: Member) {
|
|
||||||
for (index in request.ids.indices) {
|
|
||||||
val category = repository.findByIdAndMemberId(categoryId = request.ids[index], memberId = member.id!!)
|
|
||||||
|
|
||||||
if (category != null) {
|
|
||||||
category.orders = index + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCategoryList(creatorId: Long, memberId: Long): List<GetCategoryListResponse> {
|
fun getCategoryList(creatorId: Long, memberId: Long): List<GetCategoryListResponse> {
|
||||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = creatorId)
|
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = creatorId)
|
||||||
if (isBlocked) throw SodaException("잘못된 접근입니다.")
|
if (isBlocked) throw SodaException("잘못된 접근입니다.")
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.category
|
|
||||||
|
|
||||||
data class UpdateCategoryOrdersRequest(val ids: List<Long>)
|
|
|
@ -1,52 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.creator.admin.content.category
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
|
||||||
import org.springframework.data.domain.Pageable
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
|
||||||
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
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
@RequestMapping("/creator-admin/content-category")
|
|
||||||
class CreatorAdminCategoryController(private val service: CreatorAdminCategoryService) {
|
|
||||||
@GetMapping("/search")
|
|
||||||
fun searchContentNotInCategory(
|
|
||||||
@RequestParam(value = "category_id") categoryId: Long,
|
|
||||||
@RequestParam(value = "search_word") searchWord: String,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(
|
|
||||||
service.searchContentNotInCategory(
|
|
||||||
categoryId = categoryId,
|
|
||||||
searchWord = searchWord,
|
|
||||||
memberId = member.id!!
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
fun getContentInCategory(
|
|
||||||
@RequestParam(value = "category_id") categoryId: Long,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
||||||
pageable: Pageable
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(
|
|
||||||
service.getContentInCategory(
|
|
||||||
categoryId = categoryId,
|
|
||||||
memberId = member.id!!,
|
|
||||||
offset = pageable.offset,
|
|
||||||
limit = pageable.pageSize.toLong()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.creator.admin.content.category
|
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
|
||||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
|
||||||
import kr.co.vividnext.sodalive.content.category.QCategoryContent.categoryContent
|
|
||||||
import org.springframework.stereotype.Repository
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
class CreatorAdminCategoryRepository(private val queryFactory: JPAQueryFactory) {
|
|
||||||
fun searchContentNotInCategory(
|
|
||||||
categoryId: Long,
|
|
||||||
searchWord: String,
|
|
||||||
memberId: Long
|
|
||||||
): List<SearchContentNotInCategoryResponse> {
|
|
||||||
return queryFactory
|
|
||||||
.select(QSearchContentNotInCategoryResponse(audioContent.id, audioContent.title))
|
|
||||||
.from(audioContent)
|
|
||||||
.leftJoin(categoryContent)
|
|
||||||
.on(
|
|
||||||
audioContent.id.eq(categoryContent.content.id)
|
|
||||||
.and(categoryContent.category.id.eq(categoryId))
|
|
||||||
)
|
|
||||||
.where(
|
|
||||||
audioContent.duration.isNotNull
|
|
||||||
.and(audioContent.member.isNotNull)
|
|
||||||
.and(audioContent.member.id.eq(memberId))
|
|
||||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
|
||||||
.and(audioContent.title.contains(searchWord))
|
|
||||||
.and(categoryContent.id.isNull.or(categoryContent.isActive.isFalse))
|
|
||||||
)
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getContentInCategoryTotalCount(categoryId: Long, memberId: Long): Int {
|
|
||||||
return queryFactory
|
|
||||||
.select(audioContent.id)
|
|
||||||
.from(audioContent)
|
|
||||||
.leftJoin(categoryContent)
|
|
||||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue))
|
|
||||||
.where(
|
|
||||||
categoryContent.category.id.eq(categoryId)
|
|
||||||
.and(audioContent.duration.isNotNull)
|
|
||||||
.and(audioContent.member.isNotNull)
|
|
||||||
.and(audioContent.member.id.eq(memberId))
|
|
||||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
|
||||||
)
|
|
||||||
.fetch()
|
|
||||||
.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getContentInCategory(
|
|
||||||
imageHost: String,
|
|
||||||
categoryId: Long,
|
|
||||||
memberId: Long,
|
|
||||||
offset: Long,
|
|
||||||
limit: Long
|
|
||||||
): List<GetContentInCategoryItem> {
|
|
||||||
return queryFactory
|
|
||||||
.select(
|
|
||||||
QGetContentInCategoryItem(
|
|
||||||
audioContent.id,
|
|
||||||
audioContent.title,
|
|
||||||
audioContent.isAdult,
|
|
||||||
audioContent.coverImage.prepend("/").prepend(imageHost)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(audioContent)
|
|
||||||
.leftJoin(categoryContent)
|
|
||||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue))
|
|
||||||
.where(
|
|
||||||
categoryContent.category.id.eq(categoryId)
|
|
||||||
.and(audioContent.duration.isNotNull)
|
|
||||||
.and(audioContent.member.isNotNull)
|
|
||||||
.and(audioContent.member.id.eq(memberId))
|
|
||||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
|
||||||
)
|
|
||||||
.orderBy(categoryContent.updatedAt.desc())
|
|
||||||
.offset(offset)
|
|
||||||
.limit(limit)
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.creator.admin.content.category
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value
|
|
||||||
import org.springframework.stereotype.Service
|
|
||||||
|
|
||||||
@Service
|
|
||||||
class CreatorAdminCategoryService(
|
|
||||||
private val repository: CreatorAdminCategoryRepository,
|
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
|
||||||
private val imageHost: String
|
|
||||||
) {
|
|
||||||
fun searchContentNotInCategory(
|
|
||||||
categoryId: Long,
|
|
||||||
searchWord: String,
|
|
||||||
memberId: Long
|
|
||||||
): List<SearchContentNotInCategoryResponse> {
|
|
||||||
return repository.searchContentNotInCategory(
|
|
||||||
categoryId,
|
|
||||||
searchWord,
|
|
||||||
memberId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getContentInCategory(
|
|
||||||
categoryId: Long,
|
|
||||||
memberId: Long,
|
|
||||||
offset: Long,
|
|
||||||
limit: Long
|
|
||||||
): GetContentInCategoryResponse {
|
|
||||||
val totalCount = repository.getContentInCategoryTotalCount(categoryId, memberId)
|
|
||||||
val items = repository.getContentInCategory(
|
|
||||||
imageHost,
|
|
||||||
categoryId,
|
|
||||||
memberId,
|
|
||||||
offset,
|
|
||||||
limit
|
|
||||||
)
|
|
||||||
|
|
||||||
return GetContentInCategoryResponse(totalCount, items)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.creator.admin.content.category
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class GetContentInCategoryResponse(
|
|
||||||
val totalCount: Int,
|
|
||||||
val items: List<GetContentInCategoryItem>
|
|
||||||
)
|
|
||||||
|
|
||||||
data class GetContentInCategoryItem @QueryProjection constructor(
|
|
||||||
val contentId: Long,
|
|
||||||
val title: String,
|
|
||||||
val isAdult: Boolean,
|
|
||||||
val image: String
|
|
||||||
)
|
|
|
@ -1,8 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.creator.admin.content.category
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class SearchContentNotInCategoryResponse @QueryProjection constructor(
|
|
||||||
val contentId: Long,
|
|
||||||
val title: String
|
|
||||||
)
|
|
Loading…
Reference in New Issue