修复bug
This commit is contained in:
parent
46bcfec6a0
commit
05ececfd51
|
@ -7,6 +7,7 @@ import (
|
|||
"gorm.io/gorm"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ExecuteDb struct {
|
||||
|
@ -58,12 +59,31 @@ func (db *ExecuteDb) ExecuteWriteV2(readData []map[string]interface{}, execute s
|
|||
func (db *ExecuteDb) replaceExecuteString(execute string, rowData map[string]interface{}) string {
|
||||
executeString := execute
|
||||
for key, value := range rowData {
|
||||
formatValue := FormatValueData(value)
|
||||
key := fmt.Sprintf("${%s}", key)
|
||||
executeString = strings.Replace(executeString, key, fmt.Sprintf("%v", value), -1)
|
||||
executeString = strings.Replace(executeString, key, fmt.Sprintf("%v", formatValue), -1)
|
||||
}
|
||||
return executeString
|
||||
}
|
||||
|
||||
func FormatValueData(v interface{}) interface{} {
|
||||
var format interface{}
|
||||
switch v.(type) {
|
||||
case nil:
|
||||
format = "NULL"
|
||||
case time.Time:
|
||||
format = fmt.Sprintf("'%v'", v.(time.Time).Format("2006-01-02 15:04:05"))
|
||||
|
||||
case []uint8:
|
||||
format = fmt.Sprintf("'%v'", string(v.([]uint8)))
|
||||
case string:
|
||||
format = fmt.Sprintf("'%v'", v)
|
||||
default:
|
||||
format = v
|
||||
}
|
||||
return format
|
||||
}
|
||||
|
||||
func FilterReadData(data *[]map[string]interface{}, matchJson string) (filteredData []map[string]interface{}, err error) {
|
||||
if matchJson == "" {
|
||||
return *data, nil
|
||||
|
|
1
go.mod
1
go.mod
|
@ -18,7 +18,6 @@ require (
|
|||
github.com/go-sql-driver/mysql v1.7.0
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||
github.com/golang/protobuf v1.5.4
|
||||
github.com/jinzhu/copier v0.4.0
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5
|
||||
github.com/nats-io/nats.go v1.9.1
|
||||
github.com/openzipkin/zipkin-go v0.2.2
|
||||
|
|
Loading…
Reference in New Issue