Compare commits
No commits in common. "05e714fff105cd874481ce46bf7998c727af2104" and "1b782f3df802f3a580c1bee737085b4b9932b339" have entirely different histories.
05e714fff1
...
1b782f3df8
|
@ -1,40 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
|
||||||
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
|
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
|
||||||
@RequestMapping("/admin/audio-content/series/recommend")
|
|
||||||
class AdminRecommendSeriesController(private val service: AdminRecommendSeriesService) {
|
|
||||||
@GetMapping
|
|
||||||
fun getRecommendSeriesList(@RequestParam isFree: Boolean) = ApiResponse.ok(
|
|
||||||
service.getRecommendSeriesList(isFree = isFree)
|
|
||||||
)
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
fun createRecommendSeries(
|
|
||||||
@RequestPart("image") image: MultipartFile,
|
|
||||||
@RequestPart("request") requestString: String
|
|
||||||
) = ApiResponse.ok(service.createRecommendSeries(image, requestString))
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
fun modifyRecommendSeries(
|
|
||||||
@RequestPart("image", required = false) image: MultipartFile? = null,
|
|
||||||
@RequestPart("request") requestString: String
|
|
||||||
) = ApiResponse.ok(service.updateRecommendSeries(image, requestString))
|
|
||||||
|
|
||||||
@PutMapping("/orders")
|
|
||||||
fun updateRecommendSeriesOrders(
|
|
||||||
@RequestBody request: UpdateRecommendSeriesOrdersRequest
|
|
||||||
) = ApiResponse.ok(service.updateRecommendSeriesOrders(request.ids))
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
|
||||||
import kr.co.vividnext.sodalive.content.main.tab.QRecommendSeries.recommendSeries
|
|
||||||
import kr.co.vividnext.sodalive.content.main.tab.RecommendSeries
|
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
|
||||||
import org.springframework.beans.factory.annotation.Value
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
|
||||||
|
|
||||||
interface AdminRecommendSeriesRepository :
|
|
||||||
JpaRepository<RecommendSeries, Long>,
|
|
||||||
AdminRecommendSeriesQueryRepository
|
|
||||||
|
|
||||||
interface AdminRecommendSeriesQueryRepository {
|
|
||||||
fun getRecommendSeriesList(isFree: Boolean): List<GetAdminRecommendSeriesListResponse>
|
|
||||||
}
|
|
||||||
|
|
||||||
class AdminRecommendSeriesQueryRepositoryImpl(
|
|
||||||
private val queryFactory: JPAQueryFactory,
|
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
|
||||||
private val imageHost: String
|
|
||||||
) : AdminRecommendSeriesQueryRepository {
|
|
||||||
override fun getRecommendSeriesList(isFree: Boolean): List<GetAdminRecommendSeriesListResponse> {
|
|
||||||
return queryFactory
|
|
||||||
.select(
|
|
||||||
QGetAdminRecommendSeriesListResponse(
|
|
||||||
recommendSeries.id,
|
|
||||||
series.id,
|
|
||||||
series.title,
|
|
||||||
recommendSeries.imagePath.prepend("/").prepend(imageHost)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(recommendSeries)
|
|
||||||
.innerJoin(recommendSeries.series, series)
|
|
||||||
.where(
|
|
||||||
recommendSeries.isActive.isTrue
|
|
||||||
.and(series.isActive.isTrue)
|
|
||||||
.and(recommendSeries.isFree.eq(isFree))
|
|
||||||
)
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import kr.co.vividnext.sodalive.admin.content.series.AdminContentSeriesRepository
|
|
||||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
|
||||||
import kr.co.vividnext.sodalive.content.main.tab.RecommendSeries
|
|
||||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
|
||||||
import org.springframework.beans.factory.annotation.Value
|
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
|
||||||
import org.springframework.stereotype.Service
|
|
||||||
import org.springframework.transaction.annotation.Transactional
|
|
||||||
import org.springframework.web.multipart.MultipartFile
|
|
||||||
|
|
||||||
@Service
|
|
||||||
class AdminRecommendSeriesService(
|
|
||||||
private val s3Uploader: S3Uploader,
|
|
||||||
private val repository: AdminRecommendSeriesRepository,
|
|
||||||
private val seriesRepository: AdminContentSeriesRepository,
|
|
||||||
private val objectMapper: ObjectMapper,
|
|
||||||
|
|
||||||
@Value("\${cloud.aws.s3.bucket}")
|
|
||||||
private val bucket: String
|
|
||||||
) {
|
|
||||||
fun getRecommendSeriesList(isFree: Boolean): List<GetAdminRecommendSeriesListResponse> {
|
|
||||||
return repository.getRecommendSeriesList(isFree = isFree)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun createRecommendSeries(image: MultipartFile, requestString: String) {
|
|
||||||
val request = objectMapper.readValue(requestString, CreateRecommendSeriesRequest::class.java)
|
|
||||||
val series = seriesRepository.findByIdOrNull(request.seriesId)
|
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
|
||||||
|
|
||||||
val recommendSeries = RecommendSeries(isFree = request.isFree)
|
|
||||||
recommendSeries.series = series
|
|
||||||
repository.save(recommendSeries)
|
|
||||||
|
|
||||||
val fileName = generateFileName()
|
|
||||||
val imagePath = s3Uploader.upload(
|
|
||||||
inputStream = image.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "recommend_series/${recommendSeries.id}/$fileName"
|
|
||||||
)
|
|
||||||
recommendSeries.imagePath = imagePath
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun updateRecommendSeries(image: MultipartFile?, requestString: String) {
|
|
||||||
val request = objectMapper.readValue(requestString, UpdateRecommendSeriesRequest::class.java)
|
|
||||||
val recommendSeries = repository.findByIdOrNull(request.id)
|
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
|
||||||
|
|
||||||
if (image != null) {
|
|
||||||
val fileName = generateFileName()
|
|
||||||
val imagePath = s3Uploader.upload(
|
|
||||||
inputStream = image.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "recommend_series/${recommendSeries.id}/$fileName"
|
|
||||||
)
|
|
||||||
recommendSeries.imagePath = imagePath
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.isActive != null) {
|
|
||||||
recommendSeries.isActive = request.isActive
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.seriesId != null) {
|
|
||||||
val series = seriesRepository.findByIdOrNull(request.seriesId)
|
|
||||||
|
|
||||||
if (series != null) {
|
|
||||||
recommendSeries.series = series
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun updateRecommendSeriesOrders(ids: List<Long>) {
|
|
||||||
for (index in ids.indices) {
|
|
||||||
val recommendSeries = repository.findByIdOrNull(ids[index])
|
|
||||||
|
|
||||||
if (recommendSeries != null) {
|
|
||||||
recommendSeries.orders = index + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
data class CreateRecommendSeriesRequest(
|
|
||||||
val seriesId: Long,
|
|
||||||
val isFree: Boolean
|
|
||||||
)
|
|
|
@ -1,10 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class GetAdminRecommendSeriesListResponse @QueryProjection constructor(
|
|
||||||
val id: Long,
|
|
||||||
val seriesId: Long,
|
|
||||||
val seriesTitle: String,
|
|
||||||
val imageUrl: String
|
|
||||||
)
|
|
|
@ -1,5 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
data class UpdateRecommendSeriesOrdersRequest(
|
|
||||||
val ids: List<Long>
|
|
||||||
)
|
|
|
@ -1,7 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.series.recommend
|
|
||||||
|
|
||||||
data class UpdateRecommendSeriesRequest(
|
|
||||||
val id: Long,
|
|
||||||
val seriesId: Long?,
|
|
||||||
val isActive: Boolean?
|
|
||||||
)
|
|
|
@ -42,8 +42,8 @@ class AuditionVoteService(
|
||||||
endDate = endDate
|
endDate = endDate
|
||||||
)
|
)
|
||||||
|
|
||||||
if (voteCount > 100) {
|
if (voteCount > 10) {
|
||||||
throw SodaException("오늘 응원은 여기까지!\n하루 최대 100회까지 응원이 가능합니다.\n내일 다시 이용해주세요.")
|
throw SodaException("오늘 응원은 여기까지!\n하루 최대 10회까지 응원이 가능합니다.\n내일 다시 이용해주세요.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (voteCount > 0) {
|
if (voteCount > 0) {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.main.tab
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
|
||||||
import javax.persistence.Column
|
|
||||||
import javax.persistence.Entity
|
|
||||||
import javax.persistence.FetchType
|
|
||||||
import javax.persistence.JoinColumn
|
|
||||||
import javax.persistence.ManyToOne
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
data class RecommendSeries(
|
|
||||||
@Column(nullable = false)
|
|
||||||
var imagePath: String = "",
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
var orders: Int = 1,
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
var isFree: Boolean = false,
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
var isActive: Boolean = true
|
|
||||||
) : BaseEntity() {
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "series_id", nullable = false)
|
|
||||||
var series: Series? = null
|
|
||||||
}
|
|
Loading…
Reference in New Issue