X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=backend%2Fsrc%2Fmodel.rs;fp=backend%2Fsrc%2Fmodel.rs;h=0ed482514b43dd2084b817afc738db3b6a1a11e7;hp=d0f95d2e46c86b994e89432c360fddc202ac32a7;hb=cc2e5b6893b582b4b5c4e7a93e914a189f6a959b;hpb=adcf4a5a5d982489a7e91d4988401eb4512839a3 diff --git a/backend/src/model.rs b/backend/src/model.rs index d0f95d2..0ed4825 100644 --- a/backend/src/model.rs +++ b/backend/src/model.rs @@ -1,22 +1,41 @@ +use chrono::prelude::*; + +pub struct User { + pub id: i64, + pub email: String, +} + +pub struct UserLoginInfo { + pub last_login_datetime: DateTime, + pub ip: String, + pub user_agent: String, +} + pub struct Recipe { pub id: i64, + pub user_id: i64, pub title: String, - pub description: Option, + pub description: String, pub estimate_time: Option, // [min]. - pub difficulty: Option, + pub difficulty: Difficulty, //ingredients: Vec, // For four people. pub process: Vec, } impl Recipe { - pub fn new(id: i64, title: String, description: Option) -> Recipe { + pub fn empty(id: i64, user_id: i64) -> Recipe { + Self::new(id, user_id, String::new(), String::new()) + } + + pub fn new(id: i64, user_id: i64, title: String, description: String) -> Recipe { Recipe { id, + user_id, title, description, estimate_time: None, - difficulty: None, + difficulty: Difficulty::Unknown, process: Vec::new(), } } @@ -34,13 +53,13 @@ pub struct Quantity { pub struct Group { pub name: Option, + pub input: Vec, + pub output: Vec, pub steps: Vec, } pub struct Step { pub action: String, - pub input: Vec, - pub output: Vec, } pub struct IntermediateSubstance {