api2sql基础的能力 #8
@ -90,21 +90,22 @@ func (e *execute) List(ctx context.Context, inputParam *define.Api2SqlParam) (an
|
|||||||
st := wrapper.NewDynamic()
|
st := wrapper.NewDynamic()
|
||||||
for _, columnConfig := range inputParam.ColumnList {
|
for _, columnConfig := range inputParam.ColumnList {
|
||||||
tag := fmt.Sprintf(`gorm:%v json:%v`, columnConfig.Column, columnConfig.Alias)
|
tag := fmt.Sprintf(`gorm:%v json:%v`, columnConfig.Column, columnConfig.Alias)
|
||||||
|
column := wrapper.String(columnConfig.Column).SnakeCaseToCamel()
|
||||||
switch columnConfig.Type {
|
switch columnConfig.Type {
|
||||||
case "int", "int8", "int16", "int32", "int64":
|
case "int", "int8", "int16", "int32", "int64":
|
||||||
st.AddInt(columnConfig.Column, tag, "")
|
st.AddInt(column, tag, "")
|
||||||
case "uint", "uint8", "uint16", "uint32", "uint64":
|
case "uint", "uint8", "uint16", "uint32", "uint64":
|
||||||
st.AddUint(columnConfig.Column, tag, "")
|
st.AddUint(column, tag, "")
|
||||||
case "bool":
|
case "bool":
|
||||||
st.AddBool(columnConfig.Column, tag, "")
|
st.AddBool(column, tag, "")
|
||||||
case "float":
|
case "float":
|
||||||
st.AddBool(columnConfig.Column, tag, "")
|
st.AddBool(column, tag, "")
|
||||||
case "string":
|
case "string":
|
||||||
st.AddString(columnConfig.Column, tag, "")
|
st.AddString(column, tag, "")
|
||||||
case "map":
|
case "map":
|
||||||
st.AddMap(columnConfig.Column, tag, "")
|
st.AddMap(column, tag, "")
|
||||||
case "slice":
|
case "slice":
|
||||||
st.AddSlice(columnConfig.Column, tag, "")
|
st.AddSlice(column, tag, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val := st.ToStructDefaultSliceValue()
|
val := st.ToStructDefaultSliceValue()
|
||||||
|
@ -49,7 +49,13 @@ func Test_execute_Run(t *testing.T) {
|
|||||||
InputSql: "",
|
InputSql: "",
|
||||||
TableSplitConfig: define.TableSplitConfig{},
|
TableSplitConfig: define.TableSplitConfig{},
|
||||||
SqlType: consts.SqlTypeList,
|
SqlType: consts.SqlTypeList,
|
||||||
ColumnList: nil,
|
ColumnList: []*define.ColumnConfig{
|
||||||
|
&define.ColumnConfig{
|
||||||
|
Column: "flag",
|
||||||
|
Alias: "project_flag",
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
Limit: 0,
|
Limit: 0,
|
||||||
Offset: 0,
|
Offset: 0,
|
||||||
ForceNoLimit: false,
|
ForceNoLimit: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user