reply_update.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/service/main/search/dao"
  5. "go-common/app/service/main/search/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. // replyUpdate
  11. func replyUpdate(c *bm.Context) {
  12. params := c.Request.Form
  13. appid := params.Get("appid")
  14. if appid == "" {
  15. c.JSON(nil, ecode.RequestErr)
  16. return
  17. }
  18. switch appid {
  19. case "reply_record":
  20. replyRecordUpdate(c)
  21. default:
  22. c.JSON(nil, ecode.RequestErr)
  23. }
  24. }
  25. func replyRecordUpdate(c *bm.Context) {
  26. var (
  27. err error
  28. bulkItem []dao.BulkItem
  29. d []*model.ReplyRecordUpdateParams
  30. )
  31. params := c.Request.Form
  32. data := params.Get("data")
  33. if data == "" {
  34. c.JSON(nil, ecode.RequestErr)
  35. return
  36. }
  37. if err = json.Unmarshal([]byte(data), &d); err != nil {
  38. log.Error("json.Unmarshal error(%v)", err)
  39. c.JSON(nil, ecode.RequestErr)
  40. return
  41. }
  42. for _, v := range d {
  43. bulkItem = append(bulkItem, v)
  44. }
  45. if err = svr.Update(c, "replyExternal", bulkItem); err != nil {
  46. log.Error("srv.Update error(%v)", err)
  47. }
  48. c.JSON(nil, err)
  49. }