fix(event): 이벤트 성인 여부 조회 기준을 인증 저장소로 변경한다
This commit is contained in:
@@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.event
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
@@ -24,11 +23,8 @@ class EventController(private val service: EventService) {
|
||||
) = run {
|
||||
ApiResponse.ok(
|
||||
service.getEventList(
|
||||
if (member?.role == MemberRole.ADMIN) {
|
||||
null
|
||||
} else {
|
||||
member?.auth != null
|
||||
}
|
||||
memberId = member?.id,
|
||||
memberRole = member?.role
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -36,7 +32,7 @@ class EventController(private val service: EventService) {
|
||||
@GetMapping("/popup")
|
||||
fun getEventPopup(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = ApiResponse.ok(service.getEventPopup(member?.auth != null))
|
||||
) = ApiResponse.ok(service.getEventPopup(memberId = member?.id))
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
|
||||
@@ -3,6 +3,8 @@ package kr.co.vividnext.sodalive.event
|
||||
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.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.member.auth.AuthRepository
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
@@ -17,6 +19,7 @@ import java.time.format.DateTimeFormatter
|
||||
class EventService(
|
||||
private val repository: EventRepository,
|
||||
private val s3Uploader: S3Uploader,
|
||||
private val authRepository: AuthRepository,
|
||||
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val bucket: String,
|
||||
@@ -45,6 +48,16 @@ class EventService(
|
||||
return GetEventResponse(0, eventList)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getEventList(memberId: Long?, memberRole: MemberRole?): GetEventResponse {
|
||||
val isAdult = if (memberRole == MemberRole.ADMIN) {
|
||||
null
|
||||
} else {
|
||||
memberId?.let { authRepository.getAuthIdByMemberId(it) != null } ?: false
|
||||
}
|
||||
return getEventList(isAdult)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getEventPopup(isAdult: Boolean): EventItem? {
|
||||
val eventPopup = repository.getMainEventPopup(isAdult)
|
||||
@@ -66,6 +79,12 @@ class EventService(
|
||||
return eventPopup
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getEventPopup(memberId: Long?): EventItem? {
|
||||
val isAdult = memberId?.let { authRepository.getAuthIdByMemberId(it) != null } ?: false
|
||||
return getEventPopup(isAdult)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun save(
|
||||
thumbnail: MultipartFile,
|
||||
|
||||
Reference in New Issue
Block a user