Deduplicate logic across controllers, auth, and schema fixes
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -8,7 +8,6 @@ import org.apache.pdfbox.pdmodel.font.PDType1Font
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Component
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
@@ -112,12 +111,4 @@ class EmailStorage(
|
||||
atomicMove(tmp, path)
|
||||
return path.toString()
|
||||
}
|
||||
|
||||
private fun atomicMove(tmp: Path, target: Path) {
|
||||
try {
|
||||
Files.move(tmp, target, java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
} catch (_: Exception) {
|
||||
Files.move(tmp, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.android.trisolarisserver.component
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
|
||||
internal fun atomicMove(tmp: Path, target: Path) {
|
||||
try {
|
||||
Files.move(
|
||||
tmp,
|
||||
target,
|
||||
java.nio.file.StandardCopyOption.ATOMIC_MOVE,
|
||||
java.nio.file.StandardCopyOption.REPLACE_EXISTING
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
Files.move(tmp, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
@@ -38,13 +38,7 @@ class LlamaClient(
|
||||
)
|
||||
)
|
||||
)
|
||||
val headers = HttpHeaders()
|
||||
headers.contentType = MediaType.APPLICATION_JSON
|
||||
val entity = HttpEntity(payload, headers)
|
||||
val response = restTemplate.postForEntity(baseUrl, entity, String::class.java)
|
||||
val body = response.body ?: return ""
|
||||
val node = objectMapper.readTree(body)
|
||||
return node.path("choices").path(0).path("message").path("content").asText()
|
||||
return post(payload)
|
||||
}
|
||||
|
||||
fun askText(content: String, question: String): String {
|
||||
@@ -61,6 +55,10 @@ class LlamaClient(
|
||||
)
|
||||
)
|
||||
)
|
||||
return post(payload)
|
||||
}
|
||||
|
||||
private fun post(payload: Map<String, Any>): String {
|
||||
val headers = HttpHeaders()
|
||||
headers.contentType = MediaType.APPLICATION_JSON
|
||||
val entity = HttpEntity(payload, headers)
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.springframework.web.multipart.MultipartFile
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
@@ -102,13 +101,6 @@ class RoomImageStorage(
|
||||
}
|
||||
}
|
||||
|
||||
private fun atomicMove(tmp: Path, target: Path) {
|
||||
try {
|
||||
Files.move(tmp, target, java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
} catch (_: Exception) {
|
||||
Files.move(tmp, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class StoredRoomImage(
|
||||
|
||||
Reference in New Issue
Block a user