app,server: Allow to edit steps

This commit is contained in:
traxys 2023-06-25 22:02:58 +02:00
parent 0c7e52bd8b
commit 1ea5c8aafa
4 changed files with 141 additions and 5 deletions

View file

@ -1,7 +1,7 @@
use api::{
AddRecipeIngredientRequest, CreateRecipeRequest, CreateRecipeResponse, EmptyResponse,
IngredientInfo, ListRecipesResponse, RecipeInfo, RecipeIngredientEditRequest,
RecipeRenameRequest,
IngredientInfo, ListRecipesResponse, RecipeEditStepsRequest, RecipeInfo,
RecipeIngredientEditRequest, RecipeRenameRequest,
};
use axum::{
async_trait,
@ -210,3 +210,19 @@ pub(super) async fn add_ig_request(
Ok(EmptyResponse {}.into())
}
pub(super) async fn edit_step(
State(state): State<AppState>,
RecipeExtractor(recipe): RecipeExtractor,
Json(req): Json<RecipeEditStepsRequest>,
) -> JsonResult<EmptyResponse> {
let model = recipe::ActiveModel {
id: ActiveValue::Set(recipe.id),
steps: ActiveValue::Set(req.steps),
..Default::default()
};
model.update(&state.db).await?;
Ok(EmptyResponse {}.into())
}