app,server: Allow to edit the rating
This commit is contained in:
parent
5ef000dec0
commit
d614029931
4 changed files with 167 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use api::{
|
||||
AddRecipeIngredientRequest, CreateRecipeRequest, CreateRecipeResponse, EmptyResponse,
|
||||
IngredientInfo, ListRecipesResponse, RecipeEditStepsRequest, RecipeInfo,
|
||||
IngredientInfo, ListRecipesResponse, RecipeEditRating, RecipeEditStepsRequest, RecipeInfo,
|
||||
RecipeIngredientEditRequest, RecipeRenameRequest,
|
||||
};
|
||||
use axum::{
|
||||
|
|
@ -227,3 +227,19 @@ pub(super) async fn edit_step(
|
|||
|
||||
Ok(EmptyResponse {}.into())
|
||||
}
|
||||
|
||||
pub(super) async fn edit_rating(
|
||||
State(state): State<AppState>,
|
||||
RecipeExtractor(recipe): RecipeExtractor,
|
||||
Json(req): Json<RecipeEditRating>,
|
||||
) -> JsonResult<EmptyResponse> {
|
||||
let model = recipe::ActiveModel {
|
||||
id: ActiveValue::Set(recipe.id),
|
||||
ranking: ActiveValue::Set(req.rating as _),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
model.update(&state.db).await?;
|
||||
|
||||
Ok(EmptyResponse {}.into())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue