新增get(id: String)功能

This commit is contained in:
Raymond Yang 2023-05-23 14:19:16 +08:00
parent b811352620
commit de7171b72b
2 changed files with 23 additions and 20 deletions

View File

@ -287,17 +287,12 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"_id": "6465a6e2f5c86b7c50520486",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"name": "獅子影片",
"path": "/upload/1684383458922.mp4",
"contentType": "video/mp4",
"createAt": 1684383458939
},
"params": {
"availableRange": 20,
@ -336,17 +331,12 @@
},
"modelData": {
"material": {
"_id": "6464410c9c67517fcbccf447",
"_id": "6465a6e2f5c86b7c50520486",
"ownerId": "646435a39c67517fcbccf426",
"name": "奸笑的綿芽",
"path": "/upload/1684291852002.jpeg",
"contentType": "image/jpeg",
"fileTag": [
"圖片",
"Hololive"
],
"createAt": 1684291852023,
"updatedAt": 1684294290879
"name": "獅子影片",
"path": "/upload/1684383458922.mp4",
"contentType": "video/mp4",
"createAt": 1684383458939
},
"params": {
"availableRange": 20,

View File

@ -35,6 +35,19 @@ 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()