Skip to content

Commit

Permalink
refactor: (#733) list -> dto로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo committed Sep 13, 2024
1 parent 9e95ef6 commit e0fc400
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ data class AvailableVolunteerResponse(
}
}
}

data class AvailableVolunteersResponse(
val volunteers: List<AvailableVolunteerResponse>
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package team.aliens.dms.domain.volunteer.usecase
import team.aliens.dms.common.annotation.ReadOnlyUseCase
import team.aliens.dms.domain.student.service.StudentService
import team.aliens.dms.domain.volunteer.dto.response.AvailableVolunteerResponse
<<<<<<< Updated upstream
=======
import team.aliens.dms.domain.volunteer.dto.response.AvailableVolunteersResponse
import team.aliens.dms.domain.volunteer.dto.response.VolunteerResponse
>>>>>>> Stashed changes
import team.aliens.dms.domain.volunteer.service.VolunteerService

@ReadOnlyUseCase
Expand All @@ -11,20 +16,14 @@ class QueryAvailableVolunteersUseCase(
private val studentService: StudentService
) {

fun execute(): List<AvailableVolunteerResponse> {
fun execute(): AvailableVolunteersResponse {
val student = studentService.getCurrentStudent()

val availableVolunteers = volunteerService.getVolunteerByCondition(student.id)

return availableVolunteers.map { volunteer ->
AvailableVolunteerResponse(
id = volunteer.id,
name = volunteer.name,
content = volunteer.content,
score = volunteer.score,
optionalScore = volunteer.optionalScore,
maxApplicants = volunteer.maxApplicants
)
}
return AvailableVolunteersResponse(
availableVolunteers
.map { AvailableVolunteerResponse.of(it) }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class VolunteerWebAdapter(

@ResponseStatus(HttpStatus.OK)
@GetMapping
fun getAvailableVolunteers(): List<AvailableVolunteerResponse> {
fun getAvailableVolunteers(): AvailableVolunteersResponse {
return queryAvailableVolunteersUseCase.execute()
}

Expand Down

0 comments on commit e0fc400

Please sign in to comment.