fix: change handler order
This commit is contained in:
@@ -112,7 +112,7 @@ func GetOrder(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAllOrders(c *gin.Context) {
|
func GetAllOrders(c *gin.Context) {
|
||||||
var orders models.Order
|
var orders []models.Order
|
||||||
|
|
||||||
if err := database.DB.Preload("Items.Item").Find(&orders).Error; err != nil {
|
if err := database.DB.Preload("Items.Item").Find(&orders).Error; err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Не удалось вывести заказы"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Не удалось вывести заказы"})
|
||||||
@@ -136,6 +136,7 @@ func UpdateOrderStatus(c *gin.Context) {
|
|||||||
|
|
||||||
if req.Status != "new" && req.Status != "packed" && req.Status != "delivered" && req.Status != "cancel" {
|
if req.Status != "new" && req.Status != "packed" && req.Status != "delivered" && req.Status != "cancel" {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Неверно указанный статус заказа"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Неверно указанный статус заказа"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result := database.DB.Model(&models.Order{}).Where("id = ? ", orderID).Update("status", req.Status)
|
result := database.DB.Model(&models.Order{}).Where("id = ? ", orderID).Update("status", req.Status)
|
||||||
|
|||||||
Reference in New Issue
Block a user