Compare commits

..

No commits in common. "de7171b72b19459eafd4e8d26a794482e3bf64c1" and "2b18af2b2d3e480ab095dad1d9ee7a9e0134ca83" have entirely different histories.

5 changed files with 74 additions and 166 deletions

View File

@ -20,17 +20,9 @@
"modelData": {
"type": 0,
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"id": "d6350683.jpg",
"textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg"
},
"params": {
"width": 1,
@ -108,17 +100,9 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"id": "d6350683.jpg",
"textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg"
},
"params": {
"width": 0.75,
@ -149,17 +133,9 @@
"modelData": {
"type": 2,
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"id": "d6350683.jpg",
"textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg"
},
"params": {
"availableRange": 20,
@ -192,17 +168,9 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"id": "d6350683.jpg",
"textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg"
},
"params": {
"availableRange": 20,
@ -237,17 +205,9 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"contentType": "model/gltf-binary",
"id": "spiderbot.glb",
"textureUrl": "https://www.ray650128.com/spiderbot.glb"
},
"params": {
"availableRange": 20,
@ -287,12 +247,9 @@
},
"modelData": {
"material": {
"_id": "6465a6e2f5c86b7c50520486",
"ownerId": "646435a39c67517fcbccf426",
"name": "獅子影片",
"path": "/upload/1684383458922.mp4",
"contentType": "video/mp4",
"createAt": 1684383458939
"contentType": "video/mpeg4",
"id": "ker1.mp4",
"textureUrl": "https://www.ray650128.com/video/ker1.mp4"
},
"params": {
"availableRange": 20,
@ -331,12 +288,9 @@
},
"modelData": {
"material": {
"_id": "6465a6e2f5c86b7c50520486",
"ownerId": "646435a39c67517fcbccf426",
"name": "獅子影片",
"path": "/upload/1684383458922.mp4",
"contentType": "video/mp4",
"createAt": 1684383458939
"contentType": "video/mpeg4",
"id": "ker2.mp4",
"textureUrl": "https://www.ray650128.com/video/ker2.mp4"
},
"params": {
"availableRange": 20,
@ -372,17 +326,9 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"contentType": "video/mpeg4",
"id": "hou1.mp4",
"textureUrl": "https://www.ray650128.com/video/hou1.mp4"
},
"params": {
"availableRange": 20,
@ -432,10 +378,10 @@
},
{
"id": 9,
"name": "MultiplePlane",
"name": "MultiFace",
"position": {
"x": 1,
"y": -1,
"x": 0,
"y": 1,
"z": 0
},
"rotation": {
@ -449,59 +395,56 @@
"z": 1
},
"modelData": {
"materials": [
{
"_id": "6464410c9c67517fcbccf447",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
},
{
"_id": "646590294df2e46df0f7a51b",
"ownerId": "646435a39c67517fcbccf426",
"name": "供三小",
"path": "/upload/1684377641965.jpeg",
"contentType": "image/jpeg",
"createAt": 1684377641977
},
{
"_id": "646590674df2e46df0f7a524",
"ownerId": "646435a39c67517fcbccf426",
"name": "解散囉",
"path": "/upload/1684377703013.png",
"contentType": "image/png",
"createAt": 1684377703020
},
{
"_id": "646590e04df2e46df0f7a52f",
"ownerId": "646435a39c67517fcbccf426",
"name": "QRCode",
"path": "/upload/1684377824564.png",
"contentType": "image/png",
"createAt": 1684377824573
},
{
"_id": "646593304df2e46df0f7a54b",
"ownerId": "646435a39c67517fcbccf426",
"name": "煙霧",
"path": "/upload/1684378416412.png",
"contentType": "image/png",
"createAt": 1684378416417
}
],
"material": {
"contentTypes": [
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg",
"image/jpeg"
],
"textureUrls": [
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg",
"https://cdn2.ettoday.net/images/6350/d6350683.jpg"
]
},
"params": {
"levelAngles": [ 0 ],
"levelBorders": [ 0 ],
"levelCount": 1,
"levelAngles": [
45,
0,
-45
],
"levelBorders": [
0.1,
0.1,
0.1
],
"levelCount": 3,
"planeBorder": 0.1,
"planeCount": 4,
"planeCount": 5,
"speed": 1
},
"type": 6

View File

@ -1,28 +1,14 @@
package com.ray650128.extension
import com.ray650128.model.pojo.Material
import com.ray650128.model.pojo.arModel.ModelData
import com.ray650128.model.pojo.arModelDto.ModelDataDto
import com.ray650128.service.MaterialService
import org.litote.kmongo.Id
fun ModelData.toDto(): ModelDataDto {
val service = MaterialService()
return ModelDataDto(
type = this.type,
material = if (this.material != null) {
service.findById(this.material.toString())
} else null,
materials = if (this.materials != null) {
ArrayList<Material>().apply {
materials?.forEach { id ->
val material = service.findById(id.toString())
if (material != null) {
add(material)
}
}
}
} else null,
material = service.findById(this.material.toString()),
params = this.params
)
}
@ -32,10 +18,5 @@ fun ModelDataDto.toModelData(): ModelData =
ModelData(
type = this.type,
material = this.material?._id,
materials = ArrayList<Id<Material>>().apply {
materials?.forEach { material ->
add(material._id)
}
},
params = this.params
)

View File

@ -9,6 +9,5 @@ import org.litote.kmongo.Id
data class ModelData(
var type: Int = -1,
@Contextual var material: Id<Material>? = null,
@Contextual var materials: List<Id<Material>>? = null,
var params: ModelParams
)

View File

@ -10,6 +10,5 @@ import org.litote.kmongo.Id
data class ModelDataDto(
var type: Int = -1,
var material: Material? = null,
var materials: List<Material>? = null,
var params: ModelParams
)

View File

@ -4,7 +4,6 @@ import com.ray650128.extension.*
import com.ray650128.model.ErrorResponse
import com.ray650128.model.pojo.arModel.ArModel
import com.ray650128.model.pojo.User
import com.ray650128.model.pojo.arModelDto.ArModelDto
import com.ray650128.service.ModelService
import com.ray650128.service.UserService
import io.ktor.server.application.*
@ -35,25 +34,12 @@ fun Application.configureArModelRouting() {
call.sendSuccess(list)
}
get("/{id}") {
call.authentication.principal<User>()?.account ?: run {
call.sendUnauthorized()
return@get
}
val id = call.parameters["id"].toString()
val arModel = modelService.findById(id) ?: run {
call.sendNotFound()
return@get
}
call.sendSuccess(arModel.toDto())
}
post("/create") {
val user = call.authentication.principal<User>() ?: run {
call.sendUnauthorized()
return@post
}
val body = call.receive<ArModelDto>().toArModel()
val body = call.receive<ArModel>()
body.apply {
ownerId = user._id
createAt = System.currentTimeMillis()
@ -72,7 +58,7 @@ fun Application.configureArModelRouting() {
call.sendUnauthorized()
return@put
}
val body = call.receive<ArModelDto>().toArModel()
val body = call.receive<ArModel>()
val id = call.parameters["id"].toString()
val isSuccess = modelService.updateById(id, body)
call.sendSuccess(mapOf("success" to isSuccess))