dto_func.go 629 B

123456789101112131415161718192021222324252627282930
  1. package binding
  2. import (
  3. "git.sxidc.com/go-framework/baize/api"
  4. "github.com/gin-gonic/gin/binding"
  5. )
  6. func JsonBody(c *api.Context, dto DTO) error {
  7. return c.ShouldBindJSON(dto)
  8. }
  9. func QueryParams(c *api.Context, dto DTO) error {
  10. return c.ShouldBindQuery(dto)
  11. }
  12. func PathParams(c *api.Context, dto DTO) error {
  13. return c.ShouldBindUri(dto)
  14. }
  15. func MultipartForm(c *api.Context, dto DTO) error {
  16. return c.ShouldBindWith(dto, binding.FormMultipart)
  17. }
  18. func FormBody(c *api.Context, dto DTO) error {
  19. return c.ShouldBindWith(dto, binding.Form)
  20. }
  21. func XMLBody(c *api.Context, dto DTO) error {
  22. return c.ShouldBindXML(dto)
  23. }