Recipe edit (WIP): add API to set some recipe values
This commit is contained in:
parent
c6dfff065c
commit
dd05a673d9
20 changed files with 690 additions and 2189 deletions
|
|
@ -16,84 +16,134 @@ pub struct SetRecipeDescription {
|
|||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeImage {
|
||||
pub struct SetRecipeEstimatedTime {
|
||||
pub recipe_id: i64,
|
||||
pub image: Vec<u8>,
|
||||
pub estimated_time: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
pub enum Difficulty {
|
||||
Unknown = 0,
|
||||
Easy = 1,
|
||||
Medium = 2,
|
||||
Hard = 3,
|
||||
}
|
||||
|
||||
impl TryFrom<u32> for Difficulty {
|
||||
type Error = &'static str;
|
||||
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
||||
Ok(match value {
|
||||
1 => Self::Easy,
|
||||
2 => Self::Medium,
|
||||
3 => Self::Hard,
|
||||
_ => Self::Unknown,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Difficulty> for u32 {
|
||||
fn from(value: Difficulty) -> Self {
|
||||
value as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeImageReply {
|
||||
pub image_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct RemoveRecipeImage {
|
||||
pub image_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeIngredient {
|
||||
pub group_id: i64,
|
||||
pub name: String,
|
||||
pub quantity_value: Option<f64>,
|
||||
pub quantity_unit: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeIngredientReply {
|
||||
pub ingredient_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct RemoveRecipeIngredient {
|
||||
pub group_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetRecipeIngredientsOrder {
|
||||
pub group_id: i64,
|
||||
pub ingredient_ids: Vec<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeGroup {
|
||||
pub struct SetRecipeDifficulty {
|
||||
pub recipe_id: i64,
|
||||
pub name: String,
|
||||
pub quantity_value: Option<f64>,
|
||||
pub quantity_unit: String,
|
||||
pub difficulty: Difficulty,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeGroupReply {
|
||||
pub group_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct RemoveRecipeGroupReply {
|
||||
pub group_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetRecipeGroupsOrder {
|
||||
pub struct SetRecipeLanguage {
|
||||
pub recipe_id: i64,
|
||||
pub group_ids: Vec<i64>,
|
||||
pub lang: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeStep {
|
||||
pub group_id: i64,
|
||||
pub name: String,
|
||||
pub struct SetIsPublished {
|
||||
pub recipe_id: i64,
|
||||
pub is_published: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct AddRecipeStepReply {
|
||||
pub step_id: i64,
|
||||
}
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeImage {
|
||||
// pub recipe_id: i64,
|
||||
// pub image: Vec<u8>,
|
||||
// }
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct RemoveRecipeStep {
|
||||
pub step_id: i64,
|
||||
}
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeImageReply {
|
||||
// pub image_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct RemoveRecipeImage {
|
||||
// pub image_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeIngredient {
|
||||
// pub group_id: i64,
|
||||
// pub name: String,
|
||||
// pub quantity_value: Option<f64>,
|
||||
// pub quantity_unit: String,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeIngredientReply {
|
||||
// pub ingredient_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct RemoveRecipeIngredient {
|
||||
// pub group_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct SetRecipeIngredientsOrder {
|
||||
// pub group_id: i64,
|
||||
// pub ingredient_ids: Vec<i64>,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeGroup {
|
||||
// pub recipe_id: i64,
|
||||
// pub name: String,
|
||||
// pub quantity_value: Option<f64>,
|
||||
// pub quantity_unit: String,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeGroupReply {
|
||||
// pub group_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct RemoveRecipeGroupReply {
|
||||
// pub group_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct SetRecipeGroupsOrder {
|
||||
// pub recipe_id: i64,
|
||||
// pub group_ids: Vec<i64>,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeStep {
|
||||
// pub group_id: i64,
|
||||
// pub name: String,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct AddRecipeStepReply {
|
||||
// pub step_id: i64,
|
||||
// }
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone)]
|
||||
// pub struct RemoveRecipeStep {
|
||||
// pub step_id: i64,
|
||||
// }
|
||||
|
||||
///// PROFILE /////
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue