The backend for the project formerly known as signet, now known as beignet.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
888 B

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