+ DeleteRecipes
This commit is contained in:
@@ -312,3 +312,27 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteRecipes(ctx *jxcontext.Context, recipeIDs []int) (num int64, err error) {
|
||||
db := dao.GetDB()
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
for _, recipeID := range recipeIDs {
|
||||
recipe := &model.FoodRecipe{}
|
||||
recipe.ID = recipeID
|
||||
num2, err2 := dao.DeleteEntityLogically(db, recipe, nil, ctx.GetUserName(), nil)
|
||||
if err = err2; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
num += num2
|
||||
}
|
||||
dao.Commit(db)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user