MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / FilterServiceRemote

Method FilterServiceRemote

controller/strategy/iml.go:74–100  ·  view source on GitHub ↗
(ctx *gin.Context, serviceId string, name string)

Source from the content-addressed store, hash-verified

72}
73
74func (i *imlStrategyController) FilterServiceRemote(ctx *gin.Context, serviceId string, name string) ([]*strategy_dto.Title, []any, int64, string, string, error) {
75 f, has := strategy_filter.RemoteFilter(name)
76 if !has {
77 return nil, nil, 0, "", "", fmt.Errorf("filter not found: %s", name)
78 }
79 scopeAllow := false
80 for _, s := range f.Scopes() {
81 if s == strategy_filter.ScopeService {
82 scopeAllow = true
83 break
84 }
85 }
86 if !scopeAllow {
87 return nil, nil, 0, "", "", fmt.Errorf("scope not allowed: %s", name)
88 }
89 list, total, err := f.RemoteList(ctx, "", map[string]interface{}{"service": serviceId}, -1, -1)
90 if err != nil {
91 return nil, nil, 0, "", "", err
92 }
93 return utils.SliceToSlice(f.Titles(), func(l strategy_filter.OptionTitle) *strategy_dto.Title {
94 return &strategy_dto.Title{
95 Field: l.Field,
96 Title: l.Title,
97 }
98 }), list, total, f.Key(), "list", nil
99
100}
101
102func (i *imlStrategyController) filterOptions(ctx *gin.Context, scope string) ([]*strategy_dto.FilterOption, error) {
103 m, has := strategy_filter.Options(scope)

Callers

nothing calls this directly

Calls 5

RemoteFilterMethod · 0.65
ScopesMethod · 0.65
RemoteListMethod · 0.65
TitlesMethod · 0.65
KeyMethod · 0.65

Tested by

no test coverage detected