The backend for the project formerly known as signet, now known as beignet.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

getqueuemembers.go 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. }