using Application.Domain.Entities; using Infrastructure.Data; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; namespace Platform.Controllers { /// /// 作为平台服务器,响应网关节点的HTTP请求 /// public class ServerController : ControllerBase { private readonly IServiceProvider _services; public ServerController(IServiceProvider services) { this._services = services; } /// /// 根据编号查询设备是否存在 /// /// /// public bool HasProduct(string number) { using var scope = this._services.CreateScope(); var repo = scope.ServiceProvider.GetRequiredService>(); return repo.ReadOnlyTable().Any(o => o.Number == number); } } }