修复结构体生成的BUG
This commit is contained in:
parent
2be1b29234
commit
d2e96ecfe6
@ -90,21 +90,22 @@ func (e *execute) List(ctx context.Context, inputParam *define.Api2SqlParam) (an
|
||||
st := wrapper.NewDynamic()
|
||||
for _, columnConfig := range inputParam.ColumnList {
|
||||
tag := fmt.Sprintf(`gorm:%v json:%v`, columnConfig.Column, columnConfig.Alias)
|
||||
column := wrapper.String(columnConfig.Column).SnakeCaseToCamel()
|
||||
switch columnConfig.Type {
|
||||
case "int", "int8", "int16", "int32", "int64":
|
||||
st.AddInt(columnConfig.Column, tag, "")
|
||||
st.AddInt(column, tag, "")
|
||||
case "uint", "uint8", "uint16", "uint32", "uint64":
|
||||
st.AddUint(columnConfig.Column, tag, "")
|
||||
st.AddUint(column, tag, "")
|
||||
case "bool":
|
||||
st.AddBool(columnConfig.Column, tag, "")
|
||||
st.AddBool(column, tag, "")
|
||||
case "float":
|
||||
st.AddBool(columnConfig.Column, tag, "")
|
||||
st.AddBool(column, tag, "")
|
||||
case "string":
|
||||
st.AddString(columnConfig.Column, tag, "")
|
||||
st.AddString(column, tag, "")
|
||||
case "map":
|
||||
st.AddMap(columnConfig.Column, tag, "")
|
||||
st.AddMap(column, tag, "")
|
||||
case "slice":
|
||||
st.AddSlice(columnConfig.Column, tag, "")
|
||||
st.AddSlice(column, tag, "")
|
||||
}
|
||||
}
|
||||
val := st.ToStructDefaultSliceValue()
|
||||
|
@ -43,13 +43,19 @@ func Test_execute_Run(t *testing.T) {
|
||||
})
|
||||
Exec.SetDatabaseClientManager(clientManager)
|
||||
res, err := Exec.List(context.Background(), &define.Api2SqlParam{
|
||||
DatabaseFlag: "TEST_DATABASE",
|
||||
Table: "project",
|
||||
ForceMaster: false,
|
||||
InputSql: "",
|
||||
TableSplitConfig: define.TableSplitConfig{},
|
||||
SqlType: consts.SqlTypeList,
|
||||
ColumnList: nil,
|
||||
DatabaseFlag: "TEST_DATABASE",
|
||||
Table: "project",
|
||||
ForceMaster: false,
|
||||
InputSql: "",
|
||||
TableSplitConfig: define.TableSplitConfig{},
|
||||
SqlType: consts.SqlTypeList,
|
||||
ColumnList: []*define.ColumnConfig{
|
||||
&define.ColumnConfig{
|
||||
Column: "flag",
|
||||
Alias: "project_flag",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Limit: 0,
|
||||
Offset: 0,
|
||||
ForceNoLimit: false,
|
||||
|
Loading…
Reference in New Issue
Block a user