-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/user-query-event-schedule
- Loading branch information
Showing
9 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
.../com/kodomo/juganbbojjak/domain/work_report/dto/reponse/QueryWorkReportDetailsResponse.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.kodomo.juganbbojjak.domain.work_report.dto.reponse | ||
|
||
import com.kodomo.juganbbojjak.domain.work_report.model.WorkDetailType | ||
|
||
data class QueryWorkReportDetailsResponse( | ||
val title: String, | ||
val workReportList: List<WorkReportListResponse> | ||
) | ||
|
||
data class WorkReportListResponse( | ||
val contentKey: String, | ||
val contentValue: String, | ||
val contentType: WorkDetailType | ||
) |
9 changes: 7 additions & 2 deletions
9
...lication/src/main/kotlin/com/kodomo/juganbbojjak/domain/work_report/spi/WorkDetailPort.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,9 +1,14 @@ | ||
package com.kodomo.juganbbojjak.domain.work_report.spi | ||
|
||
import com.kodomo.juganbbojjak.domain.work_report.model.WorkDetail | ||
import java.util.UUID | ||
|
||
interface WorkDetailPort : CommandWorkDetail | ||
interface WorkDetailPort : CommandWorkDetailPort, QueryWorkDetailPort | ||
|
||
interface CommandWorkDetail{ | ||
interface CommandWorkDetailPort{ | ||
fun saveAllWorkDetails(workDetails: List<WorkDetail>) | ||
} | ||
|
||
interface QueryWorkDetailPort{ | ||
fun queryWorkDetailByWorkReportId(workReportId: UUID): List<WorkDetail> | ||
} |
7 changes: 6 additions & 1 deletion
7
...lication/src/main/kotlin/com/kodomo/juganbbojjak/domain/work_report/spi/WorkReportPort.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,9 +1,14 @@ | ||
package com.kodomo.juganbbojjak.domain.work_report.spi | ||
|
||
import com.kodomo.juganbbojjak.domain.work_report.model.WorkReport | ||
import java.util.UUID | ||
|
||
interface WorkReportPort : CommandWorkReport | ||
interface WorkReportPort : CommandWorkReport, QueryWorkReport | ||
|
||
interface CommandWorkReport { | ||
fun saveWorkReport(workReport: WorkReport): WorkReport | ||
} | ||
|
||
interface QueryWorkReport { | ||
fun queryWorkReportByWeeklyWorkReportId(weeklyWorkReportId: UUID, userId: UUID?): WorkReport? | ||
} |
46 changes: 46 additions & 0 deletions
46
...otlin/com/kodomo/juganbbojjak/domain/work_report/usecase/QueryWorkReportDetailsUseCase.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,46 @@ | ||
package com.kodomo.juganbbojjak.domain.work_report.usecase | ||
|
||
import com.kodomo.juganbbojjak.common.annotation.UseCase | ||
import com.kodomo.juganbbojjak.common.spi.SecurityPort | ||
import com.kodomo.juganbbojjak.domain.user.exception.UserNotFoundException | ||
import com.kodomo.juganbbojjak.domain.user.model.Authority | ||
import com.kodomo.juganbbojjak.domain.user.spi.QueryUserPort | ||
import com.kodomo.juganbbojjak.domain.work_report.dto.reponse.QueryWorkReportDetailsResponse | ||
import com.kodomo.juganbbojjak.domain.work_report.dto.reponse.WorkReportListResponse | ||
import com.kodomo.juganbbojjak.domain.work_report.exception.WorkReportNotFoundException | ||
import com.kodomo.juganbbojjak.domain.work_report.spi.WorkDetailPort | ||
import com.kodomo.juganbbojjak.domain.work_report.spi.WorkReportPort | ||
import java.util.UUID | ||
|
||
@UseCase | ||
class QueryWorkReportDetailsUseCase( | ||
private val workReportPort: WorkReportPort, | ||
private val workDetailPort: WorkDetailPort, | ||
private val securityPort: SecurityPort, | ||
private val queryUserPort: QueryUserPort | ||
) { | ||
|
||
fun execute(weeklyWorkReportId: UUID): QueryWorkReportDetailsResponse { | ||
|
||
val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) | ||
?: throw UserNotFoundException | ||
|
||
val workReport = when (user.authority) { | ||
Authority.ADMIN -> workReportPort.queryWorkReportByWeeklyWorkReportId(weeklyWorkReportId, null) | ||
Authority.USER -> workReportPort.queryWorkReportByWeeklyWorkReportId(weeklyWorkReportId, user.id) | ||
} ?: throw WorkReportNotFoundException | ||
|
||
val workDetail = workDetailPort.queryWorkDetailByWorkReportId(workReport.id) | ||
|
||
return QueryWorkReportDetailsResponse( | ||
title = workReport.title, | ||
workReportList = workDetail.map { | ||
WorkReportListResponse( | ||
contentKey = it.title, | ||
contentValue = it.content, | ||
contentType = it.type | ||
) | ||
} | ||
) | ||
} | ||
} |
17 changes: 16 additions & 1 deletion
17
...in/com/kodomo/juganbbojjak/domain/work_report/persistence/WorkDetailPersistenceAdapter.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,20 +1,35 @@ | ||
package com.kodomo.juganbbojjak.domain.work_report.persistence | ||
|
||
import com.kodomo.juganbbojjak.domain.work_report.model.WorkDetail | ||
import com.kodomo.juganbbojjak.domain.work_report.persistence.entity.QWorkDetailEntity.workDetailEntity | ||
import com.kodomo.juganbbojjak.domain.work_report.persistence.entity.QWorkReportEntity.workReportEntity | ||
import com.kodomo.juganbbojjak.domain.work_report.persistence.mapper.WorkDetailMapper | ||
import com.kodomo.juganbbojjak.domain.work_report.persistence.repository.WorkDetailRepository | ||
import com.kodomo.juganbbojjak.domain.work_report.spi.WorkDetailPort | ||
import com.kodomo.juganbbojjak.global.annotation.Adapter | ||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import java.util.* | ||
|
||
@Adapter | ||
class WorkDetailPersistenceAdapter( | ||
private val workDetailRepository: WorkDetailRepository, | ||
private val workDetailMapper: WorkDetailMapper | ||
private val workDetailMapper: WorkDetailMapper, | ||
private val queryFactory: JPAQueryFactory | ||
) : WorkDetailPort { | ||
|
||
override fun saveAllWorkDetails(workDetails: List<WorkDetail>) { | ||
workDetailRepository.saveAll( | ||
workDetails.map { workDetailMapper.toEntity(it) } | ||
) | ||
} | ||
|
||
override fun queryWorkDetailByWorkReportId(workReportId: UUID): List<WorkDetail> { | ||
return queryFactory | ||
.selectFrom(workDetailEntity) | ||
.join(workReportEntity) | ||
.on(workDetailEntity.workReportEntity.id.eq(workReportEntity.id)) | ||
.where(workDetailEntity.workReportEntity.id.eq(workReportId)) | ||
.fetch() | ||
.map { workDetailMapper.toDomain(it) } | ||
} | ||
} |
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
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