This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from GSM-MSG/314-feat/notification-detail-api
🔀 :: 314 공지사항 상세 조회 API
- Loading branch information
Showing
7 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...tlin/com/msg/gcms/domain/notice/presentation/data/response/FindNoticeDetailResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.msg.gcms.domain.notice.presentation.data.response | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class FindNoticeDetailResponseDto( | ||
val title: String, | ||
val content : String, | ||
val username : String, | ||
val userProfileImg : String?, | ||
val createdAt : LocalDateTime | ||
) |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/msg/gcms/domain/notice/service/FindNoticeDetailService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.msg.gcms.domain.notice.service | ||
|
||
import com.msg.gcms.domain.notice.presentation.data.response.FindNoticeDetailResponseDto | ||
|
||
interface FindNoticeDetailService { | ||
fun execute(id: Long): FindNoticeDetailResponseDto | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/msg/gcms/domain/notice/service/impl/FindNoticeDetailServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.msg.gcms.domain.notice.service.impl | ||
|
||
import com.msg.gcms.domain.auth.domain.Role | ||
import com.msg.gcms.domain.club.exception.HeadNotSameException | ||
import com.msg.gcms.domain.notice.domain.repository.NoticeRepository | ||
import com.msg.gcms.domain.notice.exception.NoticeNotFoundException | ||
import com.msg.gcms.domain.notice.presentation.data.response.FindNoticeDetailResponseDto | ||
import com.msg.gcms.domain.notice.service.FindNoticeDetailService | ||
import com.msg.gcms.domain.notice.utils.NoticeConverter | ||
import com.msg.gcms.global.annotation.ServiceWithReadOnlyTransaction | ||
import com.msg.gcms.global.util.UserUtil | ||
import org.springframework.data.repository.findByIdOrNull | ||
|
||
@ServiceWithReadOnlyTransaction | ||
class FindNoticeDetailServiceImpl( | ||
private val userUtil: UserUtil, | ||
private val noticeRepository: NoticeRepository, | ||
private val noticeConverter: NoticeConverter | ||
) : FindNoticeDetailService { | ||
override fun execute(id: Long): FindNoticeDetailResponseDto { | ||
val currentUser = userUtil.fetchCurrentUser() | ||
|
||
val notice = noticeRepository.findByIdOrNull(id) ?: throw NoticeNotFoundException() | ||
|
||
if (notice.club.user != currentUser && currentUser.roles[0] != Role.ROLE_ADMIN) | ||
throw HeadNotSameException() | ||
|
||
return noticeConverter.toResponse(notice) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters