mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-17 06:00:25 +08:00
简化缓存条件设置
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
@@ -27,19 +28,43 @@ func (this *CreatePopupAction) RunGet(params struct {
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
CacheRefJSON []byte
|
||||
|
||||
CondType string
|
||||
CondJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
var cacheRef = &serverconfigs.HTTPCacheRef{}
|
||||
err := json.Unmarshal(params.CacheRefJSON, cacheRef)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
this.Fail("解析条件出错:" + err.Error() + ", JSON: " + string(params.CacheRefJSON))
|
||||
return
|
||||
}
|
||||
|
||||
if len(params.CondJSON) > 0 {
|
||||
var cond = &shared.HTTPRequestCond{}
|
||||
err = json.Unmarshal(params.CondJSON, cond)
|
||||
if err != nil {
|
||||
this.Fail("解析条件出错:" + err.Error() + ", JSON: " + string(params.CondJSON))
|
||||
return
|
||||
}
|
||||
cond.Type = params.CondType
|
||||
cacheRef.SimpleCond = cond
|
||||
|
||||
// 将组合条件置为空
|
||||
cacheRef.Conds = &shared.HTTPRequestCondsConfig{}
|
||||
}
|
||||
|
||||
err = cacheRef.Init()
|
||||
if err != nil {
|
||||
this.Fail("解析条件出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(cacheRef.Key) == 0 {
|
||||
this.Fail("请输入缓存Key")
|
||||
}
|
||||
|
||||
if cacheRef.Conds == nil || len(cacheRef.Conds.Groups) == 0 {
|
||||
if (cacheRef.Conds == nil || len(cacheRef.Conds.Groups) == 0) && cacheRef.SimpleCond == nil {
|
||||
this.Fail("请填写匹配条件分组")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user