커뮤니티 게시물 신고 추가
This commit is contained in:
parent
2735ac32bb
commit
421846e08a
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.report
|
|||
|
||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||
import kr.co.vividnext.sodalive.explorer.profile.CreatorCheers
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunity
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.EnumType
|
||||
|
@ -27,6 +28,10 @@ data class Report(
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "cheers_id", nullable = true)
|
||||
var cheers: CreatorCheers? = null
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "community_post_id", nullable = true)
|
||||
var communityPost: CreatorCommunity? = null
|
||||
}
|
||||
|
||||
enum class ReportType {
|
||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.report
|
|||
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.explorer.profile.CreatorCheersRepository
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunityRepository
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
|
@ -13,7 +14,8 @@ import org.springframework.transaction.annotation.Transactional
|
|||
class ReportService(
|
||||
private val repository: ReportRepository,
|
||||
private val memberRepository: MemberRepository,
|
||||
private val cheersRepository: CreatorCheersRepository
|
||||
private val cheersRepository: CreatorCheersRepository,
|
||||
private val creatorCommunityRepository: CreatorCommunityRepository
|
||||
) {
|
||||
@Transactional
|
||||
fun save(member: Member, request: ReportRequest) {
|
||||
|
@ -35,18 +37,32 @@ class ReportService(
|
|||
null
|
||||
}
|
||||
|
||||
val communityPost = if (request.communityPostId != null) {
|
||||
creatorCommunityRepository.findByIdOrNull(request.communityPostId)
|
||||
?: throw SodaException("신고가 접수되었습니다.")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val report = Report(type = request.type, reason = request.reason)
|
||||
report.member = member
|
||||
report.reportedAccount = reportedAccount
|
||||
report.cheers = cheers
|
||||
report.communityPost = communityPost
|
||||
repository.save(report)
|
||||
}
|
||||
|
||||
private fun conditionAllIsNull(request: ReportRequest, isNull: Boolean): Boolean {
|
||||
return if (isNull) {
|
||||
request.reportedMemberId == null && request.cheersId == null && request.audioContentId == null
|
||||
request.reportedMemberId == null &&
|
||||
request.cheersId == null &&
|
||||
request.audioContentId == null &&
|
||||
request.communityPostId == null
|
||||
} else {
|
||||
request.reportedMemberId != null && request.cheersId != null && request.audioContentId != null
|
||||
request.reportedMemberId != null &&
|
||||
request.cheersId != null &&
|
||||
request.audioContentId != null &&
|
||||
request.communityPostId != null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue