X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fmodel.rs;h=0ed482514b43dd2084b817afc738db3b6a1a11e7;hb=HEAD;hp=ced209d0be14933d4c79ed6c023a8ec53e7d1a93;hpb=89f0943c08854acbc407562f813c4dde1e26fcf6;p=recipes.git diff --git a/backend/src/model.rs b/backend/src/model.rs index ced209d..0ed4825 100644 --- a/backend/src/model.rs +++ b/backend/src/model.rs @@ -1,34 +1,80 @@ -struct Recipe { - ingredients: Vec, - process: Vec, +use chrono::prelude::*; + +pub struct User { + pub id: i64, + pub email: String, } -struct Ingredient { - quantity: Quantity, - name: String, +pub struct UserLoginInfo { + pub last_login_datetime: DateTime, + pub ip: String, + pub user_agent: String, } -struct Quantity { - value: f32, - unit: 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. + pub process: Vec, } -struct Group { - name: String, - steps: 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 Step { - action: String, - input: Vec, - output: Vec, +pub struct Ingredient { + pub quantity: Option, + pub name: String, } -struct IntermediateSubstance { - name: String, - quantity: Option, +pub struct Quantity { + pub value: f32, + pub unit: String, } -enum StepInput { +pub struct Group { + pub name: Option, + pub input: Vec, + pub output: Vec, + pub steps: Vec, +} + +pub struct Step { + pub action: String, +} + +pub struct IntermediateSubstance { + pub name: String, + pub quantity: Option, +} + +pub enum StepInput { Ingredient(Ingredient), - IntermediateSubstance, -} \ No newline at end of file + IntermediateSubstance(IntermediateSubstance), +} + +pub enum Difficulty { + Unknown, + Easy, + Medium, + Hard, +}