api.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package definition
  2. import (
  3. "git.sxidc.com/go-framework/baize/framework/binding"
  4. "git.sxidc.com/go-framework/baize/framework/core/api"
  5. "git.sxidc.com/go-framework/baize/framework/core/api/request"
  6. "git.sxidc.com/go-framework/baize/framework/core/api/response"
  7. "git.sxidc.com/go-framework/baize/framework/core/domain"
  8. "git.sxidc.com/go-framework/baize/framework/core/infrastructure"
  9. )
  10. // Simple Bind参数
  11. type Simple struct {
  12. // schema
  13. Schema string
  14. }
  15. func (simple *Simple) Bind(binder *binding.Binder) {
  16. binding.GetBind(binder, &binding.SimpleBindItem[map[string]any]{
  17. Path: "/queryRuleDefinition/get",
  18. SendResponseFunc: response.SendMapResponse,
  19. RequestParams: &GetQueryRuleDefinitionQueryParams{},
  20. ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
  21. errResponse := map[string]any{
  22. "definition": make([]Info, 0),
  23. }
  24. queryParams, err := request.ToConcrete[*GetQueryRuleDefinitionQueryParams](params)
  25. if err != nil {
  26. return errResponse, err
  27. }
  28. return map[string]any{
  29. "definition": formInfoBatch(GetQueryRuleDefinitions(queryParams.DomainName)),
  30. }, nil
  31. },
  32. })
  33. }