You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/Platform/Controllers/ServerController.cs

35 lines
1008 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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