web_netsafe.go 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func webNsMd5(c *bm.Context) {
  9. params := c.Request.Form
  10. nidStr := params.Get("nid")
  11. nid, err := strconv.ParseInt(nidStr, 10, 64)
  12. if err != nil {
  13. log.Error("strconv.ParseInt(%s) error(%v)", nidStr, err)
  14. c.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. appkey := params.Get("appkey")
  18. if appkey != "bilibili" {
  19. log.Error("(%s) error(%v)", appkey, err)
  20. c.JSON(nil, ecode.RequestErr)
  21. return
  22. }
  23. md5 := params.Get("md5")
  24. if len(md5) != 32 {
  25. log.Error("len(%s) (%d) error(%v)", md5, len(md5), err)
  26. c.JSON(nil, ecode.RequestErr)
  27. return
  28. }
  29. companyID := 2
  30. err = arcSvc.AddNetSafeMd5(c, nid, md5)
  31. if err != nil {
  32. c.JSON(nil, err)
  33. }
  34. c.JSONMap(map[string]interface{}{
  35. "nid": nid,
  36. "md5": md5,
  37. "cid": companyID,
  38. "companyId": companyID,
  39. "response": "ok",
  40. }, nil)
  41. }