Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94aea7ca27 | ||
|
|
bc0d3cb589 | ||
|
|
9972863232 |
+4
-2
@@ -3,13 +3,15 @@
|
|||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
debug/
|
debug/
|
||||||
target/
|
target/
|
||||||
|
data/
|
||||||
|
backend/debug/
|
||||||
|
backend/target/
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
.env
|
||||||
# RustRover
|
# RustRover
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
|||||||
Generated
+2399
File diff suppressed because it is too large
Load Diff
+4
-1
@@ -6,5 +6,8 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.8.9"
|
axum = "0.8.9"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
|
serde_json = "1.0.149"
|
||||||
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-native-tls"] }
|
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-native-tls"] }
|
||||||
tokio = { version = "1.52.1", features = ["tr-multi-thread", "macros"] }
|
tokio = { version = "1.52.1", features = ["rt-multi-thread", "macros"] }
|
||||||
|
dotenv = "0.15.0"
|
||||||
|
chrono = { version = "0.4.44", features = ["serde"] }
|
||||||
|
|||||||
+29
-2
@@ -1,3 +1,30 @@
|
|||||||
fn main() {
|
mod models;
|
||||||
println!("Hello, world!");
|
use axum::{Router, routing};
|
||||||
|
use dotenv::dotenv;
|
||||||
|
use models::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sqlx::{PgPool, postgres::PgPoolOptions};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
dotenv().ok();
|
||||||
|
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL variable not set");
|
||||||
|
let pool = match PgPoolOptions::new().connect(&database_url).await {
|
||||||
|
Ok(pool) => {
|
||||||
|
println!("Database connection successful");
|
||||||
|
pool
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("Failed to connect to database: {:?}", err);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let app = Router::new().route("/", routing::get(root_handler));
|
||||||
|
|
||||||
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:8001").await.unwrap();
|
||||||
|
axum::serve(listener, app).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn root_handler() -> &'static str {
|
||||||
|
"Hello, World"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub enum category {
|
||||||
|
WhiteboardBeamer,
|
||||||
|
Internet,
|
||||||
|
IPadKoffer,
|
||||||
|
AppleTV,
|
||||||
|
DocuCam,
|
||||||
|
Sonstiges,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||||
|
pub struct ticket {
|
||||||
|
pub id: i32,
|
||||||
|
pub category: category,
|
||||||
|
pub betreff: String,
|
||||||
|
pub description: String,
|
||||||
|
pub room: i16,
|
||||||
|
pub date: chrono::NaiveDateTime,
|
||||||
|
pub user_id: i16,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||||
|
pub struct user {
|
||||||
|
pub id: i16,
|
||||||
|
pub first_name: String,
|
||||||
|
pub last_name: String,
|
||||||
|
pub is_admin: bool,
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
CREATE TYPE category AS ENUM('Whiteboard Beamer', 'Internet', 'iPad Koffer', 'Apple TV', 'Docu Cam', 'Sonstiges')
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS tickets (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
category category NOT NULL DEFAULT 'Sonstiges',
|
||||||
|
betreff VARCHAR(100),
|
||||||
|
description VARCHAR,
|
||||||
|
room SMALLINT,
|
||||||
|
date TIMESTAMP,
|
||||||
|
user_id SMALLINT
|
||||||
|
);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE users (
|
||||||
|
id SMALLINT PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name VARCHAR(30),
|
||||||
|
firstname VARCHAR(30),
|
||||||
|
is_admin BOOLEAN NOT NULL DEFAULT false
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user