http.go 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package block
  2. import (
  3. model "go-common/app/admin/main/member/model/block"
  4. service "go-common/app/admin/main/member/service/block"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/middleware/permit"
  8. "github.com/pkg/errors"
  9. )
  10. var (
  11. svc *service.Service
  12. )
  13. // Setup is.
  14. func Setup(blockSvc *service.Service, e *bm.Engine, authSvc *permit.Permit) {
  15. svc = blockSvc
  16. cb := e.Group("/x/admin/block", authSvc.Permit("BLOCK_SEARCH"))
  17. {
  18. cb.POST("/search", blockSearch)
  19. cb.GET("/history", history)
  20. }
  21. cb = e.Group("/x/admin/block", authSvc.Permit("BLOCK_BLOCK"))
  22. {
  23. cb.POST("", batchBlock)
  24. }
  25. cb = e.Group("/x/admin/block", authSvc.Permit("BLOCK_REMOVE"))
  26. {
  27. cb.POST("/remove", batchRemove)
  28. }
  29. }
  30. func bind(c *bm.Context, v model.ParamValidator) (err error) {
  31. if err = c.Bind(v); err != nil {
  32. err = errors.WithStack(err)
  33. return
  34. }
  35. if !v.Validate() {
  36. err = ecode.RequestErr
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. return
  41. }