-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Rooms #83
base: master
Are you sure you want to change the base?
Feature: Rooms #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
INSERT INTO rooms(id, name, active, deactivate_after_timestamp) | ||
VALUES | ||
(1, 'Enabled', true, NULL), | ||
(2, 'Inactive', false, NULL), | ||
(3, 'Deactivated by Timestamp', true, '2024-09-01'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod buy_request; | ||
pub mod news; | ||
pub mod products; | ||
pub mod rooms; | ||
pub mod users; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use axum::http::StatusCode; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_with::serde_as; | ||
use serde_with::DisplayFromStr; | ||
use thiserror::Error; | ||
|
||
use crate::responses::result_json::HttpStatusCode; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct RoomIdRequest { | ||
pub room_id: i32, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct RoomInfoResponse { | ||
pub room_id: i32, | ||
pub name: String, | ||
} | ||
|
||
#[serde_as] | ||
#[derive(Error, Debug, Serialize)] | ||
pub enum RoomInfoError { | ||
#[error("database error: {0}")] | ||
DbError( | ||
#[serde_as(as = "DisplayFromStr")] | ||
#[from] | ||
sqlx::Error, | ||
), | ||
|
||
#[error("invalid room id: {0}")] | ||
InvalidRoom(i32), | ||
} | ||
|
||
impl HttpStatusCode for RoomInfoError { | ||
fn status_code(&self) -> axum::http::StatusCode { | ||
match self { | ||
RoomInfoError::DbError(_) => StatusCode::INTERNAL_SERVER_ERROR, | ||
RoomInfoError::InvalidRoom(_) => StatusCode::BAD_REQUEST, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i64? in src/protocol/buy_request.rs it is a i32?