|
@@ -10,7 +10,6 @@ import (
|
|
|
"git.sxidc.com/go-framework/baize/framwork/infrastructure/database/sql"
|
|
"git.sxidc.com/go-framework/baize/framwork/infrastructure/database/sql"
|
|
|
"git.sxidc.com/go-tools/utils/strutils"
|
|
"git.sxidc.com/go-tools/utils/strutils"
|
|
|
"git.sxidc.com/service-supports/fserr"
|
|
"git.sxidc.com/service-supports/fserr"
|
|
|
- "github.com/mitchellh/mapstructure"
|
|
|
|
|
"reflect"
|
|
"reflect"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -195,11 +194,6 @@ func Query[TI any](fromTableName string, toTableName string, toRelationColumnNam
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-type WithInfo[FI any, TI any] struct {
|
|
|
|
|
- Self FI `json:"self" mapstructure:"self"`
|
|
|
|
|
- With TI `json:"with" mapstructure:"with"`
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func QueryWithOtherInfo[FI any, TI any](fromTableName string, toTableName string, toRelationColumnName string) binding.ServiceFunc[map[string]any] {
|
|
func QueryWithOtherInfo[FI any, TI any](fromTableName string, toTableName string, toRelationColumnName string) binding.ServiceFunc[map[string]any] {
|
|
|
return func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
|
|
return func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
|
|
|
var outputFromZero FI
|
|
var outputFromZero FI
|
|
@@ -219,13 +213,9 @@ func QueryWithOtherInfo[FI any, TI any](fromTableName string, toTableName string
|
|
|
|
|
|
|
|
outputToZero = outputToZeroValue.Interface().(TI)
|
|
outputToZero = outputToZeroValue.Interface().(TI)
|
|
|
|
|
|
|
|
- zeroRetMap := make(map[string]any)
|
|
|
|
|
- err := mapstructure.Decode(WithInfo[FI, TI]{
|
|
|
|
|
- Self: outputFromZero,
|
|
|
|
|
- With: outputToZero,
|
|
|
|
|
- }, &zeroRetMap)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, err
|
|
|
|
|
|
|
+ zeroRetMap := map[string]any{
|
|
|
|
|
+ "self": outputFromZero,
|
|
|
|
|
+ "with": outputToZero,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dbExecutor := i.DBExecutor()
|
|
dbExecutor := i.DBExecutor()
|
|
@@ -295,12 +285,9 @@ func QueryWithOtherInfo[FI any, TI any](fromTableName string, toTableName string
|
|
|
return zeroRetMap, err
|
|
return zeroRetMap, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- retMap := make(map[string]any)
|
|
|
|
|
- err = mapstructure.Decode(WithInfo[FI, TI]{
|
|
|
|
|
- Self: fromInfo,
|
|
|
|
|
- With: toInfo,
|
|
|
|
|
- }, &retMap)
|
|
|
|
|
-
|
|
|
|
|
- return retMap, nil
|
|
|
|
|
|
|
+ return map[string]any{
|
|
|
|
|
+ "self": fromInfo,
|
|
|
|
|
+ "with": toInfo,
|
|
|
|
|
+ }, nil
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|