mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-25 11:10:29 +08:00
优化代码
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache/cacheutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
@@ -27,11 +26,11 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) {
|
||||
cachePolicyId := action.ParamInt64("cachePolicyId")
|
||||
action.Data["cachePolicyId"] = cachePolicyId
|
||||
|
||||
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
|
||||
if parentActionValue.IsValid() {
|
||||
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
|
||||
if isOk {
|
||||
action.Data["cachePolicyName"] = cacheutils.FindCachePolicyNameWithoutError(&parentAction, cachePolicyId)
|
||||
}
|
||||
parentActionObj, ok := actionPtr.(interface {
|
||||
Parent() *actionutils.ParentAction
|
||||
})
|
||||
if ok {
|
||||
var parentAction = parentActionObj.Parent()
|
||||
action.Data["cachePolicyName"] = cacheutils.FindCachePolicyNameWithoutError(parentAction, cachePolicyId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user