The backend for the project formerly known as signet, now known as beignet.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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