將mongoDB改成需登入
This commit is contained in:
parent
a2acb7b928
commit
7c68dc5ceb
@ -7,7 +7,7 @@ import org.litote.kmongo.*
|
|||||||
import org.litote.kmongo.id.toId
|
import org.litote.kmongo.id.toId
|
||||||
|
|
||||||
class MaterialService {
|
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 database = client.getDatabase("ar_system")
|
||||||
private val materialCollection = database.getCollection<Material>()
|
private val materialCollection = database.getCollection<Material>()
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ class MaterialService {
|
|||||||
val updateResult = materialCollection.replaceOne(
|
val updateResult = materialCollection.replaceOne(
|
||||||
material.copy(
|
material.copy(
|
||||||
name = request.name,
|
name = request.name,
|
||||||
|
fileTag = request.fileTag,
|
||||||
updatedAt = request.updatedAt
|
updatedAt = request.updatedAt
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import org.litote.kmongo.*
|
|||||||
import org.litote.kmongo.id.toId
|
import org.litote.kmongo.id.toId
|
||||||
|
|
||||||
class ModelService {
|
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 database = client.getDatabase("ar_system")
|
||||||
private val arModelCollection = database.getCollection<ArModel>()
|
private val arModelCollection = database.getCollection<ArModel>()
|
||||||
|
|
||||||
@ -26,22 +26,21 @@ class ModelService {
|
|||||||
return arModelCollection.find(ArModel::ownerId eq bsonId).toList()
|
return arModelCollection.find(ArModel::ownerId eq bsonId).toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateById(id: String, request: ArModel): Boolean =
|
fun updateById(id: String, request: ArModel): Boolean = findById(id)?.let { arModel ->
|
||||||
findById(id)?.let { arModel ->
|
val updateResult = arModelCollection.replaceOne(
|
||||||
val updateResult = arModelCollection.replaceOne(
|
arModel.copy(
|
||||||
arModel.copy(
|
name = request.name,
|
||||||
name = request.name,
|
position = request.position,
|
||||||
position = request.position,
|
rotation = request.rotation,
|
||||||
rotation = request.rotation,
|
scale = request.scale,
|
||||||
scale = request.scale,
|
modelData = request.modelData,
|
||||||
modelData = request.modelData,
|
events = request.events,
|
||||||
events = request.events,
|
childEvents = request.childEvents,
|
||||||
childEvents = request.childEvents,
|
updatedAt = request.updatedAt
|
||||||
updatedAt = request.updatedAt
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
updateResult.modifiedCount == 1L
|
)
|
||||||
} ?: false
|
updateResult.modifiedCount == 1L
|
||||||
|
} ?: false
|
||||||
|
|
||||||
fun deleteById(id: String): Boolean {
|
fun deleteById(id: String): Boolean {
|
||||||
val deleteResult = arModelCollection.deleteOneById(ObjectId(id))
|
val deleteResult = arModelCollection.deleteOneById(ObjectId(id))
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import org.litote.kmongo.*
|
|||||||
import org.litote.kmongo.id.toId
|
import org.litote.kmongo.id.toId
|
||||||
|
|
||||||
class UserService {
|
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 database = client.getDatabase("ar_system")
|
||||||
private val userCollection = database.getCollection<User>()
|
private val userCollection = database.getCollection<User>()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user