apply.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 queryApply(c *bm.Context) {
  9. qar := model.QueryApplyRequest{}
  10. if err := c.BindWith(&qar, binding.Form); err != nil {
  11. c.JSON(nil, err)
  12. return
  13. }
  14. if err := qar.Verify(); err != nil {
  15. c.JSON(nil, err)
  16. return
  17. }
  18. c.JSON(srv.QueryApply(&qar))
  19. }
  20. func addApply(c *bm.Context) {
  21. apply := model.Apply{}
  22. if err := c.BindWith(&apply, binding.JSON); err != nil {
  23. c.JSON(nil, err)
  24. return
  25. }
  26. cookie := c.Request.Header.Get("Cookie")
  27. c.JSON(nil, srv.AddApply(c, cookie, &apply))
  28. }
  29. func updateApply(c *bm.Context) {
  30. apply := model.Apply{}
  31. if err := c.BindWith(&apply, binding.JSON); err != nil {
  32. c.JSON(nil, err)
  33. return
  34. }
  35. cookie := c.Request.Header.Get("Cookie")
  36. c.JSON(nil, srv.UpdateApply(cookie, &apply))
  37. }
  38. func delApply(c *bm.Context) {
  39. v := new(struct {
  40. ID int64 `form:"id"`
  41. })
  42. if err := c.Bind(v); err != nil {
  43. c.JSON(nil, ecode.RequestErr)
  44. return
  45. }
  46. c.JSON(nil, srv.DeleteApply(v.ID))
  47. }