X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=backend%2Fsrc%2Fmodel.rs;h=0ed482514b43dd2084b817afc738db3b6a1a11e7;hb=cc2e5b6893b582b4b5c4e7a93e914a189f6a959b;hp=d012bc9b99ce8233ab61de0b6919e89f38459433;hpb=108476e3554ea3a25dca5b5ab260f38c1e734221;p=recipes.git diff --git a/backend/src/model.rs b/backend/src/model.rs index d012bc9..0ed4825 100644 --- a/backend/src/model.rs +++ b/backend/src/model.rs @@ -1,44 +1,78 @@ -struct Recipe { - title: String, - estimate_time: Option, // [min]. - difficulty: Option, +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: String, + pub estimate_time: Option, // [min]. + pub difficulty: Difficulty, //ingredients: Vec, // For four people. - process: Vec, + pub process: Vec, +} + +impl 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: Difficulty::Unknown, + process: Vec::new(), + } + } } -struct Ingredient { - quantity: Option, - name: String, +pub struct Ingredient { + pub quantity: Option, + pub name: String, } -struct Quantity { - value: f32, - unit: String, +pub struct Quantity { + pub value: f32, + pub unit: String, } -struct Group { - name: Option, - steps: Vec, +pub struct Group { + pub name: Option, + pub input: Vec, + pub output: Vec, + pub steps: Vec, } -struct Step { - action: String, - input: Vec, - output: Vec, +pub struct Step { + pub action: String, } -struct IntermediateSubstance { - name: String, - quantity: Option, +pub struct IntermediateSubstance { + pub name: String, + pub quantity: Option, } -enum StepInput { +pub enum StepInput { Ingredient(Ingredient), IntermediateSubstance(IntermediateSubstance), } -enum Difficulty { +pub enum Difficulty { Unknown, Easy, Medium,