| @@ -32,7 +32,7 @@ data class AudioContent( | ||||
|     var title: String, | ||||
|     @Column(columnDefinition = "TEXT", nullable = false) | ||||
|     var detail: String, | ||||
|     val price: Int = 0, | ||||
|     var price: Int = 0, | ||||
|     var releaseDate: LocalDateTime? = null, | ||||
|     val limited: Int? = null, | ||||
|     var remaining: Int? = null, | ||||
|   | ||||
| @@ -0,0 +1,29 @@ | ||||
| package kr.co.vividnext.sodalive.content | ||||
|  | ||||
| import java.time.LocalDateTime | ||||
| import javax.persistence.Entity | ||||
| import javax.persistence.FetchType | ||||
| import javax.persistence.GeneratedValue | ||||
| import javax.persistence.GenerationType | ||||
| import javax.persistence.Id | ||||
| import javax.persistence.JoinColumn | ||||
| import javax.persistence.ManyToOne | ||||
| import javax.persistence.PrePersist | ||||
|  | ||||
| @Entity | ||||
| data class ContentPriceChangeLog( | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|     var id: Long? = null, | ||||
|     val prevPrice: Int, | ||||
|     var createdAt: LocalDateTime? = null | ||||
| ) { | ||||
|     @ManyToOne(fetch = FetchType.LAZY) | ||||
|     @JoinColumn(name = "content_id", nullable = false) | ||||
|     var audioContent: AudioContent? = null | ||||
|  | ||||
|     @PrePersist | ||||
|     fun prePersist() { | ||||
|         createdAt = LocalDateTime.now() | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.content | ||||
|  | ||||
| import org.springframework.data.jpa.repository.JpaRepository | ||||
|  | ||||
| interface ContentPriceChangeLogRepository : JpaRepository<ContentPriceChangeLog, Long> | ||||
| @@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper | ||||
| import kr.co.vividnext.sodalive.aws.cloudfront.AudioContentCloudFront | ||||
| import kr.co.vividnext.sodalive.aws.s3.S3Uploader | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLog | ||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLogRepository | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -16,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile | ||||
| @Service | ||||
| class CreatorAdminContentService( | ||||
|     private val repository: CreatorAdminContentRepository, | ||||
|     private val contentPriceChangeLogRepository: ContentPriceChangeLogRepository, | ||||
|     private val audioContentCloudFront: AudioContentCloudFront, | ||||
|     private val objectMapper: ObjectMapper, | ||||
|     private val s3Uploader: S3Uploader, | ||||
| @@ -139,5 +142,15 @@ class CreatorAdminContentService( | ||||
|         if (request.detail != null) { | ||||
|             audioContent.detail = request.detail | ||||
|         } | ||||
|  | ||||
|         if (request.price != null) { | ||||
|             if (request.price < 5) throw SodaException("콘텐츠의 최소금액은 5캔 입니다.") | ||||
|  | ||||
|             val contentPriceChangeLog = ContentPriceChangeLog(prevPrice = audioContent.price) | ||||
|             contentPriceChangeLog.audioContent = audioContent | ||||
|             contentPriceChangeLogRepository.save(contentPriceChangeLog) | ||||
|  | ||||
|             audioContent.price = request.price | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ data class UpdateCreatorAdminContentRequest( | ||||
|     val id: Long, | ||||
|     val title: String?, | ||||
|     val detail: String?, | ||||
|     val price: Int?, | ||||
|     val isAdult: Boolean?, | ||||
|     val isActive: Boolean?, | ||||
|     val isCommentAvailable: Boolean? | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.creator.admin.signature | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.ApiResponse | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.data.domain.Pageable | ||||
| import org.springframework.security.access.prepost.PreAuthorize | ||||
| @@ -21,11 +22,18 @@ class CreatorAdminSignatureController(private val service: CreatorAdminSignature | ||||
|     @GetMapping | ||||
|     fun getSignatureCanList( | ||||
|         pageable: Pageable, | ||||
|         @RequestParam("sort-type", required = false) sortType: SignatureCanSortType?, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(data = service.getSignatureList(pageable, memberId = member.id!!)) | ||||
|         ApiResponse.ok( | ||||
|             data = service.getSignatureList( | ||||
|                 pageable, | ||||
|                 sortType ?: SignatureCanSortType.NEWEST, | ||||
|                 memberId = member.id!! | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @PostMapping | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.creator.admin.signature | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.live.signature.QSignatureCan.signatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import kr.co.vividnext.sodalive.member.QMember.member | ||||
| import org.springframework.data.jpa.repository.JpaRepository | ||||
|  | ||||
| @@ -11,7 +12,13 @@ interface CreatorAdminSignatureRepository : JpaRepository<SignatureCan, Long>, C | ||||
| interface CreatorAdminSignatureQueryRepository { | ||||
|     fun getSignatureListTotalCount(memberId: Long): Int | ||||
|  | ||||
|     fun getSignatureList(memberId: Long, imageHost: String, offset: Long, limit: Long): List<GetSignatureListItem> | ||||
|     fun getSignatureList( | ||||
|         memberId: Long, | ||||
|         sortType: SignatureCanSortType, | ||||
|         imageHost: String, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetSignatureListItem> | ||||
|  | ||||
|     fun findSignatureByIdOrNull(id: Long, memberId: Long): SignatureCan? | ||||
| } | ||||
| @@ -32,10 +39,25 @@ class CreatorAdminSignatureQueryRepositoryImpl( | ||||
|  | ||||
|     override fun getSignatureList( | ||||
|         memberId: Long, | ||||
|         sortType: SignatureCanSortType, | ||||
|         imageHost: String, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetSignatureListItem> { | ||||
|         val orderBy = when (sortType) { | ||||
|             SignatureCanSortType.CAN_HIGH -> { | ||||
|                 signatureCan.can.desc() | ||||
|             } | ||||
|  | ||||
|             SignatureCanSortType.CAN_LOW -> { | ||||
|                 signatureCan.can.asc() | ||||
|             } | ||||
|  | ||||
|             else -> { | ||||
|                 signatureCan.id.desc() | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return queryFactory.select( | ||||
|             QGetSignatureListItem( | ||||
|                 signatureCan.id, | ||||
| @@ -54,7 +76,7 @@ class CreatorAdminSignatureQueryRepositoryImpl( | ||||
|             ) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .orderBy(signatureCan.id.desc()) | ||||
|             .orderBy(orderBy) | ||||
|             .fetch() | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import com.amazonaws.services.s3.model.ObjectMetadata | ||||
| import kr.co.vividnext.sodalive.aws.s3.S3Uploader | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -24,10 +25,15 @@ class CreatorAdminSignatureService( | ||||
|     @Value("\${cloud.aws.cloud-front.host}") | ||||
|     private val imageHost: String | ||||
| ) { | ||||
|     fun getSignatureList(pageable: Pageable, memberId: Long): GetSignatureListResponse { | ||||
|     fun getSignatureList( | ||||
|         pageable: Pageable, | ||||
|         sortType: SignatureCanSortType, | ||||
|         memberId: Long | ||||
|     ): GetSignatureListResponse { | ||||
|         val totalCount = repository.getSignatureListTotalCount(memberId = memberId) | ||||
|         val items = repository.getSignatureList( | ||||
|             memberId = memberId, | ||||
|             sortType = sortType, | ||||
|             imageHost = imageHost, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|   | ||||
| @@ -0,0 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.live.signature | ||||
|  | ||||
| enum class SignatureCanSortType { | ||||
|     NEWEST, CAN_HIGH, CAN_LOW | ||||
| } | ||||
		Reference in New Issue
	
	Block a user