|
@@ -57,15 +57,15 @@ func InsertEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- tableRows := sql_tpl.NewTableRow()
|
|
|
- err = formInsertTableRow(sqlMapping, tableRows)
|
|
|
+ tableRow := sql_tpl.NewTableRow()
|
|
|
+ err = formInsertTableRow(sqlMapping, tableRow)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
innerExecuteParamsMap, err := sql_tpl.InsertExecuteParams{
|
|
|
TableName: tableName,
|
|
|
- TableRow: tableRows,
|
|
|
+ TableRow: tableRow,
|
|
|
}.Map()
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -78,7 +78,7 @@ func InsertEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- tableRowsBatch := make([]sql_tpl.TableRow, 0)
|
|
|
+ tableRowBatch := make([]sql_tpl.TableRow, 0)
|
|
|
|
|
|
for i := 0; i < entitySliceValue.Len(); i++ {
|
|
|
sqlMapping, err := ParseSqlMappingTag(entitySliceValue.Index(i).Interface())
|
|
@@ -86,18 +86,18 @@ func InsertEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- tableRows := sql_tpl.NewTableRow()
|
|
|
- err = formInsertTableRow(sqlMapping, tableRows)
|
|
|
+ tableRow := sql_tpl.NewTableRow()
|
|
|
+ err = formInsertTableRow(sqlMapping, tableRow)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- tableRowsBatch = append(tableRowsBatch, *tableRows)
|
|
|
+ tableRowBatch = append(tableRowBatch, *tableRow)
|
|
|
}
|
|
|
|
|
|
innerExecuteParamsMap, err := sql_tpl.InsertBatchExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
- TableRowsBatch: tableRowsBatch,
|
|
|
+ TableName: tableName,
|
|
|
+ TableRowBatch: tableRowBatch,
|
|
|
}.Map()
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -118,13 +118,13 @@ func InsertEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func formInsertTableRow(sqlMapping *Mapping, tableRows *sql_tpl.TableRow) error {
|
|
|
+func formInsertTableRow(sqlMapping *Mapping, tableRow *sql_tpl.TableRow) error {
|
|
|
now := time.Now()
|
|
|
|
|
|
for fieldName, mappingElement := range sqlMapping.MappingElement {
|
|
|
switch element := mappingElement.(type) {
|
|
|
case *Mapping:
|
|
|
- err := formInsertTableRow(element, tableRows)
|
|
|
+ err := formInsertTableRow(element, tableRow)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -170,7 +170,7 @@ func formInsertTableRow(sqlMapping *Mapping, tableRows *sql_tpl.TableRow) error
|
|
|
opts = append(opts, sql_tpl.WithAESKey(element.AESKey))
|
|
|
}
|
|
|
|
|
|
- tableRows.Add(element.Name, value, opts...)
|
|
|
+ tableRow.Add(element.Name, value, opts...)
|
|
|
default:
|
|
|
return errors.New("不支持的元素类型")
|
|
|
}
|
|
@@ -270,16 +270,16 @@ func UpdateEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- tableRows := sql_tpl.NewTableRow()
|
|
|
+ tableRow := sql_tpl.NewTableRow()
|
|
|
conditions := sql_tpl.NewConditions()
|
|
|
- err = formUpdateTableRowsAndConditions(sqlMapping, tableRows, conditions)
|
|
|
+ err = formUpdateTableRowAndConditions(sqlMapping, tableRow, conditions)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
executeParamsMap, err := sql_tpl.UpdateExecuteParams{
|
|
|
TableName: tableName,
|
|
|
- TableRow: tableRows,
|
|
|
+ TableRow: tableRow,
|
|
|
Conditions: conditions,
|
|
|
}.Map()
|
|
|
if err != nil {
|
|
@@ -294,13 +294,13 @@ func UpdateEntity[T any](executor Executor, tableName string, e T) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func formUpdateTableRowsAndConditions(sqlMapping *Mapping, tableRows *sql_tpl.TableRow, conditions *sql_tpl.Conditions) error {
|
|
|
+func formUpdateTableRowAndConditions(sqlMapping *Mapping, tableRow *sql_tpl.TableRow, conditions *sql_tpl.Conditions) error {
|
|
|
now := time.Now()
|
|
|
|
|
|
for fieldName, mappingElement := range sqlMapping.MappingElement {
|
|
|
switch element := mappingElement.(type) {
|
|
|
case *Mapping:
|
|
|
- err := formUpdateTableRowsAndConditions(element, tableRows, conditions)
|
|
|
+ err := formUpdateTableRowAndConditions(element, tableRow, conditions)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -364,7 +364,7 @@ func formUpdateTableRowsAndConditions(sqlMapping *Mapping, tableRows *sql_tpl.Ta
|
|
|
if element.IsKey {
|
|
|
conditions.Equal(element.Name, value, opts...)
|
|
|
} else {
|
|
|
- tableRows.Add(element.Name, value, opts...)
|
|
|
+ tableRow.Add(element.Name, value, opts...)
|
|
|
}
|
|
|
default:
|
|
|
return errors.New("不支持的元素类型")
|