package order

import (
	"Wine-Server/handlers/manager/super/order/change"
	"Wine-Server/handlers/manager/super/order/trade"
	"Wine-Server/utils"
	"Wine-Server/utils/tables"
	"github.com/gorilla/websocket"
)

func Handle(msg utils.WsMsg, conn *websocket.Conn, manager *tables.ManagerTable) {
	switch msg.Event {
	// trade:
	case "superOrderTradeQueryUser":
		trade.QueryUser(conn, manager, msg.Data)
		break
	case "superOrderTradeQueryTrade":
		trade.QueryTrade(conn, manager, msg.Data)
		break
	case "superOrderTradeRefund":
		trade.Refund(conn, manager, msg.Data)
		break
	// order:
	case "superOrderChangeQueryWorker":
		change.QueryWorker(conn, manager, msg.Data)
		break
	case "superOrderChangeQueryOrder":
		change.QueryOrder(conn, manager, msg.Data)
		break
	default:
		_ = conn.WriteJSON(utils.WsError("unrecognized event"))
		break
	}
}
