add core models

This commit is contained in:
Kasper Juul Hermansen 2022-10-03 22:20:01 +02:00
parent 8c51b68523
commit b01b33f7d1
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
11 changed files with 58 additions and 2 deletions

1
Cargo.lock generated
View File

@ -2452,6 +2452,7 @@ checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f"
dependencies = [
"getrandom",
"rand",
"serde",
]
[[package]]

View File

@ -9,4 +9,4 @@ edition = "2021"
anyhow = "1.0.60"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.68"
uuid = { version = "1.1.2", features = ["v4", "fast-rng"] }
uuid = { version = "1.1.2", features = ["v4", "fast-rng", "serde"] }

View File

@ -0,0 +1,21 @@
pub mod requests;
pub mod responses;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Deserialize, Serialize)]
pub enum ItemState {
Created,
Done,
Archived,
Deleted,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ItemDto {
pub id: Uuid,
pub title: String,
pub description: Option<String>,
pub state: ItemState,
}

View File

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct CreateItemDto {
pub name: String,
}

View File

@ -0,0 +1,3 @@
use super::ItemDto;
pub type CreatedItemDto = ItemDto;

View File

@ -1 +1,3 @@
pub mod item;
pub mod projects;
pub mod users;

View File

@ -0,0 +1,11 @@
pub mod requests;
pub mod responses;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize)]
pub struct ProjectDto {
pub id: Uuid,
pub name: String,
}

View File

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct CreateProjectDto {
pub name: String,
}

View File

@ -0,0 +1,3 @@
use super::ProjectDto;
pub type CreatedProjectDto = ProjectDto;

View File

@ -1,11 +1,11 @@
pub mod requests;
pub mod responses;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Serialize, Deserialize, Debug)]
pub struct UserDto {
#[serde(skip_serializing, skip_deserializing)]
pub id: Uuid,
pub username: String,
pub email: String,

View File

@ -0,0 +1,3 @@
use super::UserDto;
pub type UserCreatedDto = UserDto;