app,server: Allow to edit steps
This commit is contained in:
parent
0c7e52bd8b
commit
1ea5c8aafa
4 changed files with 141 additions and 5 deletions
|
|
@ -228,6 +228,10 @@ pub(crate) fn router(api_allowed: Option<HeaderValue>) -> Router<AppState> {
|
|||
.patch(recipe::edit_name)
|
||||
.layer(mk_service(vec![Method::GET, Method::PATCH])),
|
||||
)
|
||||
.route(
|
||||
"/household/:house_id/recipe/:recipe_id/steps",
|
||||
patch(recipe::edit_step).layer(mk_service(vec![Method::PATCH])),
|
||||
)
|
||||
.route(
|
||||
"/household/:house_id/recipe/:recipe_id/ingredients/:iid",
|
||||
patch(recipe::edit_ig_amount)
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue