Compare commits

..

No commits in common. "aa23d6d50f042abdad6824e9df57cf73f18c5563" and "0f48c71837c062ca5f24235f5117590b198576f5" have entirely different histories.

5 changed files with 16 additions and 45 deletions

View File

@ -29,7 +29,7 @@ class AudioContentCommentController(
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
val commentId = service.registerComment( service.registerComment(
comment = request.comment, comment = request.comment,
audioContentId = request.contentId, audioContentId = request.contentId,
parentId = request.parentId, parentId = request.parentId,
@ -44,7 +44,6 @@ class AudioContentCommentController(
userActionService.recordAction( userActionService.recordAction(
memberId = member.id!!, memberId = member.id!!,
actionType = ActionType.CONTENT_COMMENT, actionType = ActionType.CONTENT_COMMENT,
commentId = commentId,
pushTokenList = pushTokenList pushTokenList = pushTokenList
) )
@ -52,7 +51,6 @@ class AudioContentCommentController(
memberId = member.id!!, memberId = member.id!!,
actionType = ActionType.ORDER_CONTENT_COMMENT, actionType = ActionType.ORDER_CONTENT_COMMENT,
contentId = request.contentId, contentId = request.contentId,
commentId = commentId,
pushTokenList = pushTokenList pushTokenList = pushTokenList
) )
} catch (_: Exception) { } catch (_: Exception) {

View File

@ -33,7 +33,7 @@ class AudioContentCommentService(
audioContentId: Long, audioContentId: Long,
parentId: Long? = null, parentId: Long? = null,
isSecret: Boolean = false isSecret: Boolean = false
): Long { ) {
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId) val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.") ?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
@ -64,7 +64,7 @@ class AudioContentCommentService(
audioContentComment.parent = parent audioContentComment.parent = parent
} }
val savedContentComment = repository.save(audioContentComment) repository.save(audioContentComment)
applicationEventPublisher.publishEvent( applicationEventPublisher.publishEvent(
FcmEvent( FcmEvent(
@ -84,8 +84,6 @@ class AudioContentCommentService(
myMemberId = member.id myMemberId = member.id
) )
) )
return savedContentComment.id!!
} }
@Transactional @Transactional

View File

@ -8,35 +8,21 @@ import java.time.LocalDateTime
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository
interface PointGrantLogQueryRepository { interface PointGrantLogQueryRepository {
fun countByMemberIdAndPolicyIdAndStartDate( fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int
memberId: Long,
policyId: Long,
startDate: LocalDateTime,
orderId: Long? = null
): Int
} }
class PointGrantLogQueryRepositoryImpl( class PointGrantLogQueryRepositoryImpl(
private val queryFactory: JPAQueryFactory private val queryFactory: JPAQueryFactory
) : PointGrantLogQueryRepository { ) : PointGrantLogQueryRepository {
override fun countByMemberIdAndPolicyIdAndStartDate( override fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int {
memberId: Long,
policyId: Long,
startDate: LocalDateTime,
orderId: Long?
): Int {
var where = pointGrantLog.memberId.eq(memberId)
.and(pointGrantLog.policyId.eq(policyId))
.and(pointGrantLog.createdAt.goe(startDate))
if (orderId != null) {
where = where.and(pointGrantLog.orderId.eq(orderId))
}
return queryFactory return queryFactory
.select(pointGrantLog.id) .select(pointGrantLog.id)
.from(pointGrantLog) .from(pointGrantLog)
.where(where) .where(
pointGrantLog.memberId.eq(memberId),
pointGrantLog.policyId.eq(policyId),
pointGrantLog.createdAt.goe(startDate)
)
.fetch() .fetch()
.size .size
} }

View File

@ -9,6 +9,5 @@ import javax.persistence.Enumerated
data class UserActionLog( data class UserActionLog(
val memberId: Long, val memberId: Long,
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
val actionType: ActionType, val actionType: ActionType
val commentId: Long? = null
) : BaseEntity() ) : BaseEntity()

View File

@ -33,19 +33,12 @@ class UserActionService(
memberId: Long, memberId: Long,
actionType: ActionType, actionType: ActionType,
contentId: Long? = null, contentId: Long? = null,
commentId: Long? = null,
pushTokenList: List<String> = emptyList() pushTokenList: List<String> = emptyList()
) { ) {
coroutineScope.launch { coroutineScope.launch {
val now = LocalDateTime.now() val now = LocalDateTime.now()
transactionTemplate.execute { transactionTemplate.execute {
repository.save( repository.save(UserActionLog(memberId, actionType))
UserActionLog(
memberId = memberId,
actionType = actionType,
commentId = commentId
)
)
repository.flush() repository.flush()
} }
@ -61,13 +54,11 @@ class UserActionService(
todayAt15 todayAt15
} }
val isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate =
policyType == PolicyType.DAILY && policyTypeDailyStartDate >= policy.startDate
val order = if (contentId != null) { val order = if (contentId != null) {
orderRepository.findByMemberIdAndContentId( orderRepository.findByMemberIdAndContentId(
memberId = memberId, memberId = memberId,
contentId = contentId, contentId = contentId,
createdAt = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) { createdAt = if (policyType == PolicyType.DAILY) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
@ -81,7 +72,7 @@ class UserActionService(
val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween( val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
memberId = memberId, memberId = memberId,
actionType = actionType, actionType = actionType,
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) { startDate = if (policyType == PolicyType.DAILY) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
@ -93,12 +84,11 @@ class UserActionService(
val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate( val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate(
memberId, memberId,
policy.id!!, policy.id!!,
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) { startDate = if (policyType == PolicyType.DAILY) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
}, }
orderId = order?.id
) )
if (grantedCount >= policy.availableCount) return@execute if (grantedCount >= policy.availableCount) return@execute