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.
- Loading branch information
Showing
10 changed files
with
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @louis7308 @Huuuunee @dolong2 @yoonjibin @KimTaeO @JuuuuHong @ani2689 | ||
* @louis7308 @Huuuunee @dolong2 @yoonjibin @KimTaeO @ani2689 @ta2ye0n |
5 changes: 4 additions & 1 deletion
5
src/main/kotlin/com/msg/gcms/domain/notice/domain/repository/NoticeRepository.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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package com.msg.gcms.domain.notice.domain.repository | ||
|
||
import com.msg.gcms.domain.club.domain.entity.Club | ||
import com.msg.gcms.domain.notice.domain.entity.Notice | ||
import org.springframework.data.repository.CrudRepository | ||
|
||
interface NoticeRepository : CrudRepository<Notice, Long> | ||
interface NoticeRepository : CrudRepository<Notice, Long> { | ||
fun findByClub (club: Club): List<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
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/msg/gcms/domain/notice/presentation/data/response/NoticeListDto.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,14 @@ | ||
package com.msg.gcms.domain.notice.presentation.data.response | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class NoticeListDto( | ||
val notices: List<NoticeResponseDto> | ||
) { | ||
data class NoticeResponseDto( | ||
val id: Long, | ||
val title: String, | ||
val username: String, | ||
val createdAt: LocalDateTime | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
...ain/kotlin/com/msg/gcms/domain/notice/presentation/data/response/NoticeListResponseDto.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,5 @@ | ||
package com.msg.gcms.domain.notice.presentation.data.response | ||
|
||
data class NoticeListResponseDto( | ||
val notices: List<NoticeListDto.NoticeResponseDto> | ||
) |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/msg/gcms/domain/notice/service/NoticeListService.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.NoticeListDto | ||
|
||
interface NoticeListService { | ||
fun execute(clubId: Long): NoticeListDto | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/msg/gcms/domain/notice/service/impl/NoticeListServiceImpl.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,38 @@ | ||
package com.msg.gcms.domain.notice.service.impl | ||
|
||
import com.msg.gcms.domain.auth.domain.Role | ||
import com.msg.gcms.domain.club.domain.repository.ClubRepository | ||
import com.msg.gcms.domain.club.exception.ClubNotFoundException | ||
import com.msg.gcms.domain.club.exception.NotClubMemberException | ||
import com.msg.gcms.domain.notice.domain.repository.NoticeRepository | ||
import com.msg.gcms.domain.notice.presentation.data.response.NoticeListDto | ||
import com.msg.gcms.domain.notice.service.NoticeListService | ||
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 NoticeListServiceImpl( | ||
private val noticeRepository: NoticeRepository, | ||
private val clubRepository: ClubRepository, | ||
private val noticeConverter: NoticeConverter, | ||
private val userUtil: UserUtil | ||
) : NoticeListService { | ||
override fun execute(clubId: Long): NoticeListDto { | ||
val user = userUtil.fetchCurrentUser() | ||
val club = clubRepository.findByIdOrNull(clubId) | ||
?: throw ClubNotFoundException() | ||
|
||
if (user.roles[0] == Role.ROLE_STUDENT) { | ||
if (!user.club.contains(club)) { | ||
throw NotClubMemberException() | ||
} | ||
} | ||
|
||
val notices = noticeRepository.findByClub(club) | ||
.map { noticeConverter.toDto(it) } | ||
|
||
return noticeConverter.toListDto(notices) | ||
} | ||
} |
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