Skip to content

Commit bd24ac0

Browse files
authored
Merge pull request #352 from depromeet/develop
2 parents 53b3955 + 0dfb22f commit bd24ac0

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package core.application.session.application.exception
2+
3+
import core.application.common.exception.BusinessException
4+
5+
class CohortSessionNotFoundException(
6+
code: SessionExceptionCode = SessionExceptionCode.COHORT_SESSION_NOT_FOUND,
7+
) : BusinessException(code)

application/src/main/kotlin/core/application/session/application/exception/SessionExceptionCode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum class SessionExceptionCode(
1414
ALREADY_CHECKED_ATTENDANCE(HttpStatus.BAD_REQUEST, "SESSION-400-04", "이미 출석을 체크했습니다"),
1515
ATTENDANCE_START_TIME_DATE_MISMATCH(HttpStatus.BAD_REQUEST, "SESSION-400-05", "출석 시작 시간의 날짜가 세션의 날짜와 일치하지 않습니다"),
1616
SESSION_NOT_FOUND(HttpStatus.NOT_FOUND, "SESSION-404-01", "세션을 찾을 수 없습니다"),
17+
COHORT_SESSION_NOT_FOUND(HttpStatus.NOT_FOUND, "SESSION-404-02", "해당 기수의 세션을 찾을 수 없습니다"),
1718
;
1819

1920
override fun getStatus(): HttpStatus = status

application/src/main/kotlin/core/application/session/application/service/SessionQueryService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class SessionQueryService(
3939
return sessionPersistencePort.findNextSessionBy(startOfToday)
4040
}
4141

42-
fun getAllSessions(): List<Session> {
42+
fun getAllCohortSessions(): List<Session> {
4343
val cohortId = cohortQueryUseCase.getLatestCohortId()
4444

45-
return sessionPersistencePort.findAllSessions(cohortId.value)
45+
return sessionPersistencePort.findAllCohortSessions(cohortId.value)
4646
}
4747

4848
fun getSessionById(sessionId: SessionId): Session =
@@ -60,7 +60,7 @@ class SessionQueryService(
6060
val cohortId = cohortQueryUseCase.getLatestCohortId()
6161

6262
return sessionPersistencePort
63-
.findAllSessions(cohortId.value)
63+
.findAllCohortSessions(cohortId.value)
6464
.map { SessionWeekQueryModel(sessionId = it.id!!, week = it.week, date = it.date) }
6565
}
6666

application/src/main/kotlin/core/application/session/presentation/controller/SessionQueryController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SessionQueryController(
3939
override fun getAllSessions(): CustomResponse<SessionListResponse> {
4040
val response =
4141
sessionQueryService
42-
.getAllSessions()
42+
.getAllCohortSessions()
4343
.let { SessionMapper.toSessionListResponse(it) }
4444

4545
return CustomResponse.ok(response)

domain/src/main/kotlin/core/domain/session/port/outbound/SessionPersistencePort.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.time.Instant
66
interface SessionPersistencePort {
77
fun findNextSessionBy(startOfToday: Instant): Session?
88

9-
fun findAllSessions(cohortId: Long): List<Session>
9+
fun findAllCohortSessions(cohortId: Long): List<Session>
1010

1111
fun findSessionById(sessionId: Long): Session?
1212

persistence/src/main/kotlin/core/persistence/cohort/repository/CohortJpaRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import core.entity.cohort.CohortEntity
44
import org.springframework.data.jpa.repository.JpaRepository
55

66
interface CohortJpaRepository : JpaRepository<CohortEntity, Long> {
7-
fun findByValue(value: String): CohortEntity
7+
fun findByValue(value: String): CohortEntity?
88
}

persistence/src/main/kotlin/core/persistence/cohort/repository/CohortRepository.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ import org.springframework.stereotype.Repository
88
class CohortRepository(
99
private val cohortJpaRepository: CohortJpaRepository,
1010
) : CohortPersistencePort {
11-
override fun findByValue(value: String): Cohort? {
12-
return cohortJpaRepository.findByValue(value).toDomain()
13-
}
11+
override fun findByValue(value: String): Cohort? = cohortJpaRepository.findByValue(value)?.toDomain()
1412
}

persistence/src/main/kotlin/core/persistence/session/repository/SessionRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SessionRepository(
1515
override fun findNextSessionBy(startOfToday: Instant): Session? =
1616
sessionJpaRepository.findFirstByDateAfterAndDeletedAtIsNullOrderByDateAsc(startOfToday)?.toDomain()
1717

18-
override fun findAllSessions(cohortId: Long): List<Session> =
18+
override fun findAllCohortSessions(cohortId: Long): List<Session> =
1919
sessionJpaRepository.findAllByCohortIdAndDeletedAtIsNullOrderByIdAsc(cohortId).map { it.toDomain() }
2020

2121
override fun findSessionById(sessionId: Long): Session? =

0 commit comments

Comments
 (0)