Remove generated file 'frontend.js'
[recipes.git] / backend / src / model.rs
1 use chrono::prelude::*;
2
3 pub struct User {
4 pub id: i64,
5 pub email: String,
6 }
7
8 pub struct UserLoginInfo {
9 pub last_login_datetime: DateTime<Utc>,
10 pub ip: String,
11 pub user_agent: String,
12 }
13
14 pub struct Recipe {
15 pub id: i64,
16 pub user_id: i64,
17 pub title: String,
18 pub description: String,
19 pub estimate_time: Option<i32>, // [min].
20 pub difficulty: Difficulty,
21
22 //ingredients: Vec<Ingredient>, // For four people.
23 pub process: Vec<Group>,
24 }
25
26 impl Recipe {
27 pub fn empty(id: i64, user_id: i64) -> Recipe {
28 Self::new(id, user_id, String::new(), String::new())
29 }
30
31 pub fn new(id: i64, user_id: i64, title: String, description: String) -> Recipe {
32 Recipe {
33 id,
34 user_id,
35 title,
36 description,
37 estimate_time: None,
38 difficulty: Difficulty::Unknown,
39 process: Vec::new(),
40 }
41 }
42 }
43
44 pub struct Ingredient {
45 pub quantity: Option<Quantity>,
46 pub name: String,
47 }
48
49 pub struct Quantity {
50 pub value: f32,
51 pub unit: String,
52 }
53
54 pub struct Group {
55 pub name: Option<String>,
56 pub input: Vec<StepInput>,
57 pub output: Vec<IntermediateSubstance>,
58 pub steps: Vec<Step>,
59 }
60
61 pub struct Step {
62 pub action: String,
63 }
64
65 pub struct IntermediateSubstance {
66 pub name: String,
67 pub quantity: Option<Quantity>,
68 }
69
70 pub enum StepInput {
71 Ingredient(Ingredient),
72 IntermediateSubstance(IntermediateSubstance),
73 }
74
75 pub enum Difficulty {
76 Unknown,
77 Easy,
78 Medium,
79 Hard,
80 }