web_history.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/metadata"
  7. )
  8. func webHistoryList(c *bm.Context) {
  9. params := c.Request.Form
  10. aidStr := params.Get("aid")
  11. ip := metadata.String(c, metadata.RemoteIP)
  12. // check
  13. midI, ok := c.Get("mid")
  14. if !ok {
  15. c.JSON(nil, ecode.NoLogin)
  16. return
  17. }
  18. mid, _ := midI.(int64)
  19. aid, err := strconv.ParseInt(aidStr, 10, 64)
  20. if err != nil || aid < 1 {
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. history, err := arcSvc.HistoryList(c, mid, aid, ip)
  25. if err != nil {
  26. c.JSON(nil, err)
  27. return
  28. }
  29. c.JSON(history, nil)
  30. }
  31. func webHistoryView(c *bm.Context) {
  32. params := c.Request.Form
  33. hidStr := params.Get("history")
  34. ip := metadata.String(c, metadata.RemoteIP)
  35. // check
  36. midI, ok := c.Get("mid")
  37. if !ok {
  38. c.JSON(nil, ecode.NoLogin)
  39. return
  40. }
  41. mid, _ := midI.(int64)
  42. hid, err := strconv.ParseInt(hidStr, 10, 64)
  43. if err != nil || hid < 1 {
  44. c.JSON(nil, ecode.RequestErr)
  45. return
  46. }
  47. history, err := arcSvc.HistoryView(c, mid, hid, ip)
  48. if err != nil {
  49. c.JSON(nil, err)
  50. return
  51. }
  52. c.JSON(history, nil)
  53. }