39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
// 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()
|
||
}
|