Compare commits
391 Commits
39760e16ff
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 587f3d6b58 | |||
| 76806e2e90 | |||
| 39c51825da | |||
| 9b6167d46d | |||
| 9a58b7b95f | |||
| 26eae4b06e | |||
| 008ee3b4e5 | |||
| 60989391f6 | |||
| 88d90eec2f | |||
| b6eb13df06 | |||
| 3a57ad23bb | |||
| a6b815ad05 | |||
| d89122802a | |||
| 729552335a | |||
| 690432d6ee | |||
| bc358d18de | |||
| 02ae507c87 | |||
| add88aca35 | |||
| 5818abf69d | |||
| b6971f6a8d | |||
| ee403915f0 | |||
| f83dd47c7c | |||
| 146f733f5d | |||
| 806fcfe7db | |||
| 1a660088de | |||
| 04e7c90407 | |||
| f278497526 | |||
| 5196c80ca8 | |||
| 597bd8f8ae | |||
| e4c1cf5a9a | |||
| 9f6bdf6ed8 | |||
| 4f89b0189e | |||
| 27be9a4fc2 | |||
| 9464cc5ed4 | |||
| c9c09c2998 | |||
| 3ea33c4c7b | |||
| 451a1aa4f2 | |||
| 90555fd34f | |||
| 0dc430b098 | |||
| 1f2103c7fa | |||
| 062c17c51e | |||
| de169b79a1 | |||
| aa24de0a5a | |||
| e5937d573a | |||
| 6da86e12bd | |||
| 9049022a74 | |||
| 7b6f3a7a5f | |||
| 53e9678efa | |||
| e4f547fa92 | |||
| b69756ef81 | |||
| 1a3a9149a2 | |||
| ce120a6d5d | |||
| 08b5fd23ab | |||
| eb18e2d009 | |||
| a27852ed44 | |||
| c7925c1706 | |||
| be59bd7e89 | |||
| 51ce143fc2 | |||
| 89eb11f808 | |||
| 30d89987a4 | |||
| 7959d3e5ed | |||
| 1e29573ef7 | |||
| cc2f533dc6 | |||
| 32b0c19f9d | |||
| 9af2d768e8 | |||
| 5677824cde | |||
| e8f1bc09f9 | |||
| d1a936d55b | |||
| dc97eaa835 | |||
| dcbe57806c | |||
| b14438cc15 | |||
| b27d3bd5c6 | |||
| 03ebc9cfe9 | |||
| 24841b9850 | |||
| d35a3d1a8c | |||
| 60c4e0b528 | |||
| 84f33d1bc2 | |||
| c4e1709b99 | |||
| e7a5fd5819 | |||
| 4bde03643c | |||
| 1bc52b56af | |||
| 9c33fd93f7 | |||
| 3c087bc275 | |||
| 8ad13c289e | |||
| 7577f48a09 | |||
| 0251906964 | |||
| 2723a5f134 | |||
| c3c60605fd | |||
| 238f704b22 | |||
| 5639d8ac8e | |||
| 9aac591591 | |||
| ffa8e5aebb | |||
| cbbfe014cc | |||
| 83028f7817 | |||
| 70d1795557 | |||
| 8c6c681424 | |||
| 50bc9f4ff3 | |||
| f00ea03fad | |||
| f22e7b9ad1 | |||
| c7ec95f4bb | |||
| 229e7a8ccc | |||
| 3c616474ff | |||
| 56eb6b3ce3 | |||
| 545836d43c | |||
| 219f83dec0 | |||
| a76a841238 | |||
| c26680de84 | |||
| 8fffad9d3a | |||
| f4f0f203a2 | |||
| b7196f5a0c | |||
| 5d33a18890 | |||
| 96186a1a50 | |||
| bc8bc479d1 | |||
| 47595b1291 | |||
| 01a88964df | |||
| 3a2b77379f | |||
| dc4e5f75cd | |||
| d0178d551c | |||
| 827333108d | |||
| 587b90bd27 | |||
| 4dc20c5e90 | |||
| ac25782f2b | |||
| 20437d56e7 | |||
| f0b412828a | |||
| 367faac5c3 | |||
| 84deaaa970 | |||
| a2b39466c2 | |||
| 03586c4005 | |||
| 6ea69e1510 | |||
| 553c6dc539 | |||
| 6cc22f5b6d | |||
| 9103d67cc1 | |||
| 25083fb0e4 | |||
| d2dc045255 | |||
| b8621dfbb0 | |||
| 93633940dd | |||
| b6f5325351 | |||
| 7c32c08f1f | |||
| 1d268da08d | |||
| 797666ae0d | |||
| dcf470997e | |||
| 0974d1dbf8 | |||
| 12a35db6cd | |||
| 9abbb05ad8 | |||
| 1ecaf69b0b | |||
| e334d1e5d9 | |||
| b735e861d0 | |||
| 4eb433d372 | |||
| 2416ae61f3 | |||
| 01fb336985 | |||
| b6af88a732 | |||
| 58a2a17d6d | |||
| 79f5a0f520 | |||
| 7f6c0f7f04 | |||
| f658df4dca | |||
| 9d43b8e23a | |||
| 4270aef79b | |||
| 1c0dc82d44 | |||
| c1e325aadf | |||
| cec87da69d | |||
| f68f24cb2c | |||
| ed094347fc | |||
| b8afdffbe1 | |||
| f6ba79f31c | |||
| 5f3b1663d2 | |||
| 66e786b4bb | |||
| f671114574 | |||
| ce37060d94 | |||
| 7d19a4d184 | |||
| 22f28a2f8a | |||
| ceef9ca979 | |||
| efe8f4f939 | |||
| ba692a1195 | |||
| d732bad042 | |||
| 4c935c3bee | |||
| c160dd791f | |||
| 23cd1b4601 | |||
| 031fc8ba1b | |||
| c6853289ad | |||
| 2497bb69bc | |||
| a58a67e0a2 | |||
| 4315fe12a5 | |||
| 42f10a8899 | |||
| 1e4b47f989 | |||
| ff255dbfae | |||
| dbe9b72feb | |||
| 95a714b391 | |||
| 28f58c7f56 | |||
| 8bd46d8f21 | |||
| e1bb8e54ed | |||
| 1de705b063 | |||
| f6926ad356 | |||
| 2cdbbb1b37 | |||
| 4dce8c8f03 | |||
| 97a5bace6f | |||
| d4d51ec48f | |||
| fb91398462 | |||
| 105dadd798 | |||
| 2abf2837d3 | |||
| 422aa67af6 | |||
| 7fffab6985 | |||
| 5a4be3d2c1 | |||
| f39a7681db | |||
| c60a7580ba | |||
| 97edb56edc | |||
| 6ebca8d22b | |||
| 95371ad934 | |||
| 2c176825fd | |||
| fae7de48d3 | |||
| b8230646a2 | |||
| 43279541dd | |||
| b4791977c1 | |||
| ef917ecc25 | |||
| a93faad951 | |||
| fd001d24d3 | |||
| 7aa5884797 | |||
| 5b237a1547 | |||
| 2e37990d87 | |||
| dd07d724a8 | |||
| 03ce8618e7 | |||
| db1a7a7fd6 | |||
| 36a82d7f53 | |||
| 3a34401113 | |||
| 9927268330 | |||
| c45c97e29d | |||
| c64a315226 | |||
| a4cafca6ab | |||
| 46284a0660 | |||
| 05df86e15a | |||
| 8b433027e2 | |||
| 5bd4ff7610 | |||
| d693c397ea | |||
| 1d8d1ec9a5 | |||
| 5e491f11ee | |||
| 7cedea06ac | |||
| 2e5f750e50 | |||
| 20289cad10 | |||
| e0d64c31c7 | |||
| 8c1b95dc97 | |||
| fb5641343e | |||
| 87765941eb | |||
| 1809862c16 | |||
| 300f784f7d | |||
| 67a045eae6 | |||
| 2a79903a28 | |||
| d3222ce083 | |||
| 406a421742 | |||
| 10bf728faf | |||
| 607617747c | |||
| f0a69eb1a2 | |||
| 6b307a6e17 | |||
| 08d08a934a | |||
| c500c12668 | |||
| 62060adeba | |||
| b2fc75edb8 | |||
| a999dd2085 | |||
| 49f95ab100 | |||
| 1a84d5b30c | |||
| 3b65050632 | |||
| d0df31674c | |||
| 1fe88402e2 | |||
| 67097696e6 | |||
| 8e7e77067a | |||
| 9899390b61 | |||
| 80c476a908 | |||
| 59da1d6e49 | |||
| 5aef7dac33 | |||
| faf7aa06b6 | |||
| 38ef6e5583 | |||
| c0b15b5d94 | |||
| 2cfc067ea1 | |||
| a91db4f956 | |||
| 8a09780a02 | |||
| 45e8ec6505 | |||
| 4554b85914 | |||
| 8aa79c4a9c | |||
| c8d3210b57 | |||
| 2282a49563 | |||
| b82fdfb2c8 | |||
| 2d17eac199 | |||
| e482bc3aad | |||
| ec022b74d1 | |||
| dc42c09ce3 | |||
| 046a34d2a4 | |||
| 9ff6ec1888 | |||
| d2950106ec | |||
| 962f800d2e | |||
| 962107e507 | |||
| 039bd11963 | |||
| 5c250ea4ae | |||
| e3405bcec6 | |||
| 0fd1c2235f | |||
| b20c29b022 | |||
| 12d5dcd298 | |||
| 2c305dc6c6 | |||
| 62f76f7433 | |||
| 858ce524f9 | |||
| 3795fb4a40 | |||
| 0c01aeec50 | |||
| 892206744d | |||
| 9e2c1474db | |||
| 16328f73d9 | |||
| e0d4f53cf4 | |||
| e09a59c5b4 | |||
| 049e654535 | |||
| c927dc4ecd | |||
| fe4ecd0ad8 | |||
| 78d476fe80 | |||
| a11c8465d5 | |||
| 366304a9b7 | |||
| 4356663688 | |||
| 26b55e6fcf | |||
| 0d743f7204 | |||
| 6cbe113b3e | |||
| 6409b69d6c | |||
| c5164c76fc | |||
| baade8e138 | |||
| b848d6b4e0 | |||
| d8139d2ab0 | |||
| e96d8f7469 | |||
| 2acffd8afc | |||
| 3c8e72073c | |||
| 724d7a9d9b | |||
| 2da3b0db78 | |||
| 685ad7afaf | |||
| 264cf75964 | |||
| c773dbc7b5 | |||
| 37cbc64f52 | |||
| cb1dde17bb | |||
| c29988acf4 | |||
| eadbf56dae | |||
| 4b3b455135 | |||
| e6ac177396 | |||
| 3d0e29003f | |||
| 78b9b00f77 | |||
| 0ee7faa551 | |||
| e5fdced681 | |||
| afb99fef64 | |||
| 7dfaa36024 | |||
| 0496f665aa | |||
| 0d19e1be74 | |||
| 4aff0111aa | |||
| 63b3ba2bb2 | |||
| 7444b41f60 | |||
| 8e90dbc8b6 | |||
| 9f70722521 | |||
| 52fae596fa | |||
| ccb67957bc | |||
| fb82538d0d | |||
| 72ee39612e | |||
| 51fd5408dc | |||
| 3fae40fbef | |||
| 0745890af0 | |||
| 4abe1730a7 | |||
| 626f0e6989 | |||
| 9f42d9d173 | |||
| f90a93c4bc | |||
| 8000ad6c6a | |||
| 1f1f1bea1a | |||
| d95460c7cd | |||
| a3d93d4b08 | |||
| 07a92af982 | |||
| f4618877d4 | |||
| 2b914fd222 | |||
| 109e42a5a3 | |||
| fa515ad39c | |||
| f09673a795 | |||
| f71536c614 | |||
| 7bdddc7ae8 | |||
| aa8926a624 | |||
| be71e59be2 | |||
| 4d7753378f | |||
| 60257c4ef4 | |||
| 1e0b79bf62 | |||
| 6883434d0d | |||
| eda2193e64 | |||
| 99bf829c88 | |||
| 5feafe1b48 | |||
| c9292b7d04 | |||
| ae7e1a91c1 | |||
| 3e1887e0d1 | |||
| 474646db47 | |||
| 56f7b6c449 | |||
| 76b2b5f7e3 | |||
| e918d809eb | |||
| 7af059e543 | |||
| 897726e1ec | |||
| 8b98a2dd07 | |||
| cca75420f0 | |||
| 86c627ed1d | |||
| d55514e3a7 |
@@ -0,0 +1,145 @@
|
|||||||
|
package kr.co.vividnext.sodalive.admin.content.series.banner
|
||||||
|
|
||||||
|
import com.amazonaws.services.s3.model.ObjectMetadata
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.banner.UpdateBannerOrdersRequest
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerListPageResponse
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerRegisterRequest
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerResponse
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerUpdateRequest
|
||||||
|
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||||
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
|
import kr.co.vividnext.sodalive.content.series.main.banner.ContentSeriesBannerService
|
||||||
|
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.data.domain.PageRequest
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart
|
||||||
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
import org.springframework.web.multipart.MultipartFile
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/audio-content/series/banner")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
class AdminContentSeriesBannerController(
|
||||||
|
private val bannerService: ContentSeriesBannerService,
|
||||||
|
private val s3Uploader: S3Uploader,
|
||||||
|
|
||||||
|
@Value("\${cloud.aws.s3.bucket}")
|
||||||
|
private val s3Bucket: String,
|
||||||
|
|
||||||
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
|
private val imageHost: String
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* 활성화된 배너 목록 조회 API
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
fun getBannerList(
|
||||||
|
@RequestParam(defaultValue = "0") page: Int,
|
||||||
|
@RequestParam(defaultValue = "20") size: Int
|
||||||
|
) = run {
|
||||||
|
val pageable = PageRequest.of(page, size)
|
||||||
|
val banners = bannerService.getActiveBanners(pageable)
|
||||||
|
val response = SeriesBannerListPageResponse(
|
||||||
|
totalCount = banners.totalElements,
|
||||||
|
content = banners.content.map { SeriesBannerResponse.from(it, imageHost) }
|
||||||
|
)
|
||||||
|
ApiResponse.ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배너 상세 조회 API
|
||||||
|
*/
|
||||||
|
@GetMapping("/{bannerId}")
|
||||||
|
fun getBannerDetail(@PathVariable bannerId: Long) = run {
|
||||||
|
val banner = bannerService.getBannerById(bannerId)
|
||||||
|
val response = SeriesBannerResponse.from(banner, imageHost)
|
||||||
|
ApiResponse.ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배너 등록 API
|
||||||
|
*/
|
||||||
|
@PostMapping("/register")
|
||||||
|
fun registerBanner(
|
||||||
|
@RequestPart("image") image: MultipartFile,
|
||||||
|
@RequestPart("request") requestString: String
|
||||||
|
) = run {
|
||||||
|
val objectMapper = ObjectMapper()
|
||||||
|
val request = objectMapper.readValue(requestString, SeriesBannerRegisterRequest::class.java)
|
||||||
|
|
||||||
|
val banner = bannerService.registerBanner(seriesId = request.seriesId, imagePath = "")
|
||||||
|
val imagePath = saveImage(banner.id!!, image)
|
||||||
|
val updatedBanner = bannerService.updateBanner(banner.id!!, imagePath)
|
||||||
|
val response = SeriesBannerResponse.from(updatedBanner, imageHost)
|
||||||
|
ApiResponse.ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배너 수정 API
|
||||||
|
*/
|
||||||
|
@PutMapping("/update")
|
||||||
|
fun updateBanner(
|
||||||
|
@RequestPart("image") image: MultipartFile,
|
||||||
|
@RequestPart("request") requestString: String
|
||||||
|
) = run {
|
||||||
|
val objectMapper = ObjectMapper()
|
||||||
|
val request = objectMapper.readValue(requestString, SeriesBannerUpdateRequest::class.java)
|
||||||
|
// 배너 존재 확인
|
||||||
|
bannerService.getBannerById(request.bannerId)
|
||||||
|
val imagePath = saveImage(request.bannerId, image)
|
||||||
|
val updated = bannerService.updateBanner(
|
||||||
|
bannerId = request.bannerId,
|
||||||
|
imagePath = imagePath,
|
||||||
|
seriesId = request.seriesId
|
||||||
|
)
|
||||||
|
val response = SeriesBannerResponse.from(updated, imageHost)
|
||||||
|
ApiResponse.ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배너 삭제 API (소프트 삭제)
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{bannerId}")
|
||||||
|
fun deleteBanner(@PathVariable bannerId: Long) = run {
|
||||||
|
bannerService.deleteBanner(bannerId)
|
||||||
|
ApiResponse.ok("배너가 성공적으로 삭제되었습니다.")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배너 정렬 순서 일괄 변경 API
|
||||||
|
*/
|
||||||
|
@PutMapping("/orders")
|
||||||
|
fun updateBannerOrders(
|
||||||
|
@RequestBody request: UpdateBannerOrdersRequest
|
||||||
|
) = run {
|
||||||
|
bannerService.updateBannerOrders(request.ids)
|
||||||
|
ApiResponse.ok(null, "배너 정렬 순서가 성공적으로 변경되었습니다.")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveImage(bannerId: Long, image: MultipartFile): String {
|
||||||
|
try {
|
||||||
|
val metadata = ObjectMetadata()
|
||||||
|
metadata.contentLength = image.size
|
||||||
|
val fileName = generateFileName("series-banner")
|
||||||
|
return s3Uploader.upload(
|
||||||
|
inputStream = image.inputStream,
|
||||||
|
bucket = s3Bucket,
|
||||||
|
filePath = "series_banner/$bannerId/$fileName",
|
||||||
|
metadata = metadata
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package kr.co.vividnext.sodalive.admin.content.series.banner.dto
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
import kr.co.vividnext.sodalive.content.series.main.banner.SeriesBanner
|
||||||
|
|
||||||
|
// 시리즈 배너 등록 요청 DTO
|
||||||
|
data class SeriesBannerRegisterRequest(
|
||||||
|
@JsonProperty("seriesId") val seriesId: Long
|
||||||
|
)
|
||||||
|
|
||||||
|
// 시리즈 배너 수정 요청 DTO
|
||||||
|
data class SeriesBannerUpdateRequest(
|
||||||
|
@JsonProperty("bannerId") val bannerId: Long,
|
||||||
|
@JsonProperty("seriesId") val seriesId: Long? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
// 시리즈 배너 응답 DTO
|
||||||
|
data class SeriesBannerResponse(
|
||||||
|
val id: Long,
|
||||||
|
val imagePath: String,
|
||||||
|
val seriesId: Long,
|
||||||
|
val seriesTitle: String
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun from(banner: SeriesBanner, imageHost: String): SeriesBannerResponse {
|
||||||
|
return SeriesBannerResponse(
|
||||||
|
id = banner.id!!,
|
||||||
|
imagePath = "$imageHost/${banner.imagePath}",
|
||||||
|
seriesId = banner.series.id!!,
|
||||||
|
seriesTitle = banner.series.title
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 시리즈 배너 목록 페이지 응답 DTO
|
||||||
|
data class SeriesBannerListPageResponse(
|
||||||
|
val totalCount: Long,
|
||||||
|
val content: List<SeriesBannerResponse>
|
||||||
|
)
|
||||||
@@ -51,7 +51,7 @@ class HomeService(
|
|||||||
private val imageHost: String
|
private val imageHost: String
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val RECOMMEND_TARGET_SIZE = 20
|
private const val RECOMMEND_TARGET_SIZE = 30
|
||||||
private const val RECOMMEND_MAX_ATTEMPTS = 3
|
private const val RECOMMEND_MAX_ATTEMPTS = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,8 @@ class HomeService(
|
|||||||
|
|
||||||
val originalAudioDramaList = seriesService.getOriginalAudioDramaList(
|
val originalAudioDramaList = seriesService.getOriginalAudioDramaList(
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
contentType = contentType
|
contentType = contentType,
|
||||||
|
orderByRandom = true
|
||||||
)
|
)
|
||||||
|
|
||||||
val auditionList = auditionService.getInProgressAuditionList(isAdult = isAdult)
|
val auditionList = auditionService.getInProgressAuditionList(isAdult = isAdult)
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ class ChatCharacterController(
|
|||||||
).content
|
).content
|
||||||
|
|
||||||
// 추천 캐릭터 조회
|
// 추천 캐릭터 조회
|
||||||
// 최근 대화한 캐릭터를 제외한 랜덤 20개 조회
|
// 최근 대화한 캐릭터를 제외한 랜덤 30개 조회
|
||||||
// Controller에서는 호출만
|
// Controller에서는 호출만
|
||||||
// 세부로직은 추후에 변경될 수 있으므로 Service에 별도로 생성
|
// 세부로직은 추후에 변경될 수 있으므로 Service에 별도로 생성
|
||||||
val excludeIds = recentCharacters.map { it.characterId }
|
val excludeIds = recentCharacters.map { it.characterId }
|
||||||
val recommendCharacters = service.getRecommendCharacters(excludeIds, 20)
|
val recommendCharacters = service.getRecommendCharacters(excludeIds, 30)
|
||||||
|
|
||||||
// 큐레이션 섹션 (활성화된 큐레이션 + 캐릭터)
|
// 큐레이션 섹션 (활성화된 큐레이션 + 캐릭터)
|
||||||
val curationSections = curationQueryService.getActiveCurationsWithCharacters()
|
val curationSections = curationQueryService.getActiveCurationsWithCharacters()
|
||||||
@@ -92,7 +92,8 @@ class ChatCharacterController(
|
|||||||
characterId = it.id!!,
|
characterId = it.id!!,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
description = it.description,
|
description = it.description,
|
||||||
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
|
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}",
|
||||||
|
new = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ data class Character(
|
|||||||
@JsonProperty("characterId") val characterId: Long,
|
@JsonProperty("characterId") val characterId: Long,
|
||||||
@JsonProperty("name") val name: String,
|
@JsonProperty("name") val name: String,
|
||||||
@JsonProperty("description") val description: String,
|
@JsonProperty("description") val description: String,
|
||||||
@JsonProperty("imageUrl") val imageUrl: String
|
@JsonProperty("imageUrl") val imageUrl: String,
|
||||||
|
@JsonProperty("isNew") val new: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class RecentCharacter(
|
data class RecentCharacter(
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import org.springframework.data.domain.Page
|
|||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.data.jpa.repository.Query
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
import org.springframework.data.repository.query.Param
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface CharacterImageRepository : JpaRepository<CharacterImage, Long>, CharacterImageQueryRepository {
|
interface CharacterImageRepository : JpaRepository<CharacterImage, Long>, CharacterImageQueryRepository {
|
||||||
@@ -26,6 +28,21 @@ interface CharacterImageRepository : JpaRepository<CharacterImage, Long>, Charac
|
|||||||
"WHERE ci.chatCharacter.id = :characterId AND ci.isActive = true"
|
"WHERE ci.chatCharacter.id = :characterId AND ci.isActive = true"
|
||||||
)
|
)
|
||||||
fun findMaxSortOrderByCharacterId(characterId: Long): Int
|
fun findMaxSortOrderByCharacterId(characterId: Long): Int
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
select distinct c.id
|
||||||
|
from CharacterImage ci
|
||||||
|
join ci.chatCharacter c
|
||||||
|
where ci.isActive = true
|
||||||
|
and ci.createdAt >= :since
|
||||||
|
and c.id in :characterIds
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
fun findCharacterIdsWithRecentImages(
|
||||||
|
@Param("characterIds") characterIds: List<Long>,
|
||||||
|
@Param("since") since: LocalDateTime
|
||||||
|
): List<Long>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CharacterImageQueryRepository {
|
interface CharacterImageQueryRepository {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.chat.character.ChatCharacterTag
|
|||||||
import kr.co.vividnext.sodalive.chat.character.ChatCharacterValue
|
import kr.co.vividnext.sodalive.chat.character.ChatCharacterValue
|
||||||
import kr.co.vividnext.sodalive.chat.character.dto.Character
|
import kr.co.vividnext.sodalive.chat.character.dto.Character
|
||||||
import kr.co.vividnext.sodalive.chat.character.dto.RecentCharactersResponse
|
import kr.co.vividnext.sodalive.chat.character.dto.RecentCharactersResponse
|
||||||
|
import kr.co.vividnext.sodalive.chat.character.image.CharacterImageRepository
|
||||||
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterGoalRepository
|
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterGoalRepository
|
||||||
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterHobbyRepository
|
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterHobbyRepository
|
||||||
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterRepository
|
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterRepository
|
||||||
@@ -34,6 +35,7 @@ class ChatCharacterService(
|
|||||||
private val hobbyRepository: ChatCharacterHobbyRepository,
|
private val hobbyRepository: ChatCharacterHobbyRepository,
|
||||||
private val goalRepository: ChatCharacterGoalRepository,
|
private val goalRepository: ChatCharacterGoalRepository,
|
||||||
private val popularCharacterQuery: PopularCharacterQuery,
|
private val popularCharacterQuery: PopularCharacterQuery,
|
||||||
|
private val imageRepository: CharacterImageRepository,
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val imageHost: String
|
private val imageHost: String
|
||||||
@@ -46,12 +48,25 @@ class ChatCharacterService(
|
|||||||
} else {
|
} else {
|
||||||
chatCharacterRepository.findRandomActive(PageRequest.of(0, safeLimit))
|
chatCharacterRepository.findRandomActive(PageRequest.of(0, safeLimit))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val recentSet = if (chars.isNotEmpty()) {
|
||||||
|
imageRepository
|
||||||
|
.findCharacterIdsWithRecentImages(
|
||||||
|
chars.map { it.id!! },
|
||||||
|
LocalDateTime.now().minusDays(3)
|
||||||
|
)
|
||||||
|
.toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
return chars.map {
|
return chars.map {
|
||||||
Character(
|
Character(
|
||||||
characterId = it.id!!,
|
characterId = it.id!!,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
description = it.description,
|
description = it.description,
|
||||||
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
|
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}",
|
||||||
|
new = recentSet.contains(it.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,12 +84,25 @@ class ChatCharacterService(
|
|||||||
val window = RankingWindowCalculator.now("popular-character")
|
val window = RankingWindowCalculator.now("popular-character")
|
||||||
val topIds = popularCharacterQuery.findPopularCharacterIds(window.windowStart, window.nextBoundary, limit)
|
val topIds = popularCharacterQuery.findPopularCharacterIds(window.windowStart, window.nextBoundary, limit)
|
||||||
val list = loadCharactersInOrder(topIds)
|
val list = loadCharactersInOrder(topIds)
|
||||||
|
|
||||||
|
val recentSet = if (list.isNotEmpty()) {
|
||||||
|
imageRepository
|
||||||
|
.findCharacterIdsWithRecentImages(
|
||||||
|
list.map { it.id!! },
|
||||||
|
LocalDateTime.now().minusDays(3)
|
||||||
|
)
|
||||||
|
.toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
return list.map {
|
return list.map {
|
||||||
Character(
|
Character(
|
||||||
characterId = it.id!!,
|
characterId = it.id!!,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
description = it.description,
|
description = it.description,
|
||||||
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
|
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}",
|
||||||
|
new = recentSet.contains(it.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,15 +137,28 @@ class ChatCharacterService(
|
|||||||
content = emptyList()
|
content = emptyList()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val fallback = chatCharacterRepository.findByIsActiveTrue(
|
val chars = chatCharacterRepository.findByIsActiveTrue(
|
||||||
PageRequest.of(0, 20, Sort.by("createdAt").descending())
|
PageRequest.of(0, 20, Sort.by("createdAt").descending())
|
||||||
)
|
).content
|
||||||
val content = fallback.content.map {
|
|
||||||
|
val recentSet = if (chars.isNotEmpty()) {
|
||||||
|
imageRepository
|
||||||
|
.findCharacterIdsWithRecentImages(
|
||||||
|
chars.map { it.id!! },
|
||||||
|
LocalDateTime.now().minusDays(3)
|
||||||
|
)
|
||||||
|
.toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
|
val content = chars.map {
|
||||||
Character(
|
Character(
|
||||||
characterId = it.id!!,
|
characterId = it.id!!,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
description = it.description,
|
description = it.description,
|
||||||
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
|
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}",
|
||||||
|
new = recentSet.contains(it.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return RecentCharactersResponse(
|
return RecentCharactersResponse(
|
||||||
@@ -126,16 +167,29 @@ class ChatCharacterService(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val pageResult = chatCharacterRepository.findRecentSince(
|
val chars = chatCharacterRepository.findRecentSince(
|
||||||
since,
|
since,
|
||||||
PageRequest.of(safePage, safeSize)
|
PageRequest.of(safePage, safeSize)
|
||||||
)
|
).content
|
||||||
val content = pageResult.content.map {
|
|
||||||
|
val recentSet = if (chars.isNotEmpty()) {
|
||||||
|
imageRepository
|
||||||
|
.findCharacterIdsWithRecentImages(
|
||||||
|
chars.map { it.id!! },
|
||||||
|
LocalDateTime.now().minusDays(3)
|
||||||
|
)
|
||||||
|
.toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
|
val content = chars.map {
|
||||||
Character(
|
Character(
|
||||||
characterId = it.id!!,
|
characterId = it.id!!,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
description = it.description,
|
description = it.description,
|
||||||
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
|
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}",
|
||||||
|
new = recentSet.contains(it.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package kr.co.vividnext.sodalive.chat.original.controller
|
package kr.co.vividnext.sodalive.chat.original.controller
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.chat.character.ChatCharacter
|
||||||
import kr.co.vividnext.sodalive.chat.character.dto.Character
|
import kr.co.vividnext.sodalive.chat.character.dto.Character
|
||||||
|
import kr.co.vividnext.sodalive.chat.character.image.CharacterImageRepository
|
||||||
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkDetailResponse
|
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkDetailResponse
|
||||||
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkListItemResponse
|
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkListItemResponse
|
||||||
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkListResponse
|
import kr.co.vividnext.sodalive.chat.original.dto.OriginalWorkListResponse
|
||||||
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.PathVariable
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
import org.springframework.web.bind.annotation.RequestParam
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 앱용 원작(오리지널 작품) 공개 API
|
* 앱용 원작(오리지널 작품) 공개 API
|
||||||
@@ -25,6 +28,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RequestMapping("/api/chat/original")
|
@RequestMapping("/api/chat/original")
|
||||||
class OriginalWorkController(
|
class OriginalWorkController(
|
||||||
private val queryService: OriginalWorkQueryService,
|
private val queryService: OriginalWorkQueryService,
|
||||||
|
private val characterImageRepository: CharacterImageRepository,
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val imageHost: String
|
private val imageHost: String
|
||||||
) {
|
) {
|
||||||
@@ -65,17 +70,34 @@ class OriginalWorkController(
|
|||||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||||
|
|
||||||
val ow = queryService.getOriginalWork(id)
|
val ow = queryService.getOriginalWork(id)
|
||||||
val pageRes = queryService.getActiveCharactersPage(id, page = 0, size = 20)
|
val chars = queryService.getActiveCharactersPage(id, page = 0, size = 20).content
|
||||||
val characters = pageRes.content.map {
|
|
||||||
val path = it.imagePath ?: "profile/default-profile.png"
|
val recentSet = if (chars.isNotEmpty()) {
|
||||||
Character(
|
characterImageRepository
|
||||||
characterId = it.id!!,
|
.findCharacterIdsWithRecentImages(
|
||||||
name = it.name,
|
chars.map { it.id!! },
|
||||||
description = it.description,
|
LocalDateTime.now().minusDays(3)
|
||||||
imageUrl = "$imageHost/$path"
|
)
|
||||||
)
|
.toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
}
|
}
|
||||||
val response = OriginalWorkDetailResponse.from(ow, imageHost, characters)
|
|
||||||
ApiResponse.ok(response)
|
ApiResponse.ok(
|
||||||
|
OriginalWorkDetailResponse.from(
|
||||||
|
ow,
|
||||||
|
imageHost,
|
||||||
|
chars.map<ChatCharacter, Character> {
|
||||||
|
val path = it.imagePath ?: "profile/default-profile.png"
|
||||||
|
Character(
|
||||||
|
characterId = it.id!!,
|
||||||
|
name = it.name,
|
||||||
|
description = it.description,
|
||||||
|
imageUrl = "$imageHost/$path",
|
||||||
|
new = recentSet.contains(it.id)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class OriginalWorkQueryService(
|
|||||||
val safePage = if (page < 0) 0 else page
|
val safePage = if (page < 0) 0 else page
|
||||||
val safeSize = when {
|
val safeSize = when {
|
||||||
size <= 0 -> 20
|
size <= 0 -> 20
|
||||||
size > 50 -> 50
|
size > 20 -> 20
|
||||||
else -> size
|
else -> size
|
||||||
}
|
}
|
||||||
val pageable = PageRequest.of(safePage, safeSize, Sort.by("createdAt").descending())
|
val pageable = PageRequest.of(safePage, safeSize, Sort.by("createdAt").descending())
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class SecurityConfig(
|
|||||||
.antMatchers("/api/home").permitAll()
|
.antMatchers("/api/home").permitAll()
|
||||||
.antMatchers("/api/home/latest-content").permitAll()
|
.antMatchers("/api/home/latest-content").permitAll()
|
||||||
.antMatchers("/api/home/day-of-week-series").permitAll()
|
.antMatchers("/api/home/day-of-week-series").permitAll()
|
||||||
|
.antMatchers("/api/home/content-ranking").permitAll()
|
||||||
.antMatchers(HttpMethod.GET, "/api/live").permitAll()
|
.antMatchers(HttpMethod.GET, "/api/live").permitAll()
|
||||||
.antMatchers(HttpMethod.GET, "/faq").permitAll()
|
.antMatchers(HttpMethod.GET, "/faq").permitAll()
|
||||||
.antMatchers(HttpMethod.GET, "/faq/category").permitAll()
|
.antMatchers(HttpMethod.GET, "/faq/category").permitAll()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ enum class PurchaseOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum class SortType {
|
enum class SortType {
|
||||||
NEWEST, PRICE_HIGH, PRICE_LOW
|
NEWEST, PRICE_HIGH, PRICE_LOW, POPULARITY
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|||||||
@@ -243,6 +243,8 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||||
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
||||||
|
@RequestParam("sort-type", required = false) sortType: SortType? = SortType.NEWEST,
|
||||||
|
@RequestParam("theme", required = false) theme: String? = null,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
pageable: Pageable
|
pageable: Pageable
|
||||||
) = run {
|
) = run {
|
||||||
@@ -250,10 +252,11 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
|
|
||||||
ApiResponse.ok(
|
ApiResponse.ok(
|
||||||
service.getLatestContentByTheme(
|
service.getLatestContentByTheme(
|
||||||
theme = emptyList(),
|
theme = if (theme == null) listOf() else listOf(theme),
|
||||||
contentType = contentType ?: ContentType.ALL,
|
contentType = contentType ?: ContentType.ALL,
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize.toLong(),
|
limit = pageable.pageSize.toLong(),
|
||||||
|
sortType = sortType ?: SortType.NEWEST,
|
||||||
isFree = isFree ?: false,
|
isFree = isFree ?: false,
|
||||||
isAdult = (isAdultContentVisible ?: true) && member.auth != null,
|
isAdult = (isAdultContentVisible ?: true) && member.auth != null,
|
||||||
isPointAvailableOnly = isPointAvailableOnly ?: false
|
isPointAvailableOnly = isPointAvailableOnly ?: false
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ interface AudioContentQueryRepository {
|
|||||||
): Int
|
): Int
|
||||||
|
|
||||||
fun findByThemeFor2Weeks(
|
fun findByThemeFor2Weeks(
|
||||||
isFree: Boolean = false,
|
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
theme: List<String> = emptyList(),
|
theme: List<String> = emptyList(),
|
||||||
@@ -120,7 +119,6 @@ interface AudioContentQueryRepository {
|
|||||||
): List<GetAudioContentMainItem>
|
): List<GetAudioContentMainItem>
|
||||||
|
|
||||||
fun totalCountNewContentFor2Weeks(
|
fun totalCountNewContentFor2Weeks(
|
||||||
isFree: Boolean = false,
|
|
||||||
theme: List<String> = emptyList(),
|
theme: List<String> = emptyList(),
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
@@ -182,6 +180,7 @@ interface AudioContentQueryRepository {
|
|||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
|
sortType: SortType,
|
||||||
isFree: Boolean,
|
isFree: Boolean,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
orderByRandom: Boolean = false,
|
orderByRandom: Boolean = false,
|
||||||
@@ -243,6 +242,7 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
SortType.NEWEST -> audioContent.releaseDate.desc()
|
SortType.NEWEST -> audioContent.releaseDate.desc()
|
||||||
SortType.PRICE_HIGH -> audioContent.price.desc()
|
SortType.PRICE_HIGH -> audioContent.price.desc()
|
||||||
SortType.PRICE_LOW -> audioContent.price.asc()
|
SortType.PRICE_LOW -> audioContent.price.asc()
|
||||||
|
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||||
}
|
}
|
||||||
|
|
||||||
var where = audioContent.member.id.eq(creatorId)
|
var where = audioContent.member.id.eq(creatorId)
|
||||||
@@ -464,6 +464,12 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
audioContent.releaseDate.asc(),
|
audioContent.releaseDate.asc(),
|
||||||
audioContent.id.asc()
|
audioContent.id.asc()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SortType.POPULARITY -> listOf(
|
||||||
|
audioContent.playCount.desc(),
|
||||||
|
audioContent.releaseDate.asc(),
|
||||||
|
audioContent.id.asc()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
@@ -695,7 +701,6 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun totalCountNewContentFor2Weeks(
|
override fun totalCountNewContentFor2Weeks(
|
||||||
isFree: Boolean,
|
|
||||||
theme: List<String>,
|
theme: List<String>,
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
@@ -732,10 +737,6 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
where = where.and(audioContentTheme.theme.`in`(theme))
|
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFree) {
|
|
||||||
where = where.and(audioContent.price.loe(0))
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(audioContent.id)
|
.select(audioContent.id)
|
||||||
.from(audioContent)
|
.from(audioContent)
|
||||||
@@ -747,7 +748,6 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun findByThemeFor2Weeks(
|
override fun findByThemeFor2Weeks(
|
||||||
isFree: Boolean,
|
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
theme: List<String>,
|
theme: List<String>,
|
||||||
@@ -787,10 +787,6 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
where = where.and(audioContentTheme.theme.`in`(theme))
|
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFree) {
|
|
||||||
where = where.and(audioContent.price.loe(0))
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QGetAudioContentMainItem(
|
QGetAudioContentMainItem(
|
||||||
@@ -1309,6 +1305,7 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
|
sortType: SortType,
|
||||||
isFree: Boolean,
|
isFree: Boolean,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
orderByRandom: Boolean,
|
orderByRandom: Boolean,
|
||||||
@@ -1354,7 +1351,22 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
val orderBy = if (orderByRandom) {
|
val orderBy = if (orderByRandom) {
|
||||||
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
||||||
} else {
|
} else {
|
||||||
audioContent.releaseDate.desc()
|
when (sortType) {
|
||||||
|
SortType.NEWEST -> audioContent.releaseDate.desc()
|
||||||
|
SortType.PRICE_HIGH -> if (isFree) {
|
||||||
|
audioContent.releaseDate.desc()
|
||||||
|
} else {
|
||||||
|
audioContent.price.desc()
|
||||||
|
}
|
||||||
|
|
||||||
|
SortType.PRICE_LOW -> if (isFree) {
|
||||||
|
audioContent.releaseDate.asc()
|
||||||
|
} else {
|
||||||
|
audioContent.price.desc()
|
||||||
|
}
|
||||||
|
|
||||||
|
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
@@ -1441,11 +1453,10 @@ class AudioContentQueryRepositoryImpl(
|
|||||||
isAdult: Boolean
|
isAdult: Boolean
|
||||||
): AudioContent? {
|
): AudioContent? {
|
||||||
var where = audioContent.member.id.eq(creatorId)
|
var where = audioContent.member.id.eq(creatorId)
|
||||||
.and(
|
.and(audioContent.isActive.isTrue)
|
||||||
audioContent.isActive.isTrue
|
.and(audioContent.duration.isNotNull)
|
||||||
.and(audioContent.duration.isNotNull)
|
.and(audioContent.releaseDate.isNotNull)
|
||||||
.or(audioContent.releaseDate.isNotNull.and(audioContent.duration.isNotNull))
|
.and(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||||
)
|
|
||||||
|
|
||||||
if (!isAdult) {
|
if (!isAdult) {
|
||||||
where = where.and(audioContent.isAdult.isFalse)
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
|
|||||||
@@ -988,6 +988,7 @@ class AudioContentService(
|
|||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 20,
|
limit: Long = 20,
|
||||||
|
sortType: SortType = SortType.NEWEST,
|
||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
orderByRandom: Boolean = false,
|
orderByRandom: Boolean = false,
|
||||||
@@ -998,6 +999,7 @@ class AudioContentService(
|
|||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
limit = limit,
|
limit = limit,
|
||||||
|
sortType = sortType,
|
||||||
isFree = isFree,
|
isFree = isFree,
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
orderByRandom = orderByRandom,
|
orderByRandom = orderByRandom,
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ class AudioContentMainController(
|
|||||||
|
|
||||||
@GetMapping("/new/all")
|
@GetMapping("/new/all")
|
||||||
fun getNewContentAllByTheme(
|
fun getNewContentAllByTheme(
|
||||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
|
||||||
@RequestParam("theme") theme: String,
|
@RequestParam("theme") theme: String,
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
@@ -110,7 +109,6 @@ class AudioContentMainController(
|
|||||||
|
|
||||||
ApiResponse.ok(
|
ApiResponse.ok(
|
||||||
service.getNewContentFor2WeeksByTheme(
|
service.getNewContentFor2WeeksByTheme(
|
||||||
isFree = isFree ?: false,
|
|
||||||
theme = theme,
|
theme = theme,
|
||||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
contentType = contentType ?: ContentType.ALL,
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
|||||||
@@ -28,16 +28,6 @@ class AudioContentMainService(
|
|||||||
@Cacheable(cacheNames = ["default"], key = "'themeList:' + ':' + #isAdult")
|
@Cacheable(cacheNames = ["default"], key = "'themeList:' + ':' + #isAdult")
|
||||||
fun getThemeList(isAdult: Boolean, contentType: ContentType): List<String> {
|
fun getThemeList(isAdult: Boolean, contentType: ContentType): List<String> {
|
||||||
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult, contentType = contentType)
|
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult, contentType = contentType)
|
||||||
.filter {
|
|
||||||
it != "모닝콜" &&
|
|
||||||
it != "알람" &&
|
|
||||||
it != "슬립콜" &&
|
|
||||||
it != "다시듣기" &&
|
|
||||||
it != "ASMR" &&
|
|
||||||
it != "릴레이" &&
|
|
||||||
it != "챌린지" &&
|
|
||||||
it != "자기소개"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@@ -64,7 +54,6 @@ class AudioContentMainService(
|
|||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
fun getNewContentFor2WeeksByTheme(
|
fun getNewContentFor2WeeksByTheme(
|
||||||
isFree: Boolean,
|
|
||||||
theme: String,
|
theme: String,
|
||||||
isAdultContentVisible: Boolean,
|
isAdultContentVisible: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
@@ -75,31 +64,19 @@ class AudioContentMainService(
|
|||||||
val themeList = if (theme.isBlank()) {
|
val themeList = if (theme.isBlank()) {
|
||||||
audioContentThemeRepository.getActiveThemeOfContent(
|
audioContentThemeRepository.getActiveThemeOfContent(
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
isFree = isFree,
|
|
||||||
contentType = contentType
|
contentType = contentType
|
||||||
).filter {
|
)
|
||||||
it != "모닝콜" &&
|
|
||||||
it != "알람" &&
|
|
||||||
it != "슬립콜" &&
|
|
||||||
it != "다시듣기" &&
|
|
||||||
it != "ASMR" &&
|
|
||||||
it != "릴레이" &&
|
|
||||||
it != "챌린지" &&
|
|
||||||
it != "자기소개"
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
listOf(theme)
|
listOf(theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalCount = repository.totalCountNewContentFor2Weeks(
|
val totalCount = repository.totalCountNewContentFor2Weeks(
|
||||||
isFree,
|
|
||||||
themeList,
|
themeList,
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
contentType = contentType
|
contentType = contentType
|
||||||
)
|
)
|
||||||
val items = repository.findByThemeFor2Weeks(
|
val items = repository.findByThemeFor2Weeks(
|
||||||
isFree,
|
|
||||||
cloudfrontHost = imageHost,
|
cloudfrontHost = imageHost,
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
theme = themeList,
|
theme = themeList,
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact
|
|||||||
SortType.NEWEST -> audioContent.createdAt.desc()
|
SortType.NEWEST -> audioContent.createdAt.desc()
|
||||||
SortType.PRICE_HIGH -> audioContent.price.desc()
|
SortType.PRICE_HIGH -> audioContent.price.desc()
|
||||||
SortType.PRICE_LOW -> audioContent.price.asc()
|
SortType.PRICE_LOW -> audioContent.price.asc()
|
||||||
|
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||||
}
|
}
|
||||||
|
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
|||||||
fun getSeriesList(
|
fun getSeriesList(
|
||||||
@RequestParam(required = false) creatorId: Long?,
|
@RequestParam(required = false) creatorId: Long?,
|
||||||
@RequestParam(name = "isOriginal", required = false) isOriginal: Boolean? = null,
|
@RequestParam(name = "isOriginal", required = false) isOriginal: Boolean? = null,
|
||||||
|
@RequestParam(name = "isCompleted", required = false) isCompleted: Boolean? = null,
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
@@ -31,6 +32,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
|||||||
service.getSeriesList(
|
service.getSeriesList(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
isOriginal = isOriginal ?: false,
|
isOriginal = isOriginal ?: false,
|
||||||
|
isCompleted = isCompleted ?: false,
|
||||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
contentType = contentType ?: ContentType.ALL,
|
contentType = contentType ?: ContentType.ALL,
|
||||||
member = member,
|
member = member,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
|||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeriesContent.seriesContent
|
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeriesContent.seriesContent
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
||||||
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesState
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.keyword.QSeriesKeyword.seriesKeyword
|
import kr.co.vividnext.sodalive.creator.admin.content.series.keyword.QSeriesKeyword.seriesKeyword
|
||||||
import kr.co.vividnext.sodalive.member.MemberRole
|
import kr.co.vividnext.sodalive.member.MemberRole
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
import kr.co.vividnext.sodalive.member.QMember.member
|
||||||
@@ -23,13 +24,37 @@ import org.springframework.data.jpa.repository.JpaRepository
|
|||||||
interface ContentSeriesRepository : JpaRepository<Series, Long>, ContentSeriesQueryRepository
|
interface ContentSeriesRepository : JpaRepository<Series, Long>, ContentSeriesQueryRepository
|
||||||
|
|
||||||
interface ContentSeriesQueryRepository {
|
interface ContentSeriesQueryRepository {
|
||||||
fun getSeriesTotalCount(creatorId: Long?, isAuth: Boolean, contentType: ContentType, isOriginal: Boolean): Int
|
fun getSeriesTotalCount(
|
||||||
|
creatorId: Long?,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType,
|
||||||
|
isOriginal: Boolean,
|
||||||
|
isCompleted: Boolean
|
||||||
|
): Int
|
||||||
|
|
||||||
fun getSeriesList(
|
fun getSeriesList(
|
||||||
imageHost: String,
|
imageHost: String,
|
||||||
creatorId: Long?,
|
creatorId: Long?,
|
||||||
isAuth: Boolean,
|
isAuth: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
isOriginal: Boolean,
|
isOriginal: Boolean,
|
||||||
|
isCompleted: Boolean,
|
||||||
|
orderByRandom: Boolean,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<Series>
|
||||||
|
|
||||||
|
fun getSeriesByGenreTotalCount(
|
||||||
|
genreId: Long,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType
|
||||||
|
): Int
|
||||||
|
|
||||||
|
fun getSeriesByGenreList(
|
||||||
|
imageHost: String,
|
||||||
|
genreId: Long,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<Series>
|
): List<Series>
|
||||||
@@ -41,6 +66,7 @@ interface ContentSeriesQueryRepository {
|
|||||||
fun getOriginalAudioDramaList(
|
fun getOriginalAudioDramaList(
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
|
orderByRandom: Boolean = false,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 20
|
limit: Long = 20
|
||||||
): List<Series>
|
): List<Series>
|
||||||
@@ -60,7 +86,13 @@ interface ContentSeriesQueryRepository {
|
|||||||
class ContentSeriesQueryRepositoryImpl(
|
class ContentSeriesQueryRepositoryImpl(
|
||||||
private val queryFactory: JPAQueryFactory
|
private val queryFactory: JPAQueryFactory
|
||||||
) : ContentSeriesQueryRepository {
|
) : ContentSeriesQueryRepository {
|
||||||
override fun getSeriesTotalCount(creatorId: Long?, isAuth: Boolean, contentType: ContentType, isOriginal: Boolean): Int {
|
override fun getSeriesTotalCount(
|
||||||
|
creatorId: Long?,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType,
|
||||||
|
isOriginal: Boolean,
|
||||||
|
isCompleted: Boolean
|
||||||
|
): Int {
|
||||||
var where = series.isActive.isTrue
|
var where = series.isActive.isTrue
|
||||||
|
|
||||||
if (creatorId != null) {
|
if (creatorId != null) {
|
||||||
@@ -71,6 +103,10 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
where = where.and(series.isOriginal.isTrue)
|
where = where.and(series.isOriginal.isTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCompleted) {
|
||||||
|
where = where.and(series.state.eq(SeriesState.COMPLETE))
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAuth) {
|
if (!isAuth) {
|
||||||
where = where.and(series.isAdult.isFalse)
|
where = where.and(series.isAdult.isFalse)
|
||||||
} else {
|
} else {
|
||||||
@@ -104,6 +140,8 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
isAuth: Boolean,
|
isAuth: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
isOriginal: Boolean,
|
isOriginal: Boolean,
|
||||||
|
isCompleted: Boolean,
|
||||||
|
orderByRandom: Boolean,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<Series> {
|
): List<Series> {
|
||||||
@@ -116,6 +154,10 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
where = where.and(series.isOriginal.isTrue)
|
where = where.and(series.isOriginal.isTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCompleted) {
|
||||||
|
where = where.and(series.state.eq(SeriesState.COMPLETE))
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAuth) {
|
if (!isAuth) {
|
||||||
where = where.and(series.isAdult.isFalse)
|
where = where.and(series.isAdult.isFalse)
|
||||||
} else {
|
} else {
|
||||||
@@ -134,11 +176,105 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val orderBy = if (orderByRandom) {
|
||||||
|
listOf(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
|
||||||
|
} else if (creatorId != null) {
|
||||||
|
listOf(series.orders.asc(), series.createdAt.asc())
|
||||||
|
} else {
|
||||||
|
listOf(audioContent.releaseDate.max().desc(), series.createdAt.asc())
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.selectFrom(series)
|
.selectFrom(series)
|
||||||
.innerJoin(series.member, member)
|
.innerJoin(series.member, member)
|
||||||
|
.innerJoin(seriesContent).on(series.id.eq(seriesContent.series.id))
|
||||||
|
.innerJoin(seriesContent.content, audioContent)
|
||||||
.where(where)
|
.where(where)
|
||||||
.orderBy(series.orders.asc(), series.createdAt.asc())
|
.groupBy(series.id)
|
||||||
|
.orderBy(*orderBy.toTypedArray())
|
||||||
|
.offset(offset)
|
||||||
|
.limit(limit)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSeriesByGenreTotalCount(
|
||||||
|
genreId: Long,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType
|
||||||
|
): Int {
|
||||||
|
var where = series.isActive.isTrue
|
||||||
|
.and(series.genre.id.eq(genreId))
|
||||||
|
|
||||||
|
if (!isAuth) {
|
||||||
|
where = where.and(series.isAdult.isFalse)
|
||||||
|
} else {
|
||||||
|
if (contentType != ContentType.ALL) {
|
||||||
|
where = where.and(
|
||||||
|
series.member.isNull.or(
|
||||||
|
series.member.auth.gender.eq(
|
||||||
|
if (contentType == ContentType.MALE) {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(series.id)
|
||||||
|
.from(seriesContent)
|
||||||
|
.innerJoin(seriesContent.series, series)
|
||||||
|
.innerJoin(seriesContent.content, audioContent)
|
||||||
|
.innerJoin(series.member, member)
|
||||||
|
.innerJoin(series.genre, seriesGenre)
|
||||||
|
.where(where)
|
||||||
|
.groupBy(series.id)
|
||||||
|
.fetch()
|
||||||
|
.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSeriesByGenreList(
|
||||||
|
imageHost: String,
|
||||||
|
genreId: Long,
|
||||||
|
isAuth: Boolean,
|
||||||
|
contentType: ContentType,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<Series> {
|
||||||
|
var where = series.isActive.isTrue
|
||||||
|
.and(series.genre.id.eq(genreId))
|
||||||
|
|
||||||
|
if (!isAuth) {
|
||||||
|
where = where.and(series.isAdult.isFalse)
|
||||||
|
} else {
|
||||||
|
if (contentType != ContentType.ALL) {
|
||||||
|
where = where.and(
|
||||||
|
series.member.isNull.or(
|
||||||
|
series.member.auth.gender.eq(
|
||||||
|
if (contentType == ContentType.MALE) {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(series)
|
||||||
|
.from(seriesContent)
|
||||||
|
.innerJoin(seriesContent.series, series)
|
||||||
|
.innerJoin(seriesContent.content, audioContent)
|
||||||
|
.innerJoin(series.member, member)
|
||||||
|
.innerJoin(series.genre, seriesGenre)
|
||||||
|
.where(where)
|
||||||
|
.groupBy(series.id)
|
||||||
|
.orderBy(audioContent.releaseDate.max().desc(), series.createdAt.asc())
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.fetch()
|
.fetch()
|
||||||
@@ -231,6 +367,7 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
override fun getOriginalAudioDramaList(
|
override fun getOriginalAudioDramaList(
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
|
orderByRandom: Boolean,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<Series> {
|
): List<Series> {
|
||||||
@@ -259,7 +396,13 @@ class ContentSeriesQueryRepositoryImpl(
|
|||||||
.selectFrom(series)
|
.selectFrom(series)
|
||||||
.innerJoin(series.member, member)
|
.innerJoin(series.member, member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.orderBy(series.id.desc())
|
.orderBy(
|
||||||
|
if (orderByRandom) {
|
||||||
|
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
||||||
|
} else {
|
||||||
|
series.id.desc()
|
||||||
|
}
|
||||||
|
)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ class ContentSeriesService(
|
|||||||
fun getOriginalAudioDramaList(
|
fun getOriginalAudioDramaList(
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
|
orderByRandom: Boolean = false,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 20
|
limit: Long = 20
|
||||||
): List<GetSeriesListResponse.SeriesListItem> {
|
): List<GetSeriesListResponse.SeriesListItem> {
|
||||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, offset, limit)
|
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, orderByRandom, offset, limit)
|
||||||
return seriesToSeriesListItem(originalAudioDramaList, isAdult, contentType)
|
return seriesToSeriesListItem(originalAudioDramaList, isAdult, contentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +52,13 @@ class ContentSeriesService(
|
|||||||
fun getSeriesList(
|
fun getSeriesList(
|
||||||
creatorId: Long?,
|
creatorId: Long?,
|
||||||
isOriginal: Boolean = false,
|
isOriginal: Boolean = false,
|
||||||
|
isCompleted: Boolean = false,
|
||||||
|
orderByRandom: Boolean = false,
|
||||||
isAdultContentVisible: Boolean,
|
isAdultContentVisible: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
member: Member,
|
member: Member,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 10
|
limit: Long = 20
|
||||||
): GetSeriesListResponse {
|
): GetSeriesListResponse {
|
||||||
val isAuth = member.auth != null && isAdultContentVisible
|
val isAuth = member.auth != null && isAdultContentVisible
|
||||||
|
|
||||||
@@ -63,7 +66,8 @@ class ContentSeriesService(
|
|||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
isAuth = isAuth,
|
isAuth = isAuth,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
isOriginal = isOriginal
|
isOriginal = isOriginal,
|
||||||
|
isCompleted = isCompleted
|
||||||
)
|
)
|
||||||
|
|
||||||
val rawItems = repository.getSeriesList(
|
val rawItems = repository.getSeriesList(
|
||||||
@@ -72,6 +76,37 @@ class ContentSeriesService(
|
|||||||
isAuth = isAuth,
|
isAuth = isAuth,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
isOriginal = isOriginal,
|
isOriginal = isOriginal,
|
||||||
|
isCompleted = isCompleted,
|
||||||
|
orderByRandom = orderByRandom,
|
||||||
|
offset = offset,
|
||||||
|
limit = limit
|
||||||
|
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||||
|
|
||||||
|
val items = seriesToSeriesListItem(seriesList = rawItems, isAdult = isAuth, contentType = contentType)
|
||||||
|
return GetSeriesListResponse(totalCount, items)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSeriesListByGenre(
|
||||||
|
genreId: Long,
|
||||||
|
isAdultContentVisible: Boolean,
|
||||||
|
contentType: ContentType,
|
||||||
|
member: Member,
|
||||||
|
offset: Long = 0,
|
||||||
|
limit: Long = 20
|
||||||
|
): GetSeriesListResponse {
|
||||||
|
val isAuth = member.auth != null && isAdultContentVisible
|
||||||
|
|
||||||
|
val totalCount = repository.getSeriesByGenreTotalCount(
|
||||||
|
genreId = genreId,
|
||||||
|
isAuth = isAuth,
|
||||||
|
contentType = contentType
|
||||||
|
)
|
||||||
|
|
||||||
|
val rawItems = repository.getSeriesByGenreList(
|
||||||
|
imageHost = coverImageHost,
|
||||||
|
genreId = genreId,
|
||||||
|
isAuth = isAuth,
|
||||||
|
contentType = contentType,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
limit = limit
|
limit = limit
|
||||||
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||||
@@ -205,7 +240,7 @@ class ContentSeriesService(
|
|||||||
val seriesList = repository.getRecommendSeriesList(
|
val seriesList = repository.getRecommendSeriesList(
|
||||||
isAuth = isAuth,
|
isAuth = isAuth,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
limit = 10
|
limit = 20
|
||||||
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||||
|
|
||||||
return seriesToSeriesListItem(seriesList = seriesList, isAdult = isAuth, contentType = contentType)
|
return seriesToSeriesListItem(seriesList = seriesList, isAdult = isAuth, contentType = contentType)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package kr.co.vividnext.sodalive.content.series.main
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerResponse
|
||||||
|
import kr.co.vividnext.sodalive.content.series.GetSeriesListResponse
|
||||||
|
|
||||||
|
data class SeriesHomeResponse(
|
||||||
|
val banners: List<SeriesBannerResponse>,
|
||||||
|
val completedSeriesList: List<GetSeriesListResponse.SeriesListItem>,
|
||||||
|
val recommendSeriesList: List<GetSeriesListResponse.SeriesListItem>
|
||||||
|
)
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package kr.co.vividnext.sodalive.content.series.main
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.banner.dto.SeriesBannerResponse
|
||||||
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
|
import kr.co.vividnext.sodalive.content.ContentType
|
||||||
|
import kr.co.vividnext.sodalive.content.series.ContentSeriesService
|
||||||
|
import kr.co.vividnext.sodalive.content.series.main.banner.ContentSeriesBannerService
|
||||||
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
||||||
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.data.domain.PageRequest
|
||||||
|
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
|
||||||
|
@RequestMapping("/audio-content/series/main")
|
||||||
|
class SeriesMainController(
|
||||||
|
private val contentSeriesService: ContentSeriesService,
|
||||||
|
private val bannerService: ContentSeriesBannerService,
|
||||||
|
|
||||||
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
|
private val imageHost: String
|
||||||
|
) {
|
||||||
|
@GetMapping
|
||||||
|
fun fetchData(
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
val banners = bannerService.getActiveBanners(PageRequest.of(0, 10))
|
||||||
|
.content
|
||||||
|
.map {
|
||||||
|
SeriesBannerResponse.from(it, imageHost)
|
||||||
|
}
|
||||||
|
|
||||||
|
val completedSeriesList = contentSeriesService.getSeriesList(
|
||||||
|
creatorId = null,
|
||||||
|
isCompleted = true,
|
||||||
|
orderByRandom = true,
|
||||||
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
member = member
|
||||||
|
).items
|
||||||
|
|
||||||
|
val recommendSeriesList = contentSeriesService.getRecommendSeriesList(
|
||||||
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
member = member
|
||||||
|
)
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
SeriesHomeResponse(
|
||||||
|
banners = banners,
|
||||||
|
completedSeriesList = completedSeriesList,
|
||||||
|
recommendSeriesList = recommendSeriesList
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/recommend")
|
||||||
|
fun getRecommendSeriesList(
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
contentSeriesService.getRecommendSeriesList(
|
||||||
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
member = member
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/day-of-week")
|
||||||
|
fun getDayOfWeekSeriesList(
|
||||||
|
@RequestParam("dayOfWeek") dayOfWeek: SeriesPublishedDaysOfWeek,
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@RequestParam(defaultValue = "0") page: Int,
|
||||||
|
@RequestParam(defaultValue = "20") size: Int,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
val pageable = PageRequest.of(page, size)
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
contentSeriesService.getDayOfWeekSeriesList(
|
||||||
|
memberId = member.id,
|
||||||
|
isAdult = member.auth != null && (isAdultContentVisible ?: true),
|
||||||
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
dayOfWeek = dayOfWeek,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/genre-list")
|
||||||
|
fun getGenreList(
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
val memberId = member.id!!
|
||||||
|
val isAdult = member.auth != null && (isAdultContentVisible ?: true)
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
contentSeriesService.getGenreList(
|
||||||
|
memberId = memberId,
|
||||||
|
isAdult = isAdult,
|
||||||
|
contentType = contentType ?: ContentType.ALL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-by-genre")
|
||||||
|
fun getSeriesListByGenre(
|
||||||
|
@RequestParam("genreId") genreId: Long,
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@RequestParam(defaultValue = "0") page: Int,
|
||||||
|
@RequestParam(defaultValue = "20") size: Int,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
val pageable = PageRequest.of(page, size)
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
contentSeriesService.getSeriesListByGenre(
|
||||||
|
genreId = genreId,
|
||||||
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
member = member,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package kr.co.vividnext.sodalive.content.series.main.banner
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.AdminContentSeriesRepository
|
||||||
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
|
import org.springframework.data.domain.Page
|
||||||
|
import org.springframework.data.domain.Pageable
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class ContentSeriesBannerService(
|
||||||
|
private val bannerRepository: SeriesBannerRepository,
|
||||||
|
private val seriesRepository: AdminContentSeriesRepository
|
||||||
|
) {
|
||||||
|
fun getActiveBanners(pageable: Pageable): Page<SeriesBanner> {
|
||||||
|
return bannerRepository.findByIsActiveTrueOrderBySortOrderAsc(pageable)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBannerById(bannerId: Long): SeriesBanner {
|
||||||
|
return bannerRepository.findById(bannerId)
|
||||||
|
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun registerBanner(seriesId: Long, imagePath: String): SeriesBanner {
|
||||||
|
val series = seriesRepository.findByIdAndActiveTrue(seriesId)
|
||||||
|
?: throw SodaException("시리즈를 찾을 수 없습니다: $seriesId")
|
||||||
|
|
||||||
|
val finalSortOrder = (bannerRepository.findMaxSortOrder() ?: 0) + 1
|
||||||
|
|
||||||
|
val banner = SeriesBanner(
|
||||||
|
imagePath = imagePath,
|
||||||
|
series = series,
|
||||||
|
sortOrder = finalSortOrder
|
||||||
|
)
|
||||||
|
return bannerRepository.save(banner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun updateBanner(
|
||||||
|
bannerId: Long,
|
||||||
|
imagePath: String? = null,
|
||||||
|
seriesId: Long? = null
|
||||||
|
): SeriesBanner {
|
||||||
|
val banner = bannerRepository.findById(bannerId)
|
||||||
|
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||||
|
if (!banner.isActive) throw SodaException("비활성화된 배너는 수정할 수 없습니다: $bannerId")
|
||||||
|
|
||||||
|
if (imagePath != null) banner.imagePath = imagePath
|
||||||
|
|
||||||
|
if (seriesId != null) {
|
||||||
|
val series = seriesRepository.findByIdAndActiveTrue(seriesId)
|
||||||
|
?: throw SodaException("시리즈를 찾을 수 없습니다: $seriesId")
|
||||||
|
banner.series = series
|
||||||
|
}
|
||||||
|
|
||||||
|
return bannerRepository.save(banner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun deleteBanner(bannerId: Long) {
|
||||||
|
val banner = bannerRepository.findById(bannerId)
|
||||||
|
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||||
|
banner.isActive = false
|
||||||
|
bannerRepository.save(banner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun updateBannerOrders(ids: List<Long>): List<SeriesBanner> {
|
||||||
|
val updated = mutableListOf<SeriesBanner>()
|
||||||
|
for (index in ids.indices) {
|
||||||
|
val banner = bannerRepository.findById(ids[index])
|
||||||
|
.orElseThrow { SodaException("배너를 찾을 수 없습니다: ${ids[index]}") }
|
||||||
|
if (!banner.isActive) throw SodaException("비활성화된 배너는 수정할 수 없습니다: ${ids[index]}")
|
||||||
|
banner.sortOrder = index + 1
|
||||||
|
updated.add(bannerRepository.save(banner))
|
||||||
|
}
|
||||||
|
return updated
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package kr.co.vividnext.sodalive.content.series.main.banner
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||||
|
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
||||||
|
import javax.persistence.Entity
|
||||||
|
import javax.persistence.FetchType
|
||||||
|
import javax.persistence.JoinColumn
|
||||||
|
import javax.persistence.ManyToOne
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 시리즈 배너 엔티티
|
||||||
|
* 이미지와 시리즈 ID를 가지며, 소프트 삭제(isActive = false)를 지원합니다.
|
||||||
|
* 정렬 순서(sortOrder)를 통해 배너의 표시 순서를 결정합니다.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
class SeriesBanner(
|
||||||
|
// 배너 이미지 경로
|
||||||
|
var imagePath: String? = null,
|
||||||
|
|
||||||
|
// 연관된 캐릭터
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "series_id")
|
||||||
|
var series: Series,
|
||||||
|
|
||||||
|
// 정렬 순서 (낮을수록 먼저 표시)
|
||||||
|
var sortOrder: Int = 0,
|
||||||
|
|
||||||
|
// 활성화 여부 (소프트 삭제용)
|
||||||
|
var isActive: Boolean = true
|
||||||
|
) : BaseEntity()
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package kr.co.vividnext.sodalive.content.series.main.banner
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page
|
||||||
|
import org.springframework.data.domain.Pageable
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
interface SeriesBannerRepository : JpaRepository<SeriesBanner, Long> {
|
||||||
|
fun findByIsActiveTrueOrderBySortOrderAsc(pageable: Pageable): Page<SeriesBanner>
|
||||||
|
|
||||||
|
@Query("SELECT MAX(b.sortOrder) FROM SeriesBanner b WHERE b.isActive = true")
|
||||||
|
fun findMaxSortOrder(): Int?
|
||||||
|
}
|
||||||
@@ -27,6 +27,26 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
|||||||
ApiResponse.ok(service.getThemes())
|
ApiResponse.ok(service.getThemes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/active")
|
||||||
|
fun getActiveThemes(
|
||||||
|
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||||
|
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.getActiveThemeOfContent(
|
||||||
|
isAdult = member.auth != null && (isAdultContentVisible ?: true),
|
||||||
|
isFree = isFree ?: false,
|
||||||
|
isPointAvailableOnly = isPointAvailableOnly ?: false,
|
||||||
|
contentType = contentType ?: ContentType.ALL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}/content")
|
@GetMapping("/{id}/content")
|
||||||
fun getContentByTheme(
|
fun getContentByTheme(
|
||||||
@PathVariable id: Long,
|
@PathVariable id: Long,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package kr.co.vividnext.sodalive.content.theme
|
package kr.co.vividnext.sodalive.content.theme
|
||||||
|
|
||||||
|
import com.querydsl.core.types.dsl.CaseBuilder
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.content.ContentType
|
import kr.co.vividnext.sodalive.content.ContentType
|
||||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||||
@@ -32,6 +33,7 @@ class AudioContentThemeQueryRepository(
|
|||||||
fun getActiveThemeOfContent(
|
fun getActiveThemeOfContent(
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
|
isPointAvailableOnly: Boolean = false,
|
||||||
contentType: ContentType
|
contentType: ContentType
|
||||||
): List<String> {
|
): List<String> {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
@@ -59,15 +61,31 @@ class AudioContentThemeQueryRepository(
|
|||||||
where = where.and(audioContent.price.loe(0))
|
where = where.and(audioContent.price.loe(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryFactory
|
if (isPointAvailableOnly) {
|
||||||
|
where = where.and(audioContent.isPointAvailable.isTrue)
|
||||||
|
}
|
||||||
|
|
||||||
|
val query = queryFactory
|
||||||
.select(audioContentTheme.theme)
|
.select(audioContentTheme.theme)
|
||||||
.from(audioContent)
|
.from(audioContent)
|
||||||
.innerJoin(audioContent.member, member)
|
.innerJoin(audioContent.member, member)
|
||||||
.innerJoin(audioContent.theme, audioContentTheme)
|
.innerJoin(audioContent.theme, audioContentTheme)
|
||||||
.where(where)
|
.where(where)
|
||||||
.groupBy(audioContentTheme.id)
|
.groupBy(audioContentTheme.id)
|
||||||
.orderBy(audioContentTheme.orders.asc())
|
|
||||||
.fetch()
|
if (isFree) {
|
||||||
|
query.orderBy(
|
||||||
|
CaseBuilder()
|
||||||
|
.`when`(audioContentTheme.theme.eq("자기소개")).then(0)
|
||||||
|
.otherwise(1)
|
||||||
|
.asc(),
|
||||||
|
audioContentTheme.orders.asc()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
query.orderBy(audioContentTheme.orders.asc())
|
||||||
|
}
|
||||||
|
|
||||||
|
return query.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findThemeByIdAndActive(id: Long): AudioContentTheme? {
|
fun findThemeByIdAndActive(id: Long): AudioContentTheme? {
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ class AudioContentThemeService(
|
|||||||
fun getActiveThemeOfContent(
|
fun getActiveThemeOfContent(
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
|
isPointAvailableOnly: Boolean = false,
|
||||||
contentType: ContentType
|
contentType: ContentType
|
||||||
): List<String> {
|
): List<String> {
|
||||||
return queryRepository.getActiveThemeOfContent(
|
return queryRepository.getActiveThemeOfContent(
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
isFree = isFree,
|
isFree = isFree,
|
||||||
|
isPointAvailableOnly = isPointAvailableOnly,
|
||||||
contentType = contentType
|
contentType = contentType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user