The backend for the project formerly known as signet, now known as beignet.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

48 строки
1.0 KiB

  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 QueueMember struct {
  9. ID uint `json:"id"`
  10. Asset string `json:"asset"`
  11. Order int `json:"order"`
  12. }
  13. type GetQueueMembersRequest struct {
  14. ID uint `json:"id"`
  15. }
  16. type GetQueueMembersResponse struct {
  17. Members []QueueMember `json:"members"`
  18. }
  19. func GetQueueMembers(w http.ResponseWriter, r *http.Request) {
  20. var req GetQueueMembersRequest
  21. err := json.NewDecoder(r.Body).Decode(&req)
  22. if err != nil {
  23. log.Error().Err(err).Msg("Could not decode body in GetQueueMembers call")
  24. return
  25. }
  26. var members []QueueMember
  27. Db.Table("queue_orders qo").Select("rf.id, asset, qo.order").
  28. Where("queue_id = ?", req.ID).
  29. Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id").
  30. Order("qo.order").
  31. Scan(&members)
  32. var resp GetQueueMembersResponse
  33. resp.Members = members
  34. err = json.NewEncoder(w).Encode(resp)
  35. if err != nil {
  36. log.Error().Err(err).Msg("Could not deliver response in GetQueueMembers call")
  37. }
  38. }