feat: major update - MySQL, chat, wishlist, PWA, admin overhaul
This commit is contained in:
35
mengyastore-backend/internal/handlers/admin_orders.go
Normal file
35
mengyastore-backend/internal/handlers/admin_orders.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (h *AdminHandler) ListAllOrders(c *gin.Context) {
|
||||
if !h.requireAdmin(c) {
|
||||
return
|
||||
}
|
||||
orders, err := h.orderStore.ListAll()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": orders})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) DeleteOrder(c *gin.Context) {
|
||||
if !h.requireAdmin(c) {
|
||||
return
|
||||
}
|
||||
orderID := c.Param("id")
|
||||
if orderID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "missing order id"})
|
||||
return
|
||||
}
|
||||
if err := h.orderStore.Delete(orderID); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": gin.H{"ok": true}})
|
||||
}
|
||||
Reference in New Issue
Block a user