Files
EdgeAdmin/internal/web/actions/default/servers/groups/group/delete.go

37 lines
1006 B
Go
Raw Normal View History

package group
2020-10-29 20:53:08 +08:00
2023-06-30 18:08:30 +08:00
import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
2020-10-29 20:53:08 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
GroupId int64
}) {
2020-11-10 21:37:48 +08:00
// 创建日志
2023-06-30 18:08:30 +08:00
defer this.CreateLogInfo(codes.ServerGroup_LogDeleteServerGroup, params.GroupId)
2020-11-10 21:37:48 +08:00
2020-10-29 20:53:08 +08:00
// 检查是否正在使用
2021-05-25 17:48:51 +08:00
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithServerGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithServerGroupIdRequest{ServerGroupId: params.GroupId})
2020-10-29 20:53:08 +08:00
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此分组正在被使用不能删除,请修改相关服务后再删除")
}
2021-05-25 17:48:51 +08:00
_, err = this.RPC().ServerGroupRPC().DeleteServerGroup(this.AdminContext(), &pb.DeleteServerGroupRequest{ServerGroupId: params.GroupId})
2020-10-29 20:53:08 +08:00
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}