copyright.go 783 B

123456789101112131415161718192021222324252627282930313233343536
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/admin/main/search/dao"
  5. "go-common/app/admin/main/search/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. func copyRight(c *bm.Context) {
  11. var (
  12. err error
  13. bulkItem []dao.BulkItem
  14. d []*model.CopyRight
  15. form = c.Request.Form
  16. )
  17. data := form.Get("data")
  18. if data == "" {
  19. c.JSON(nil, ecode.RequestErr)
  20. return
  21. }
  22. if err = json.Unmarshal([]byte(data), &d); err != nil {
  23. log.Error("json.Unmarshal error(%v)", err)
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. for _, v := range d {
  28. bulkItem = append(bulkItem, v)
  29. }
  30. if err = svr.Index(c, "internalPublic", bulkItem); err != nil {
  31. log.Error("srv.Index error(%v)", err)
  32. }
  33. c.JSON(nil, err)
  34. }