Compare commits
No commits in common. "aa23d6d50f042abdad6824e9df57cf73f18c5563" and "0f48c71837c062ca5f24235f5117590b198576f5" have entirely different histories.
aa23d6d50f
...
0f48c71837
|
@ -29,7 +29,7 @@ class AudioContentCommentController(
|
|||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
val commentId = service.registerComment(
|
||||
service.registerComment(
|
||||
comment = request.comment,
|
||||
audioContentId = request.contentId,
|
||||
parentId = request.parentId,
|
||||
|
@ -44,7 +44,6 @@ class AudioContentCommentController(
|
|||
userActionService.recordAction(
|
||||
memberId = member.id!!,
|
||||
actionType = ActionType.CONTENT_COMMENT,
|
||||
commentId = commentId,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
|
||||
|
@ -52,7 +51,6 @@ class AudioContentCommentController(
|
|||
memberId = member.id!!,
|
||||
actionType = ActionType.ORDER_CONTENT_COMMENT,
|
||||
contentId = request.contentId,
|
||||
commentId = commentId,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class AudioContentCommentService(
|
|||
audioContentId: Long,
|
||||
parentId: Long? = null,
|
||||
isSecret: Boolean = false
|
||||
): Long {
|
||||
) {
|
||||
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
|
||||
|
@ -64,7 +64,7 @@ class AudioContentCommentService(
|
|||
audioContentComment.parent = parent
|
||||
}
|
||||
|
||||
val savedContentComment = repository.save(audioContentComment)
|
||||
repository.save(audioContentComment)
|
||||
|
||||
applicationEventPublisher.publishEvent(
|
||||
FcmEvent(
|
||||
|
@ -84,8 +84,6 @@ class AudioContentCommentService(
|
|||
myMemberId = member.id
|
||||
)
|
||||
)
|
||||
|
||||
return savedContentComment.id!!
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -8,35 +8,21 @@ import java.time.LocalDateTime
|
|||
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository
|
||||
|
||||
interface PointGrantLogQueryRepository {
|
||||
fun countByMemberIdAndPolicyIdAndStartDate(
|
||||
memberId: Long,
|
||||
policyId: Long,
|
||||
startDate: LocalDateTime,
|
||||
orderId: Long? = null
|
||||
): Int
|
||||
fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int
|
||||
}
|
||||
|
||||
class PointGrantLogQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : PointGrantLogQueryRepository {
|
||||
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))
|
||||
}
|
||||
|
||||
override fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int {
|
||||
return queryFactory
|
||||
.select(pointGrantLog.id)
|
||||
.from(pointGrantLog)
|
||||
.where(where)
|
||||
.where(
|
||||
pointGrantLog.memberId.eq(memberId),
|
||||
pointGrantLog.policyId.eq(policyId),
|
||||
pointGrantLog.createdAt.goe(startDate)
|
||||
)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
|
|
|
@ -9,6 +9,5 @@ import javax.persistence.Enumerated
|
|||
data class UserActionLog(
|
||||
val memberId: Long,
|
||||
@Enumerated(EnumType.STRING)
|
||||
val actionType: ActionType,
|
||||
val commentId: Long? = null
|
||||
val actionType: ActionType
|
||||
) : BaseEntity()
|
||||
|
|
|
@ -33,19 +33,12 @@ class UserActionService(
|
|||
memberId: Long,
|
||||
actionType: ActionType,
|
||||
contentId: Long? = null,
|
||||
commentId: Long? = null,
|
||||
pushTokenList: List<String> = emptyList()
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
val now = LocalDateTime.now()
|
||||
transactionTemplate.execute {
|
||||
repository.save(
|
||||
UserActionLog(
|
||||
memberId = memberId,
|
||||
actionType = actionType,
|
||||
commentId = commentId
|
||||
)
|
||||
)
|
||||
repository.save(UserActionLog(memberId, actionType))
|
||||
repository.flush()
|
||||
}
|
||||
|
||||
|
@ -61,13 +54,11 @@ class UserActionService(
|
|||
todayAt15
|
||||
}
|
||||
|
||||
val isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate =
|
||||
policyType == PolicyType.DAILY && policyTypeDailyStartDate >= policy.startDate
|
||||
val order = if (contentId != null) {
|
||||
orderRepository.findByMemberIdAndContentId(
|
||||
memberId = memberId,
|
||||
contentId = contentId,
|
||||
createdAt = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||
createdAt = if (policyType == PolicyType.DAILY) {
|
||||
policyTypeDailyStartDate
|
||||
} else {
|
||||
policy.startDate
|
||||
|
@ -81,7 +72,7 @@ class UserActionService(
|
|||
val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
|
||||
memberId = memberId,
|
||||
actionType = actionType,
|
||||
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||
startDate = if (policyType == PolicyType.DAILY) {
|
||||
policyTypeDailyStartDate
|
||||
} else {
|
||||
policy.startDate
|
||||
|
@ -93,12 +84,11 @@ class UserActionService(
|
|||
val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate(
|
||||
memberId,
|
||||
policy.id!!,
|
||||
startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||
startDate = if (policyType == PolicyType.DAILY) {
|
||||
policyTypeDailyStartDate
|
||||
} else {
|
||||
policy.startDate
|
||||
},
|
||||
orderId = order?.id
|
||||
}
|
||||
)
|
||||
if (grantedCount >= policy.availableCount) return@execute
|
||||
|
||||
|
|
Loading…
Reference in New Issue