archive_update.go 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // updateBlocked .
  11. func updateArchive(c *bm.Context) {
  12. form := c.Request.Form
  13. appid := form.Get("appid")
  14. switch appid {
  15. case "task_qa_fans":
  16. updateTaskQaFans(c)
  17. default:
  18. c.JSON(nil, ecode.RequestErr)
  19. }
  20. }
  21. func updateTaskQaFans(c *bm.Context) {
  22. var (
  23. err error
  24. bulkItem []dao.BulkItem
  25. d []*model.TaskQaFansParams
  26. form = c.Request.Form
  27. )
  28. data := form.Get("data")
  29. if data == "" {
  30. c.JSON(nil, ecode.RequestErr)
  31. return
  32. }
  33. if err = json.Unmarshal([]byte(data), &d); err != nil {
  34. log.Error("json.Unmarshal error(%v)", err)
  35. c.JSON(nil, err)
  36. return
  37. }
  38. for _, v := range d {
  39. bulkItem = append(bulkItem, v)
  40. }
  41. if err = svr.Update(c, "ssd_archive", bulkItem); err != nil {
  42. log.Error("srv.Update error(%v)", err)
  43. }
  44. c.JSON(nil, err)
  45. }