forked from Roflin/gamenight
Started on separating domain and adapters
This commit is contained in:
@@ -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())
|
||||
|
||||
21
backend-actix/src/schema/gamenight_participants.rs
Normal file
21
backend-actix/src/schema/gamenight_participants.rs
Normal 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)?)
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user