Started on separating domain and adapters

This commit is contained in:
2025-05-14 07:41:28 +02:00
parent 4e26d3cdcb
commit c994321576
15 changed files with 541 additions and 702 deletions

View File

@@ -53,6 +53,7 @@ pub async fn gamenight_get(pool: web::Data<DbPool>, _user: User, gamenight_data:
let mut conn = pool.get_conn();
let gamenight = schema::gamenight::get_gamenight(&mut conn, gamenight_data.into_inner().into())?;
//let participants = schema::user::get_participants(&mut conn, gamenight_id);
Ok(HttpResponse::Ok()
.content_type(ContentType::json())

View File

@@ -0,0 +1,21 @@
use diesel::{ExpressionMethods, Insertable, PgConnection, QueryDsl, Queryable, RunQueryDsl};
use serde::{Serialize, Deserialize};
use uuid::Uuid;
use crate::schema::schema::gamenight_participants;
use super::error::DatabaseError;
#[derive(Serialize, Deserialize, Debug, Insertable, Queryable)]
#[diesel(belongs_to(Gamenight))]
#[diesel(belongs_to(User))]
#[diesel(table_name = gamenight_participants)]
pub struct GamenightParticipants {
pub gamenight_id: Uuid,
pub user_id: Uuid,
}
pub fn gamenight_participants(conn: &mut PgConnection, id: Uuid) -> Result<Vec<GamenightParticipants>, DatabaseError> {
Ok(gamenight_participants::table
.filter(gamenight_participants::gamenight_id.eq(id))
.get_results(conn)?)
}

View File

@@ -2,7 +2,9 @@ pub mod user;
pub mod error;
pub mod schema;
pub mod gamenight;
pub mod gamenight_participants;
pub use user::login;
pub use user::register;
pub use gamenight::gamenights;
pub use gamenight_participants::gamenight_participants;