From 2ef1c5c9d2300b96e0c01a643dcca23760f2b99e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 11 Jan 2024 19:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E4=B8=80?= =?UTF-8?q?=E7=BB=84=E7=BD=91=E7=AB=99API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/services/service_server.go | 35 +++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/internal/rpc/services/service_server.go b/internal/rpc/services/service_server.go index 1a73e9ce..51a4cc92 100644 --- a/internal/rpc/services/service_server.go +++ b/internal/rpc/services/service_server.go @@ -1462,7 +1462,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb. return &pb.ListEnabledServersMatchResponse{Servers: result}, nil } -// DeleteServer 禁用某服务 +// DeleteServer 删除某网站 func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServerRequest) (*pb.RPCSuccess, error) { // 校验请求 _, userId, err := this.ValidateAdminAndUser(ctx, true) @@ -1479,7 +1479,7 @@ func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServe } } - // 禁用服务 + // 禁用网站 err = models.SharedServerDAO.DisableServer(tx, req.ServerId) if err != nil { return nil, err @@ -1488,6 +1488,37 @@ func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServe return this.Success() } +// DeleteServers 删除一组网站 +func (this *ServerService) DeleteServers(ctx context.Context, req *pb.DeleteServersRequest) (*pb.RPCSuccess, error) { + // 校验请求 + _, userId, err := this.ValidateAdminAndUser(ctx, true) + if err != nil { + return nil, err + } + + var tx = this.NullTx() + for _, serverId := range req.ServerIds { + if serverId <= 0 { + continue + } + + // 检查权限 + if userId > 0 { + err = models.SharedServerDAO.CheckUserServer(tx, userId, serverId) + if err != nil { + return nil, err + } + } + + // 禁用网站 + err = models.SharedServerDAO.DisableServer(tx, serverId) + if err != nil { + return nil, err + } + } + return this.Success() +} + // FindEnabledServer 查找单个服务 func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEnabledServerRequest) (*pb.FindEnabledServerResponse, error) { // 校验请求