Skip to content

Commit

Permalink
add imageURL to dto (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeryboy authored Feb 27, 2025
1 parent d427fd1 commit 3fb9ad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data class ReportDto(
val id: Long,
val title: String,
val description: String,
val imageURL: String?,
val sequence: Int,
val name: String,
val createdAt: LocalDateTime,
Expand All @@ -17,14 +18,15 @@ data class ReportDto(
val nextTitle: String?
) {
companion object {
fun of(entity: CouncilEntity, prev: CouncilEntity?, next: CouncilEntity?): ReportDto {
fun of(entity: CouncilEntity, prev: CouncilEntity?, next: CouncilEntity?, imageURL: String?): ReportDto {
require(entity.type == CouncilType.REPORT) {
"CouncilEntity must be of type REPORT, but was ${entity.type}"
}
return ReportDto(
id = entity.id,
title = entity.title,
description = entity.description,
imageURL = imageURL,
sequence = entity.sequence,
name = entity.name,
createdAt = entity.createdAt!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CouncilService(
.firstOrNull()
val nextReport =
councilRepository.findNextByType(report.createdAt!!, CouncilType.REPORT, PageRequest.of(0, 1)).firstOrNull()
return ReportDto.of(report, prevReport, nextReport)
return ReportDto.of(report, prevReport, nextReport, mainImageService.createImageURL(report.mainImage))
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 3fb9ad5

Please sign in to comment.