Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import hs.kr.entrydsm.feed.domain.notice.application.port.`in`.DeleteNoticeUseCa
import hs.kr.entrydsm.feed.domain.notice.application.port.out.DeleteNoticePort
import hs.kr.entrydsm.feed.domain.notice.application.port.out.FindNoticePort
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.UUID

/**
Expand All @@ -24,6 +25,7 @@ class DeleteNoticeService(
* @param noticeId 삭제할 공지사항의 고유 식별자
* @throws NoticeNotFoundException 지정된 ID의 공지사항을 찾을 수 없는 경우
*/
@Transactional
override fun execute(noticeId: UUID) {
val notice = findNoticePort.findByIdOrNull(noticeId) ?: throw NoticeNotFoundException
deleteNoticePort.deleteNotice(notice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import hs.kr.entrydsm.feed.infrastructure.s3.util.FileUtil
import hs.kr.entrydsm.feed.domain.attachFile.model.AttachFile
import hs.kr.entrydsm.feed.domain.notice.application.port.`in`.UpdateNoticeUseCase
import hs.kr.entrydsm.feed.domain.notice.application.port.out.FindNoticePort
import hs.kr.entrydsm.feed.domain.notice.application.port.out.SaveNoticePort
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.UUID

/**
Expand All @@ -29,6 +31,7 @@ class UpdateNoticeService(
private val fileUtil: FileUtil,
private val adminUtils: AdminUtils,
private val findAttachFilePort: FindAttachFilePort,
private val saveNoticePort: SaveNoticePort
) : UpdateNoticeUseCase {
/**
* 공지사항을 수정합니다.
Expand All @@ -40,6 +43,7 @@ class UpdateNoticeService(
* @throws AttachFileNotFoundException 첨부 파일을 찾을 수 없는 경우
* @throws hs.kr.entrydsm.feed.global.exception.UnauthorizedException 관리자 인증에 실패한 경우
*/
@Transactional
override fun execute(
noticeId: UUID,
request: UpdateNoticeRequest,
Expand All @@ -50,17 +54,19 @@ class UpdateNoticeService(
val fileName = request.fileName
val attachFiles = findAttachFiles(request.attachFileName)

request.run {
notice.updateNotice(
newTitle = title,
newContent = content,
newIsPinned = isPinned,
newType = type,
newFileName = fileName,
newAdminId = adminId,
newAttachFile = attachFiles,
)
}
saveNoticePort.saveNotice(
request.run {
notice.updateNotice(
newTitle = title,
newContent = content,
newIsPinned = isPinned,
newType = type,
newFileName = fileName,
newAdminId = adminId,
newAttachFile = attachFiles,
)
}
)

return fileName?.let {
ResponseEntity.ok(fileUtil.generateObjectUrl(it, PathList.NOTICE))
Expand Down
Loading