mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	增加删除一组网站API
This commit is contained in:
		@@ -1462,7 +1462,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
 | 
				
			|||||||
	return &pb.ListEnabledServersMatchResponse{Servers: result}, nil
 | 
						return &pb.ListEnabledServersMatchResponse{Servers: result}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DeleteServer 禁用某服务
 | 
					// DeleteServer 删除某网站
 | 
				
			||||||
func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServerRequest) (*pb.RPCSuccess, error) {
 | 
					func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServerRequest) (*pb.RPCSuccess, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
	_, userId, err := this.ValidateAdminAndUser(ctx, true)
 | 
						_, 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)
 | 
						err = models.SharedServerDAO.DisableServer(tx, req.ServerId)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -1488,6 +1488,37 @@ func (this *ServerService) DeleteServer(ctx context.Context, req *pb.DeleteServe
 | 
				
			|||||||
	return this.Success()
 | 
						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 查找单个服务
 | 
					// FindEnabledServer 查找单个服务
 | 
				
			||||||
func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEnabledServerRequest) (*pb.FindEnabledServerResponse, error) {
 | 
					func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEnabledServerRequest) (*pb.FindEnabledServerResponse, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user