check-live.go 932 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. "strconv"
  6. "strings"
  7. )
  8. func checkLiveStreamList(c *bm.Context) {
  9. params := c.Request.URL.Query()
  10. rooms := params.Get("room_ids")
  11. c.Set("input_params", params)
  12. if rooms == "" {
  13. c.Set("output_data", "some fields are empty")
  14. c.JSONMap(map[string]interface{}{"message": "some fields are empty"}, ecode.RequestErr)
  15. c.Abort()
  16. return
  17. }
  18. // 切割room_id
  19. roomIDs := strings.Split(rooms, ",")
  20. if len(roomIDs) <= 0 {
  21. c.Set("output_data", "room_ids is not right")
  22. c.JSONMap(map[string]interface{}{"message": "room_ids is not right"}, ecode.RequestErr)
  23. c.Abort()
  24. return
  25. }
  26. rids := []int64{}
  27. for _, v := range roomIDs {
  28. roomID, err := strconv.ParseInt(v, 10, 64)
  29. if err != nil {
  30. continue
  31. }
  32. rids = append(rids, roomID)
  33. }
  34. c.JSONMap(map[string]interface{}{"data": srv.CheckLiveStreamList(c, rids)}, nil)
  35. }