change-log.go 933 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. "strconv"
  6. )
  7. // getChangeLogByRoomID 查询cdn切换记录
  8. func getChangeLogByRoomID(c *bm.Context) {
  9. params := c.Request.URL.Query()
  10. room := params.Get("room_id")
  11. limit := params.Get("limit")
  12. roomID, err := strconv.ParseInt(room, 10, 64)
  13. if err != nil || roomID <= 0 {
  14. c.Set("output_data", "room_id is not right")
  15. c.JSONMap(map[string]interface{}{"message": "room_id is not right"}, ecode.RequestErr)
  16. c.Abort()
  17. return
  18. }
  19. // 默认查询1最近一条记录
  20. limitInt, _ := strconv.ParseInt(limit, 10, 64)
  21. if limitInt <= 0 {
  22. limitInt = 1
  23. }
  24. infos, err := srv.GetChangeLogByRoomID(c, roomID, limitInt)
  25. if err != nil {
  26. c.Set("output_data", err.Error())
  27. c.JSONMap(map[string]interface{}{"message": err.Error()}, ecode.RequestErr)
  28. c.Abort()
  29. return
  30. }
  31. c.JSONMap(map[string]interface{}{"data": infos}, nil)
  32. }