comment.go 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package http
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/http/blademaster/binding"
  7. )
  8. func queryComment(c *bm.Context) {
  9. comment := model.Comment{}
  10. if err := c.BindWith(&comment, binding.Form); err != nil {
  11. c.JSON(nil, err)
  12. return
  13. }
  14. c.JSON(srv.QueryComment(&comment))
  15. }
  16. func addComment(c *bm.Context) {
  17. comment := model.Comment{}
  18. if err := c.BindWith(&comment, binding.JSON); err != nil {
  19. c.JSON(nil, err)
  20. return
  21. }
  22. c.JSON(nil, srv.AddComment(&comment))
  23. }
  24. func updateComment(c *bm.Context) {
  25. comment := model.Comment{}
  26. if err := c.BindWith(&comment, binding.JSON); err != nil {
  27. c.JSON(nil, err)
  28. return
  29. }
  30. c.JSON(nil, srv.UpdateComment(&comment))
  31. }
  32. func deleteComment(c *bm.Context) {
  33. v := new(struct {
  34. ID int64 `form:"id"`
  35. })
  36. if err := c.Bind(v); err != nil {
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. c.JSON(nil, srv.DeleteComment(v.ID))
  41. }