Mwafrika_Josue

amount cancellation

Aug 13th, 2024
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2. func updateCancellationAmount(db *gorm.DB, restaurantID uint) error {
  3. query := `
  4. UPDATE Restaurant
  5. SET CancellationAmount =
  6. CASE
  7. WHEN CancellationAmount = 0 THEN GREATEST(DinnerPriceMax, LunchPriceMax)
  8. ELSE CancellationAmount
  9. END
  10. WHERE id = ?;
  11. `
  12. if err := db.Exec(query, restaurantID).Error; err != nil {
  13. logging.Logger.Error("Error updating CancellationAmount", zap.Error(err))
  14. return err
  15. }
  16.  
  17. return nil
  18. }
  19.  
  20.  
  21. if err := updateCancellationAmount(dbutil.DB(), body.ID); err != nil {
  22. return nil, http.StatusInternalServerError, err
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment