The backend for the project formerly known as signet, now known as beignet.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

editqueue.go 912 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package endpoints
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. . "github.com/imosed/signet/data"
  6. "github.com/rs/zerolog/log"
  7. )
  8. type FundOrder struct {
  9. ID int `json:"id"`
  10. Asset string `json:"asset"`
  11. Order int `json:"order"`
  12. }
  13. type EditQueueRequest struct {
  14. QueueID int `json:"queueID"`
  15. FundOrders []FundOrder `json:"fundOrders"`
  16. }
  17. func EditQueue(w http.ResponseWriter, r *http.Request) {
  18. var req EditQueueRequest
  19. err := json.NewDecoder(r.Body).Decode(&req)
  20. if err != nil {
  21. log.Error().Err(err).Msg("Could not decode body in EditQueue call")
  22. return
  23. }
  24. var resp SuccessResponse
  25. for _, qo := range req.FundOrders {
  26. Db.Table("queue_orders").
  27. Where("reward_fund_id = ? and queue_id = ?", qo.ID, req.QueueID).
  28. Update("order", qo.Order)
  29. }
  30. err = json.NewEncoder(w).Encode(resp)
  31. if err != nil {
  32. log.Error().Err(err).Msg("Could not deliver response in EditQueue call")
  33. }
  34. }