[feat]添加规则引擎debug功能

This commit is contained in:
PandaX
2023-10-27 15:28:29 +08:00
parent c2b16d5474
commit 0fcb262519
13 changed files with 2145 additions and 59 deletions

View File

@@ -3,6 +3,7 @@ package tool
import (
"encoding/json"
"pandax/pkg/global"
"reflect"
"strings"
"time"
)
@@ -67,6 +68,21 @@ func FirstLowCamelString(s string) string {
return string(data)
}
func StructToMap(s interface{}) map[string]interface{} {
result := make(map[string]interface{})
value := reflect.ValueOf(s)
typ := reflect.TypeOf(s)
for i := 0; i < value.NumField(); i++ {
field := typ.Field(i)
fieldValue := value.Field(i).Interface()
result[field.Name] = fieldValue
}
return result
}
func MapToStruct(m map[string]interface{}, s interface{}) error {
data, err := json.Marshal(m)
if err != nil {