This commit is contained in:
unknown
2026-02-04 20:27:13 +08:00
commit 3b042d1dad
9410 changed files with 1488147 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package models
import (
"encoding/json"
"errors"
"reflect"
)
// DecodeEvent 解码事件
func (this *SysEvent) DecodeEvent() (EventInterface, error) {
// 解析数据类型
t, isOk := eventTypeMapping[this.Type]
if !isOk {
return nil, errors.New("can not found event type '" + this.Type + "'")
}
ptr := reflect.New(t).Interface().(EventInterface)
// 解析参数
if IsNotNull(this.Params) {
err := json.Unmarshal(this.Params, ptr)
if err != nil {
return nil, err
}
}
return ptr, nil
}