diff --git a/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt b/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt index 1837d37..81e774e 100644 --- a/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt +++ b/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt @@ -60,14 +60,6 @@ fun Application.configureArModelRouting() { } val body = call.receive() val id = call.parameters["id"].toString() - val model = modelService.findById(id) ?: run { - call.sendNotFound() - return@put - } - body.apply { - ownerId = model.ownerId - createAt = model.createAt - } val isSuccess = modelService.updateById(id, body) call.sendSuccess(mapOf("success" to isSuccess)) } diff --git a/src/main/kotlin/com/ray650128/service/ModelService.kt b/src/main/kotlin/com/ray650128/service/ModelService.kt index 65b9f4e..5b90222 100644 --- a/src/main/kotlin/com/ray650128/service/ModelService.kt +++ b/src/main/kotlin/com/ray650128/service/ModelService.kt @@ -16,8 +16,6 @@ class ModelService { return arModel._id } - fun findAll(): List = arModelCollection.find().toList() - fun findById(id: String): ArModel? { val bsonId: Id = ObjectId(id).toId() return arModelCollection.findOne(ArModel::_id eq bsonId) @@ -28,16 +26,17 @@ class ModelService { return arModelCollection.find(ArModel::ownerId eq bsonId).toList() } - fun findByName(name: String): List { - val caseSensitiveTypeSafeFilter = ArModel::name regex name - return arModelCollection.find(caseSensitiveTypeSafeFilter).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 ) )