크리에이터, 콘텐츠, 시리즈 검색
This commit is contained in:
149
src/main/kotlin/kr/co/vividnext/sodalive/search/SearchService.kt
Normal file
149
src/main/kotlin/kr/co/vividnext/sodalive/search/SearchService.kt
Normal file
@@ -0,0 +1,149 @@
|
||||
package kr.co.vividnext.sodalive.search
|
||||
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class SearchService(private val repository: SearchRepository) {
|
||||
fun searchUnified(
|
||||
keyword: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member
|
||||
): SearchUnifiedResponse {
|
||||
val isAdult = member.auth != null && isAdultContentVisible
|
||||
|
||||
val creatorList = repository.searchCreatorList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
offset = 0,
|
||||
limit = 3
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.CREATOR
|
||||
it
|
||||
}
|
||||
|
||||
val contentList = repository.searchContentList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = 0,
|
||||
limit = 3
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.CONTENT
|
||||
it
|
||||
}
|
||||
|
||||
val seriesList = repository.searchSeriesList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = 0,
|
||||
limit = 3
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.SERIES
|
||||
it
|
||||
}
|
||||
|
||||
return SearchUnifiedResponse(
|
||||
creatorList = creatorList,
|
||||
contentList = contentList,
|
||||
seriesList = seriesList
|
||||
)
|
||||
}
|
||||
|
||||
fun searchCreatorList(
|
||||
keyword: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): SearchResponse {
|
||||
val totalCount = repository.searchCreatorTotalCount(keyword, memberId = member.id!!)
|
||||
val items = repository.searchCreatorList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.CREATOR
|
||||
it
|
||||
}
|
||||
|
||||
return SearchResponse(totalCount, items)
|
||||
}
|
||||
|
||||
fun searchContentList(
|
||||
keyword: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): SearchResponse {
|
||||
val isAdult = member.auth != null && isAdultContentVisible
|
||||
|
||||
val totalCount = repository.searchContentTotalCount(
|
||||
keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
)
|
||||
|
||||
val items = repository.searchContentList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.CONTENT
|
||||
it
|
||||
}
|
||||
|
||||
return SearchResponse(totalCount, items)
|
||||
}
|
||||
|
||||
fun searchSeriesList(
|
||||
keyword: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): SearchResponse {
|
||||
val isAdult = member.auth != null && isAdultContentVisible
|
||||
|
||||
val totalCount = repository.searchSeriesTotalCount(
|
||||
keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
)
|
||||
|
||||
val items = repository.searchSeriesList(
|
||||
keyword = keyword,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
.map {
|
||||
it.type = SearchResponseType.SERIES
|
||||
it
|
||||
}
|
||||
|
||||
return SearchResponse(totalCount, items)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user