guestDocument: split codes
Some checks failed
build-and-deploy / build-deploy (push) Failing after 30s
Some checks failed
build-and-deploy / build-deploy (push) Failing after 30s
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.android.trisolarisserver.component
|
||||
|
||||
import com.android.trisolarisserver.controller.GuestDocumentResponse
|
||||
import com.android.trisolarisserver.controller.toResponse
|
||||
import com.android.trisolarisserver.db.repo.GuestDocumentRepo
|
||||
import com.android.trisolarisserver.models.booking.GuestDocument
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Component
|
||||
@@ -79,30 +79,3 @@ private data class GuestDocKey(
|
||||
val propertyId: UUID,
|
||||
val guestId: UUID
|
||||
)
|
||||
|
||||
private fun GuestDocument.toResponse(objectMapper: ObjectMapper): GuestDocumentResponse {
|
||||
val id = id ?: throw IllegalStateException("Document id missing")
|
||||
val extracted: Map<String, String>? = extractedData?.let {
|
||||
try {
|
||||
val raw = objectMapper.readValue(it, Map::class.java)
|
||||
raw.entries.associate { entry ->
|
||||
entry.key.toString() to (entry.value?.toString() ?: "")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
return GuestDocumentResponse(
|
||||
id = id,
|
||||
propertyId = property.id!!,
|
||||
guestId = guest.id!!,
|
||||
bookingId = booking.id!!,
|
||||
uploadedByUserId = uploadedBy.id!!,
|
||||
uploadedAt = uploadedAt.toString(),
|
||||
originalFilename = originalFilename,
|
||||
contentType = contentType,
|
||||
sizeBytes = sizeBytes,
|
||||
extractedData = extracted,
|
||||
extractedAt = extractedAt?.toString()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user