提交 b613f076 编写于 作者: 麦壳饼's avatar 麦壳饼

加入产品 字典 和 加入 图标文件路径 加入 文件上传扩展等。

上级 7218a9b8
......@@ -138,6 +138,16 @@ namespace IoTSharp.Contracts
Device = 0,
Gateway = 1
}
public enum GatewayType
{
Unknow=0,
Customize,
Modbus,
Bacnet,
OPC_UA,
CanOpen,
}
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[JsonConverter(typeof(StringEnumConverter))]
public enum CoApRes
......
......@@ -100,6 +100,8 @@ namespace IoTSharp.Data
public DbSet<Produce> Produces { get; set; }
public DbSet<ProduceData> ProduceDatas { get; set; }
public DbSet<ProduceDictionary> ProduceDictionaries { get; set; }
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@ using System.Threading.Tasks;
namespace IoTSharp.Data
{
public class Produce
{
[Key]
......@@ -20,27 +19,56 @@ namespace IoTSharp.Data
public string Name { get; set; }
/// <summary>
/// 超时时间 秒数
/// ICON file full path
/// </summary>
public int DefaultTimeout { get; set; } = 300;
public string Icon { get; set; }
/// <summary>
/// 网关类型 根据不通网关来处理相关配置
/// </summary>
public GatewayType GatewayType { get; set; } = GatewayType.Unknow;
/// <summary>
/// 网关配置信息, 如果是Unknow 则不使用, 如果是自定义 ,则这里是json字符串。
/// 如果是其他对应的网关, 则这里是 对应的配置文件名。
/// </summary>
public string GatewayConfiguration { get; set; } = string.Empty;
/// <summary>
/// 超时时间 秒数
/// </summary>
public int DefaultTimeout { get; set; } = 300;
/// <summary>
/// 租户
/// </summary>
public Tenant Tenant { get; set; }
/// <summary>
/// 客户
/// </summary>
public Customer Customer { get; set; }
/// <summary>
/// 默认认证类型
/// </summary>
[EnumDataType(typeof(IdentityType))]
public IdentityType DefaultIdentityType { get; set; } = IdentityType.AccessToken;
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 默认属性
/// </summary>
public List<ProduceData> DefaultAttributes { get; set; }
/// <summary>
/// 所属设备
/// </summary>
public List<Device> Devices { get; set; }
/// <summary>
/// 默认设备类型
/// </summary>
public DeviceType DefaultDeviceType { get; set; }
/// <summary>
/// 产品字典
/// </summary>
public List<ProduceDictionary> Dictionaries { get; set; }
}
}
using IoTSharp.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataType = IoTSharp.Contracts.DataType;
namespace IoTSharp.Data
{
public class ProduceDictionary
{
[Key]
public Guid Id { get; set; }
/// <summary>
/// 字段名称
/// </summary>
public string KeyName { get; set; }
/// <summary>
/// 字段显示名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 单位转换表达式
/// </summary>
public string UnitExpression { get; set; }
/// <summary>
///
/// </summary>
public bool UnitConvert { get; set; }
/// <summary>
/// 字段备注
/// </summary>
public string? KeyDesc { get; set; }
/// <summary>
/// 默认值
/// </summary>
public string? DefaultValue { get; set; }
/// <summary>
/// 是否显示
/// </summary>
public bool Display { get; set; }
/// <summary>
/// 位置名称
/// </summary>
public string Place0 { get; set; }
/// <summary>
/// 此位置顺序
/// </summary>
public string PlaceOrder0 { get; set; }
public string Place1 { get; set; }
public string PlaceOrder1 { get; set; }
public string Place2 { get; set; }
public string PlaceOrder2 { get; set; }
public string Place3 { get; set; }
public string PlaceOrder3 { get; set; }
public string Place4 { get; set; }
public string PlaceOrder4 { get; set; }
public string Place5 { get; set; }
public string PlaceOrder5 { get; set; }
/// <summary>
/// 数据类型
/// </summary>
public DataType DataType { get; set; }
public string? Tag { get; set; }
public Guid? Customer { get; set; }
}
}
......@@ -19,13 +19,13 @@ namespace IoTSharp.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class PrducesController : ControllerBase
public class ProducesController : ControllerBase
{
private readonly ApplicationDbContext _context;
private readonly ILogger _logger;
public PrducesController(ApplicationDbContext context, ILogger<PrducesController> logger)
public ProducesController(ApplicationDbContext context, ILogger<ProducesController> logger)
{
_context = context;
_logger = logger;
......
......@@ -31,5 +31,21 @@ namespace IoTSharp.Extensions
Comstomer =@this.User.GetCustomerId()
};
}
public static string GetStorageRoot(this ControllerBase @this)
{
return $"/{@this.User.GetTenantId()}/{@this.User.GetCustomerId()}/";
}
public static string GetStorageRoot(this ControllerBase @this,Produce produce)
{
return $"/{@this.User.GetTenantId()}/{@this.User.GetCustomerId()}/{produce.Id}";
}
public static string GetStorageRoot(this ControllerBase @this, Device device)
{
return $"/{@this.User.GetTenantId()}/{@this.User.GetCustomerId()}/{device.Id}";
}
public static string GetStorageRoot(this ControllerBase @this, Gateway device)
{
return $"/{@this.User.GetTenantId()}/{@this.User.GetCustomerId()}/{device.Id}";
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册