|
@@ -11,8 +11,8 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
type Executor interface {
|
|
type Executor interface {
|
|
- ExecuteRawSql(sql string, executeParams map[string]any) ([]map[string]any, error)
|
|
+ ExecuteRawSql(sql string, executeParams map[string]any) ([]sdk.SqlResult, error)
|
|
- ExecuteSql(name string, executeParams map[string]any) ([]map[string]any, error)
|
|
+ ExecuteSql(name string, executeParams map[string]any) ([]sdk.SqlResult, error)
|
|
}
|
|
}
|
|
|
|
|
|
const (
|
|
const (
|
|
@@ -61,7 +61,7 @@ func InsertEntity[T any](executor Executor, tableName string, e T) error {
|
|
}
|
|
}
|
|
|
|
|
|
func formInsertTableRow(e any, tableRows *sql_tpl.TableRows) error {
|
|
func formInsertTableRow(e any, tableRows *sql_tpl.TableRows) error {
|
|
- sqlMapping, err := ParseSqlMapping(e)
|
|
+ sqlMapping, err := ParseSqlMappingTag(e)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -163,7 +163,7 @@ func DeleteEntity[T any](executor Executor, tableName string, e T) error {
|
|
}
|
|
}
|
|
|
|
|
|
func formDeleteConditions(e any, conditions *sql_tpl.Conditions) error {
|
|
func formDeleteConditions(e any, conditions *sql_tpl.Conditions) error {
|
|
- sqlMapping, err := ParseSqlMapping(e)
|
|
+ sqlMapping, err := ParseSqlMappingTag(e)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -239,7 +239,7 @@ func UpdateEntity[T any](executor Executor, tableName string, e T) error {
|
|
}
|
|
}
|
|
|
|
|
|
func formUpdateTableRowsAndConditions(e any, tableRows *sql_tpl.TableRows, conditions *sql_tpl.Conditions) error {
|
|
func formUpdateTableRowsAndConditions(e any, tableRows *sql_tpl.TableRows, conditions *sql_tpl.Conditions) error {
|
|
- sqlMapping, err := ParseSqlMapping(e)
|
|
+ sqlMapping, err := ParseSqlMappingTag(e)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -389,7 +389,7 @@ func Update(executor Executor, executeParams *sql_tpl.UpdateExecuteParams) error
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func Query(executor Executor, executeParams *sql_tpl.QueryExecuteParams) ([]map[string]any, int64, error) {
|
|
+func Query(executor Executor, executeParams *sql_tpl.QueryExecuteParams) ([]sdk.SqlResult, int64, error) {
|
|
if executor == nil {
|
|
if executor == nil {
|
|
return nil, 0, errors.New("没有传递执行器")
|
|
return nil, 0, errors.New("没有传递执行器")
|
|
}
|
|
}
|
|
@@ -421,10 +421,15 @@ func Query(executor Executor, executeParams *sql_tpl.QueryExecuteParams) ([]map[
|
|
return nil, 0, err
|
|
return nil, 0, err
|
|
}
|
|
}
|
|
|
|
|
|
- return tableRows, int64(countTableRow[0]["count"].(float64)), nil
|
|
+ results := make([]sdk.SqlResult, len(tableRows))
|
|
|
|
+ for i, row := range tableRows {
|
|
|
|
+ results[i] = row
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return results, int64(countTableRow[0]["count"].(float64)), nil
|
|
}
|
|
}
|
|
|
|
|
|
-func QueryOne(executor Executor, executeParams *sql_tpl.QueryOneExecuteParams) (map[string]any, error) {
|
|
+func QueryOne(executor Executor, executeParams *sql_tpl.QueryOneExecuteParams) (sdk.SqlResult, error) {
|
|
if executor == nil {
|
|
if executor == nil {
|
|
return nil, errors.New("没有传递执行器")
|
|
return nil, errors.New("没有传递执行器")
|
|
}
|
|
}
|
|
@@ -516,7 +521,7 @@ func CheckHasOnlyOne(executor Executor, executeParams *sql_tpl.CheckHasOnlyOneEx
|
|
return int64(tableRows[0]["count"].(float64)) == 1, nil
|
|
return int64(tableRows[0]["count"].(float64)) == 1, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any) ([]map[string]any, error) {
|
|
+func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any) ([]sdk.SqlResult, error) {
|
|
if executor == nil {
|
|
if executor == nil {
|
|
return nil, errors.New("没有传递执行器")
|
|
return nil, errors.New("没有传递执行器")
|
|
}
|
|
}
|
|
@@ -533,7 +538,7 @@ func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any)
|
|
return tableRows, nil
|
|
return tableRows, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func ExecuteSql(executor Executor, name string, executeParams map[string]any) ([]map[string]any, error) {
|
|
+func ExecuteSql(executor Executor, name string, executeParams map[string]any) ([]sdk.SqlResult, error) {
|
|
if executor == nil {
|
|
if executor == nil {
|
|
return nil, errors.New("没有传递执行器")
|
|
return nil, errors.New("没有传递执行器")
|
|
}
|
|
}
|