http.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package block
  2. import (
  3. model "go-common/app/service/main/member/model/block"
  4. service "go-common/app/service/main/member/service/block"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. v "go-common/library/net/http/blademaster/middleware/verify"
  8. "github.com/pkg/errors"
  9. )
  10. var (
  11. svc *service.Service
  12. )
  13. // Setup is
  14. func Setup(blockSvc *service.Service, engine *bm.Engine, v *v.Verify) {
  15. svc = blockSvc
  16. blkGroup := engine.Group("/x/internal/block", v.Verify)
  17. blkGroup.POST("/block", block)
  18. blkGroup.POST("/remove", remove)
  19. blkGroup.GET("/info", info)
  20. blkGroupBatch := engine.Group("/x/internal/block/batch", v.Verify)
  21. blkGroupBatch.POST("/block", batchBlock)
  22. blkGroupBatch.POST("/remove", batchRemove)
  23. blkGroupBatch.POST("/info", batchInfo)
  24. blkGroupBatch.GET("/detail", batchDetail)
  25. }
  26. func bind(c *bm.Context, v model.ParamValidator) (err error) {
  27. if err = c.Bind(v); err != nil {
  28. err = errors.WithStack(err)
  29. return
  30. }
  31. if !v.Validate() {
  32. err = ecode.RequestErr
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. return
  37. }