Rewrite to a API trait.
This commit is contained in:
16
backend-actix/Cargo.lock
generated
16
backend-actix/Cargo.lock
generated
@@ -1243,9 +1243,9 @@ checksum = "e8a5a9a0ff0086c7a148acb942baaabeadf9504d10400b5a05645853729b9cd2"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.12.1"
|
||||
version = "2.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
|
||||
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@@ -2175,9 +2175,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.113"
|
||||
version = "2.0.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "678faa00651c9eb72dd2020cbdf275d92eccb2400d568e419efdd64838145cb4"
|
||||
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2781,18 +2781,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.31"
|
||||
version = "0.8.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3"
|
||||
checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.31"
|
||||
version = "0.8.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a"
|
||||
checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -337,6 +337,8 @@ components:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
location_id:
|
||||
type: string
|
||||
datetime:
|
||||
type: string
|
||||
owner_id:
|
||||
@@ -408,6 +410,16 @@ components:
|
||||
type: string
|
||||
required:
|
||||
- user_id
|
||||
OwnedGame:
|
||||
title: OwnedGame
|
||||
type: object
|
||||
properties:
|
||||
game_id:
|
||||
type: string
|
||||
location_id:
|
||||
type: string
|
||||
required:
|
||||
- game_id
|
||||
LocationId:
|
||||
title: LocationId
|
||||
type: object
|
||||
@@ -499,7 +511,7 @@ components:
|
||||
GameIdsResponse:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/OwnedGame"
|
||||
UserIdsResponse:
|
||||
type: array
|
||||
items:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use gamenight_database::owned_game::OwnedGame;
|
||||
use crate::game::rename_game;
|
||||
use crate::owned_game::own_game;
|
||||
use crate::owned_game::owned_games;
|
||||
use crate::owned_game::disown_game;
|
||||
use crate::owned_game::OwnedGame;
|
||||
use gamenight_database::game::load_game;
|
||||
use crate::game::insert_game;
|
||||
use uuid::Uuid;
|
||||
@@ -13,13 +13,10 @@ use gamenight_database::{
|
||||
DbPool, GetConnection,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
models::{
|
||||
add_game_request_body::AddGameRequestBody, game::Game, game_id::GameId,
|
||||
rename_game_request_body::RenameGameRequestBody, own_game_request_body::OwnGameRequestBody
|
||||
},
|
||||
request::{authorization::AuthUser, error::ApiError},
|
||||
};
|
||||
use crate::{models, models::{
|
||||
add_game_request_body::AddGameRequestBody, game::Game, game_id::GameId,
|
||||
rename_game_request_body::RenameGameRequestBody, own_game_request_body::OwnGameRequestBody
|
||||
}, request::{authorization::AuthUser, error::ApiError}};
|
||||
|
||||
#[get("/games")]
|
||||
pub async fn get_games(
|
||||
@@ -162,7 +159,11 @@ pub async fn get_owned_games(
|
||||
let mut conn = pool.get_conn();
|
||||
let game_ids = owned_games(&mut conn, user.0.id)?;
|
||||
|
||||
let model: Vec<String> = game_ids.iter().map(|x| x.to_string()).collect();
|
||||
|
||||
let model = game_ids.iter().map(|(u, l)| models::owned_game::OwnedGame {
|
||||
game_id: u.to_string(),
|
||||
location_id: l.map(|x| x.to_string())
|
||||
}).collect::<Vec<models::owned_game::OwnedGame>>();
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
|
||||
@@ -43,6 +43,7 @@ pub async fn gamenights(
|
||||
.map(|x| Gamenight {
|
||||
id: x.id.to_string(),
|
||||
name: x.name.clone(),
|
||||
location_id: x.location_id.map(|x| x.to_string()),
|
||||
datetime: x.datetime.to_rfc3339(),
|
||||
owner_id: x.owner_id.to_string(),
|
||||
})
|
||||
@@ -77,6 +78,7 @@ pub async fn gamenight_get(
|
||||
let model = Gamenight {
|
||||
id: gamenight.id.to_string(),
|
||||
datetime: gamenight.datetime.to_rfc3339(),
|
||||
location_id: gamenight.location_id.map(|x| x.to_string()),
|
||||
name: gamenight.name,
|
||||
owner_id: gamenight.owner_id.to_string(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user