block.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package http
  2. import (
  3. "go-common/app/admin/main/block/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func blockSearch(c *bm.Context) {
  7. var (
  8. err error
  9. v = &model.ParamSearch{}
  10. )
  11. if err = bind(c, v); err != nil {
  12. return
  13. }
  14. c.JSON(svc.Search(c, v.MIDs))
  15. }
  16. func blockHistory(c *bm.Context) {
  17. var (
  18. err error
  19. v = &model.ParamHistory{}
  20. )
  21. if err = bind(c, v); err != nil {
  22. return
  23. }
  24. var ret struct {
  25. Status model.BlockStatus `json:"status"`
  26. Total int `json:"total"`
  27. History []*model.BlockHistory `json:"history"`
  28. }
  29. if ret.Status, ret.Total, ret.History, err = svc.History(c, v.MID, v.PS, v.PN); err != nil {
  30. c.JSON(nil, err)
  31. return
  32. }
  33. if ret.History == nil {
  34. ret.History = make([]*model.BlockHistory, 0)
  35. }
  36. c.JSON(ret, err)
  37. }
  38. func batchBlock(c *bm.Context) {
  39. var (
  40. err error
  41. v = &model.ParamBatchBlock{}
  42. )
  43. if err = bind(c, v); err != nil {
  44. return
  45. }
  46. c.JSON(nil, svc.BatchBlock(c, v))
  47. }
  48. func batchRemove(c *bm.Context) {
  49. var (
  50. err error
  51. v = &model.ParamBatchRemove{}
  52. )
  53. if err = bind(c, v); err != nil {
  54. return
  55. }
  56. c.JSON(nil, svc.BatchRemove(c, v))
  57. }