archive.go 795 B

12345678910111213141516171819202122232425262728293031323334
  1. package http
  2. import (
  3. "go-common/app/interface/openplatform/article/conf"
  4. "go-common/app/service/main/archive/api"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/metadata"
  8. "go-common/library/xstr"
  9. )
  10. func archives(c *bm.Context) {
  11. var (
  12. err error
  13. aids []int64
  14. arcs map[int64]*api.Arc
  15. params = c.Request.Form
  16. ip = metadata.String(c, metadata.RemoteIP)
  17. )
  18. idsStr := params.Get("ids")
  19. if aids, err = xstr.SplitInts(idsStr); err != nil || len(aids) < 1 || len(aids) > conf.Conf.Article.MaxArchives {
  20. c.JSON(nil, ecode.RequestErr)
  21. return
  22. }
  23. if arcs, err = artSrv.Archives(c, aids, ip); err != nil {
  24. c.JSON(nil, err)
  25. return
  26. }
  27. if len(arcs) == 0 {
  28. c.JSON(nil, ecode.NothingFound)
  29. return
  30. }
  31. c.JSON(arcs, err)
  32. }