Files
waf-platform/EdgeAdmin/internal/web/actions/default/settings/ip-library/delete.go
2026-02-04 20:27:13 +08:00

39 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package iplibrary
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
ArtifactId int64
}) {
defer this.CreateLogInfo(codes.IPLibraryArtifact_LogDeleteIPLibraryArtifact, params.ArtifactId)
// 删除数据库中的记录
_, err := this.RPC().IPLibraryArtifactRPC().DeleteIPLibraryArtifact(this.AdminContext(), &pb.DeleteIPLibraryArtifactRequest{IpLibraryArtifactId: params.ArtifactId})
if err != nil {
this.ErrorPage(err)
return
}
// 删除 EdgeAPI 目录下的 MaxMind 文件(删除所有,因为无法确定具体是哪个文件)
_, err = this.RPC().IPLibraryRPC().DeleteMaxMindFile(this.AdminContext(), &pb.DeleteMaxMindFileRequest{
Filename: "", // 空字符串表示删除所有
})
if err != nil {
// 记录错误但不影响删除操作
this.Fail("删除IP库文件失败" + err.Error())
return
}
this.Success()
}