Compare commits
3 Commits
0f48c71837
...
aa23d6d50f
Author | SHA1 | Date |
---|---|---|
|
aa23d6d50f | |
|
6df043dfac | |
|
fe84292483 |
|
@ -29,7 +29,7 @@ class AudioContentCommentController(
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
service.registerComment(
|
val commentId = service.registerComment(
|
||||||
comment = request.comment,
|
comment = request.comment,
|
||||||
audioContentId = request.contentId,
|
audioContentId = request.contentId,
|
||||||
parentId = request.parentId,
|
parentId = request.parentId,
|
||||||
|
@ -44,6 +44,7 @@ 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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ 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) {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
repository.save(audioContentComment)
|
val savedContentComment = repository.save(audioContentComment)
|
||||||
|
|
||||||
applicationEventPublisher.publishEvent(
|
applicationEventPublisher.publishEvent(
|
||||||
FcmEvent(
|
FcmEvent(
|
||||||
|
@ -84,6 +84,8 @@ class AudioContentCommentService(
|
||||||
myMemberId = member.id
|
myMemberId = member.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return savedContentComment.id!!
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -8,21 +8,35 @@ import java.time.LocalDateTime
|
||||||
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository
|
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository
|
||||||
|
|
||||||
interface PointGrantLogQueryRepository {
|
interface PointGrantLogQueryRepository {
|
||||||
fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int
|
fun countByMemberIdAndPolicyIdAndStartDate(
|
||||||
|
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(memberId: Long, policyId: Long, startDate: LocalDateTime): Int {
|
override fun countByMemberIdAndPolicyIdAndStartDate(
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,6 @@ 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()
|
||||||
|
|
|
@ -33,12 +33,19 @@ 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(UserActionLog(memberId, actionType))
|
repository.save(
|
||||||
|
UserActionLog(
|
||||||
|
memberId = memberId,
|
||||||
|
actionType = actionType,
|
||||||
|
commentId = commentId
|
||||||
|
)
|
||||||
|
)
|
||||||
repository.flush()
|
repository.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +61,13 @@ 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 (policyType == PolicyType.DAILY) {
|
createdAt = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||||
policyTypeDailyStartDate
|
policyTypeDailyStartDate
|
||||||
} else {
|
} else {
|
||||||
policy.startDate
|
policy.startDate
|
||||||
|
@ -72,7 +81,7 @@ class UserActionService(
|
||||||
val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
|
val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
|
||||||
memberId = memberId,
|
memberId = memberId,
|
||||||
actionType = actionType,
|
actionType = actionType,
|
||||||
startDate = if (policyType == PolicyType.DAILY) {
|
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||||
policyTypeDailyStartDate
|
policyTypeDailyStartDate
|
||||||
} else {
|
} else {
|
||||||
policy.startDate
|
policy.startDate
|
||||||
|
@ -84,11 +93,12 @@ class UserActionService(
|
||||||
val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate(
|
val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate(
|
||||||
memberId,
|
memberId,
|
||||||
policy.id!!,
|
policy.id!!,
|
||||||
startDate = if (policyType == PolicyType.DAILY) {
|
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||||
policyTypeDailyStartDate
|
policyTypeDailyStartDate
|
||||||
} else {
|
} else {
|
||||||
policy.startDate
|
policy.startDate
|
||||||
}
|
},
|
||||||
|
orderId = order?.id
|
||||||
)
|
)
|
||||||
if (grantedCount >= policy.availableCount) return@execute
|
if (grantedCount >= policy.availableCount) return@execute
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue