diff --git a/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/CompaniesController.kt b/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/CompaniesController.kt index 1062446..0be5123 100644 --- a/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/CompaniesController.kt +++ b/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/CompaniesController.kt @@ -7,17 +7,17 @@ import com.threedays.oas.model.SearchCompaniesResponse import com.threedays.support.common.base.domain.UUIDTypeId import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.RestController -import java.util.* +import java.util.UUID @RestController -class CompaniesController ( - private val companyQueryRepository: CompanyQueryRepository -): CompaniesApi { +class CompaniesController( + private val companyQueryRepository: CompanyQueryRepository, +) : CompaniesApi { override fun searchCompanies( name: String, next: UUID?, - limit: Int + limit: Int, ): ResponseEntity { val (resultCompanies, resultNext) = companyQueryRepository.searchCompanies( name = name, @@ -25,19 +25,22 @@ class CompaniesController ( limit = limit ) - val companyResponse = resultCompanies.map { + return ResponseEntity.ok(createSearchCompaniesResponse(resultCompanies, resultNext)) + } + + private fun createSearchCompaniesResponse( + companies: List, + nextID: com.threedays.domain.user.entity.Company.Id?, + ): SearchCompaniesResponse { + val companyResponse = companies.map { Company( id = it.id.value, name = it.name ) } - - return ResponseEntity.ok( - SearchCompaniesResponse( - companies = companyResponse, - next = resultNext?.value - ) + return SearchCompaniesResponse( + companies = companyResponse, + next = nextID?.value ) } - }