api2sql基础的能力 #8

Merged
zhangdeman merged 26 commits from feature/api2sql into master 2024-08-24 12:33:47 +08:00
2 changed files with 21 additions and 14 deletions
Showing only changes of commit d2e96ecfe6 - Show all commits

View File

@ -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()

View File

@ -49,7 +49,13 @@ func Test_execute_Run(t *testing.T) {
InputSql: "",
TableSplitConfig: define.TableSplitConfig{},
SqlType: consts.SqlTypeList,
ColumnList: nil,
ColumnList: []*define.ColumnConfig{
&define.ColumnConfig{
Column: "flag",
Alias: "project_flag",
Type: "string",
},
},
Limit: 0,
Offset: 0,
ForceNoLimit: false,