thumbup.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. "go-common/library/xstr"
  8. )
  9. func thumbupDM(c *bm.Context) {
  10. p := c.Request.Form
  11. mid, _ := c.Get("mid")
  12. oid, err := strconv.ParseInt(p.Get("oid"), 10, 64)
  13. if err != nil || oid <= 0 {
  14. c.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. dmid, err := strconv.ParseInt(p.Get("dmid"), 10, 64)
  18. if err != nil || dmid <= 0 {
  19. c.JSON(nil, ecode.RequestErr)
  20. return
  21. }
  22. op, err := strconv.ParseInt(p.Get("op"), 10, 64)
  23. if err != nil {
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. if err = dmSvc.ThumbupDM(c, oid, dmid, mid.(int64), int8(op)); err != nil {
  28. log.Error("dmSvc.ThumbupDM(oid:%d,dmid:%d) error(%v)", oid, dmid, err)
  29. c.JSON(nil, err)
  30. return
  31. }
  32. c.JSON(nil, nil)
  33. }
  34. func thumbupStats(c *bm.Context) {
  35. var (
  36. mid int64
  37. p = c.Request.Form
  38. )
  39. oid, err := strconv.ParseInt(p.Get("oid"), 10, 64)
  40. if err != nil || oid <= 0 {
  41. c.JSON(nil, ecode.RequestErr)
  42. return
  43. }
  44. if midI, ok := c.Get("mid"); ok {
  45. mid = midI.(int64)
  46. }
  47. dmids, err := xstr.SplitInts(p.Get("ids"))
  48. if err != nil || len(dmids) == 0 {
  49. c.JSON(nil, ecode.RequestErr)
  50. return
  51. }
  52. data, err := dmSvc.ThumbupList(c, oid, mid, dmids)
  53. if err != nil {
  54. c.JSON(nil, err)
  55. return
  56. }
  57. c.JSON(data, nil)
  58. }