Skip to content

Commit

Permalink
fix: data scope search by db not api (#6397)
Browse files Browse the repository at this point in the history
* fix: data scope search by db not api

* fix: remove debug log

* fix: update params

* fix: lint

* fix: remove useless code
  • Loading branch information
abeizn authored Nov 3, 2023
1 parent c1cd718 commit 8ddfcc1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend/helpers/pluginhelper/api/ds_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewDataSourceHelper[
connApi := NewDsConnectionApiHelper[C, S, SC](basicRes, connSrv)
scopeSrv := srvhelper.NewScopeSrvHelper[C, S, SC](basicRes, pluginName, scopeSearchColumns)
scopeApi := NewDsScopeApiHelper[C, S, SC](basicRes, scopeSrv)
scSrv := srvhelper.NewScopeConfigSrvHelper[C, S, SC](basicRes)
scSrv := srvhelper.NewScopeConfigSrvHelper[C, S, SC](basicRes, scopeSearchColumns)
scApi := NewDsScopeConfigApiHelper[C, S, SC](basicRes, scSrv)
return &DsHelper[C, S, SC]{
ConnSrv: connSrv,
Expand Down
2 changes: 1 addition & 1 deletion backend/helpers/srvhelper/connection_service_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewConnectionSrvHelper[
pluginName string,
) *ConnectionSrvHelper[C, S, SC] {
return &ConnectionSrvHelper[C, S, SC]{
ModelSrvHelper: NewModelSrvHelper[C](basicRes),
ModelSrvHelper: NewModelSrvHelper[C](basicRes, nil),
pluginName: pluginName,
}
}
Expand Down
20 changes: 11 additions & 9 deletions backend/helpers/srvhelper/model_service_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type ModelSrvHelper[M dal.Tabler] struct {
searchColumns []string
}

func NewModelSrvHelper[M dal.Tabler](basicRes context.BasicRes) *ModelSrvHelper[M] {
func NewModelSrvHelper[M dal.Tabler](basicRes context.BasicRes, searchColumns []string) *ModelSrvHelper[M] {
m := new(M)
modelName := fmt.Sprintf("%T", m)
db := basicRes.GetDal()
Expand All @@ -61,15 +61,17 @@ func NewModelSrvHelper[M dal.Tabler](basicRes context.BasicRes) *ModelSrvHelper[
}
pkWhere += fmt.Sprintf("%s = ? ", col.Name())
}

return &ModelSrvHelper[M]{
basicRes: basicRes,
log: basicRes.GetLogger().Nested(fmt.Sprintf("%s_dal", modelName)),
db: db,
validator: validator.New(),
modelName: modelName,
pk: pk,
pkWhere: pkWhere,
pkCount: len(pk),
basicRes: basicRes,
log: basicRes.GetLogger().Nested(fmt.Sprintf("%s_dal", modelName)),
db: db,
validator: validator.New(),
modelName: modelName,
pk: pk,
pkWhere: pkWhere,
pkCount: len(pk),
searchColumns: searchColumns,
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend/helpers/srvhelper/scope_config_service_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func NewScopeConfigSrvHelper[
C plugin.ToolLayerConnection,
S plugin.ToolLayerScope,
SC plugin.ToolLayerScopeConfig,
](basicRes context.BasicRes) *ScopeConfigSrvHelper[C, S, SC] {
](basicRes context.BasicRes, searchColumns []string) *ScopeConfigSrvHelper[C, S, SC] {
return &ScopeConfigSrvHelper[C, S, SC]{
ModelSrvHelper: NewModelSrvHelper[SC](basicRes),
ModelSrvHelper: NewModelSrvHelper[SC](basicRes, searchColumns),
}
}

Expand Down
6 changes: 2 additions & 4 deletions backend/helpers/srvhelper/scope_service_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ type ScopeDetail[S plugin.ToolLayerScope, SC plugin.ToolLayerScopeConfig] struct

type ScopeSrvHelper[C plugin.ToolLayerConnection, S plugin.ToolLayerScope, SC plugin.ToolLayerScopeConfig] struct {
*ModelSrvHelper[S]
pluginName string
searchColumns []string
pluginName string
}

// NewScopeSrvHelper creates a ScopeDalHelper for scope management
Expand All @@ -59,9 +58,8 @@ func NewScopeSrvHelper[
searchColumns []string,
) *ScopeSrvHelper[C, S, SC] {
return &ScopeSrvHelper[C, S, SC]{
ModelSrvHelper: NewModelSrvHelper[S](basicRes),
ModelSrvHelper: NewModelSrvHelper[S](basicRes, searchColumns),
pluginName: pluginName,
searchColumns: searchColumns,
}
}

Expand Down

0 comments on commit 8ddfcc1

Please sign in to comment.