From 7c68dc5ceb47ead5b7d320465b3fa0582d02fcd5 Mon Sep 17 00:00:00 2001 From: Raymond Yang Date: Thu, 18 May 2023 09:29:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=87mongoDB=E6=94=B9=E6=88=90=E9=9C=80?= =?UTF-8?q?=E7=99=BB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ray650128/service/MaterialService.kt | 3 +- .../com/ray650128/service/ModelService.kt | 31 +++++++++---------- .../com/ray650128/service/UserService.kt | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/ray650128/service/MaterialService.kt b/src/main/kotlin/com/ray650128/service/MaterialService.kt index 81a2e43..6b414c8 100644 --- a/src/main/kotlin/com/ray650128/service/MaterialService.kt +++ b/src/main/kotlin/com/ray650128/service/MaterialService.kt @@ -7,7 +7,7 @@ import org.litote.kmongo.* import org.litote.kmongo.id.toId class MaterialService { - private val client = KMongo.createClient("mongodb://www.ray650128.com:27017") + private val client = KMongo.createClient("mongodb://ray650128:Zx650128!@www.ray650128.com:27017") private val database = client.getDatabase("ar_system") private val materialCollection = database.getCollection() @@ -31,6 +31,7 @@ class MaterialService { val updateResult = materialCollection.replaceOne( material.copy( name = request.name, + fileTag = request.fileTag, updatedAt = request.updatedAt ) ) diff --git a/src/main/kotlin/com/ray650128/service/ModelService.kt b/src/main/kotlin/com/ray650128/service/ModelService.kt index 5b90222..94bc806 100644 --- a/src/main/kotlin/com/ray650128/service/ModelService.kt +++ b/src/main/kotlin/com/ray650128/service/ModelService.kt @@ -7,7 +7,7 @@ import org.litote.kmongo.* import org.litote.kmongo.id.toId class ModelService { - private val client = KMongo.createClient("mongodb://www.ray650128.com:27017") + private val client = KMongo.createClient("mongodb://ray650128:Zx650128!@www.ray650128.com:27017") private val database = client.getDatabase("ar_system") private val arModelCollection = database.getCollection() @@ -26,22 +26,21 @@ class ModelService { return arModelCollection.find(ArModel::ownerId eq bsonId).toList() } - fun updateById(id: String, request: ArModel): Boolean = - findById(id)?.let { arModel -> - val updateResult = arModelCollection.replaceOne( - arModel.copy( - name = request.name, - position = request.position, - rotation = request.rotation, - scale = request.scale, - modelData = request.modelData, - events = request.events, - childEvents = request.childEvents, - updatedAt = request.updatedAt - ) + fun updateById(id: String, request: ArModel): Boolean = findById(id)?.let { arModel -> + val updateResult = arModelCollection.replaceOne( + arModel.copy( + name = request.name, + position = request.position, + rotation = request.rotation, + scale = request.scale, + modelData = request.modelData, + events = request.events, + childEvents = request.childEvents, + updatedAt = request.updatedAt ) - updateResult.modifiedCount == 1L - } ?: false + ) + updateResult.modifiedCount == 1L + } ?: false fun deleteById(id: String): Boolean { val deleteResult = arModelCollection.deleteOneById(ObjectId(id)) diff --git a/src/main/kotlin/com/ray650128/service/UserService.kt b/src/main/kotlin/com/ray650128/service/UserService.kt index a725612..c682adf 100644 --- a/src/main/kotlin/com/ray650128/service/UserService.kt +++ b/src/main/kotlin/com/ray650128/service/UserService.kt @@ -6,7 +6,7 @@ import org.litote.kmongo.* import org.litote.kmongo.id.toId class UserService { - private val client = KMongo.createClient("mongodb://www.ray650128.com:27017") + private val client = KMongo.createClient("mongodb://ray650128:Zx650128!@www.ray650128.com:27017") private val database = client.getDatabase("ar_system") private val userCollection = database.getCollection()