review.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package http
  2. import (
  3. "go-common/app/admin/main/videoup-task/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "strconv"
  7. )
  8. func checkReview(c *bm.Context) {
  9. sf := &model.SubmitForm{}
  10. if err := c.Bind(sf); err != nil {
  11. c.JSON(nil, ecode.RequestErr)
  12. return
  13. }
  14. if ok, err := srv.CheckReview(c, sf); err != nil {
  15. c.JSON(nil, err)
  16. } else {
  17. c.JSON(ok, nil)
  18. }
  19. }
  20. // list
  21. func listreviews(c *bm.Context) {
  22. v := &model.ListParser{}
  23. if err := c.Bind(v); err != nil {
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. rcs, count, err := srv.ListReviewConfs(c, v.Unames, v.Bt, v.Et, v.Sort, v.Pn, v.Ps)
  28. if err != nil {
  29. c.JSON(nil, err)
  30. return
  31. }
  32. c.JSONMap(map[string]interface{}{
  33. "data": rcs,
  34. "pager": &model.Pager{Pn: int(v.Pn), Ps: int(v.Ps), Sum: count},
  35. }, nil)
  36. }
  37. func addreview(c *bm.Context) {
  38. uid, uname := getUIDName(c)
  39. trc := &model.ReviewConf{}
  40. if err := c.Bind(trc); err != nil {
  41. c.JSON(nil, ecode.RequestErr)
  42. return
  43. }
  44. trc.UID = uid
  45. trc.Uname = uname
  46. c.JSON(nil, srv.AddReviewConf(c, trc))
  47. }
  48. func editreview(c *bm.Context) {
  49. uid, uname := getUIDName(c)
  50. trc := &model.ReviewConf{}
  51. if err := c.Bind(trc); err != nil {
  52. c.JSON(nil, ecode.RequestErr)
  53. return
  54. }
  55. trc.UID = uid
  56. trc.Uname = uname
  57. c.JSON(nil, srv.EditReviewConf(c, trc))
  58. }
  59. func delreview(c *bm.Context) {
  60. idStr := c.Request.Form.Get("id")
  61. id, err := strconv.Atoi(idStr)
  62. if err != nil || id == 0 {
  63. c.JSON(nil, ecode.RequestErr)
  64. }
  65. c.JSON(nil, srv.DelReviewConf(c, id))
  66. }