mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[feat]添加规则引擎debug功能
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user