The backend for the project formerly known as signet, now known as beignet.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

46 linhas
948 B

  1. package endpoints
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. . "github.com/imosed/signet/data"
  6. )
  7. type QueueMember struct {
  8. ID uint `json:"id"`
  9. Asset string `json:"asset"`
  10. Title string `json:"title"`
  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. panic("Could not decode body")
  24. }
  25. var members []QueueMember
  26. Db.Table("queue_orders qo").Select("rf.id, asset, title, qo.order").
  27. Where("queue_id = ?", req.ID).
  28. Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id").
  29. Scan(&members)
  30. var resp GetQueueMembersResponse
  31. resp.Members = members
  32. err = json.NewEncoder(w).Encode(resp)
  33. if err != nil {
  34. panic("Could not deliver response")
  35. }
  36. }