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.

getqueuemembers.go 888 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package endpoints
  2. import (
  3. "encoding/json"
  4. . "github.com/imosed/signet/data"
  5. "net/http"
  6. )
  7. type QueueMember struct {
  8. Asset string `json:"asset"`
  9. Title string `json:"title"`
  10. }
  11. type GetQueueMembersRequest struct {
  12. ID uint `json:"id"`
  13. }
  14. type GetQueueMembersResponse struct {
  15. Members []QueueMember `json:"members"`
  16. }
  17. func GetQueueMembers(w http.ResponseWriter, r *http.Request) {
  18. var req GetQueueMembersRequest
  19. err := json.NewDecoder(r.Body).Decode(&req)
  20. if err != nil {
  21. panic("Could not decode body")
  22. }
  23. var members []QueueMember
  24. Db.Table("queue_orders qo").Select("reward_fund_id, asset, title").Where("queue_id = ?", req.ID).
  25. Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id").
  26. Scan(&members)
  27. var resp GetQueueMembersResponse
  28. resp.Members = members
  29. err = json.NewEncoder(w).Encode(resp)
  30. if err != nil {
  31. panic("Could not deliver response")
  32. }
  33. }