ugc_view.go 815 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/metadata"
  7. )
  8. // viewPage view page handler.
  9. func view(c *bm.Context) {
  10. var (
  11. v = new(struct {
  12. AID int64 `form:"aid" validate:"required,min=1"`
  13. AccessKey string `form:"access_key"`
  14. })
  15. mid int64
  16. )
  17. if err := c.Bind(v); err != nil {
  18. return
  19. }
  20. if midInter, ok := c.Get("mid"); ok {
  21. mid = midInter.(int64)
  22. }
  23. // view
  24. now := time.Now()
  25. view, isok, errMsg, err := viewSvc.View(c, mid, v.AID, v.AccessKey, metadata.String(c, metadata.RemoteIP), now)
  26. if err != nil {
  27. c.JSON(nil, err)
  28. return
  29. }
  30. // err msg logic
  31. if !isok {
  32. c.JSONMap(map[string]interface{}{
  33. "data": isok,
  34. "message": errMsg,
  35. }, ecode.CopyrightLimit)
  36. return
  37. }
  38. c.JSON(view, nil)
  39. }