feat: 网关管理模块 + RBAC权限认证 + 组织架构 + 审计日志
- 网关管理:GatewayEntity/Service/Controller CRUD + 测试连接;设备 GatewayId 外键关联 - JWT 认证:登录签发 Token(权限编码写入 Claims)、RequirePermission 权限过滤器、CurrentUser 上下文 - RBAC:用户/角色/权限实体与 CRUD,预定义 4 角色 + 6 权限种子(admin/admin123) - 组织架构:sys_org 固定层级树(公司/实验室/部门/班组白夜班),层级校验,用户挂 OrgId/岗位/技能标签 - 数据权限:角色 DataScope(全部/本组织及下级),用户列表按组织子树过滤 - 防锁死保护:禁止删/禁自己,保证至少一名活跃管理员,角色摘除 user:manage 前校验 - 审计日志:AuditRecorder 接入设备增删改/指令下发/登录登出/组织变更,AuditController 查询 - 设备指令下发按网关表取连接参数;设备列表支持 gatewayId/productId 筛选 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Model.Entity.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// 网关(通讯通道):TCP 类存 IP+端口,串口类存 COM+波特率,S7 类额外存 CPU/Rack/Slot。
|
||||
/// 同一网关下多设备用从站号(SlaveId)区分。
|
||||
/// </summary>
|
||||
public class GatewayEntity : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 网关编码(唯一,如 GW-ENV-01)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "网关编码", Length = 64)]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 网关名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "网关名称", Length = 100)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯协议类型(决定连接参数组:TCP/Serial/S7)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "通讯协议类型")]
|
||||
public IotDeviceProtocolEnum ProtocolType { get; set; } = IotDeviceProtocolEnum.ModbusTcp;
|
||||
|
||||
#region TCP 参数(ModbusTcp / Tcp / S7 协议使用)
|
||||
/// <summary>
|
||||
/// IP 地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "IP地址", Length = 50, IsNullable = true)]
|
||||
public string? Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 端口号(ModbusTcp 默认 502,S7 默认 102)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "端口号", IsNullable = true)]
|
||||
public int? Port { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 串口参数(ModbusRtu / Serial 协议使用)
|
||||
/// <summary>
|
||||
/// 串口号(如 COM3)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "串口号", Length = 20, IsNullable = true)]
|
||||
public string? ComPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 波特率(默认 9600)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "波特率", IsNullable = true)]
|
||||
public int? BaudRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据位(默认 8)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "数据位", IsNullable = true)]
|
||||
public byte? DataBits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停止位(1/2,默认 1)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "停止位", IsNullable = true)]
|
||||
public byte? StopBits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 校验位(0=None 1=Odd 2=Even,默认 0)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "校验位", IsNullable = true)]
|
||||
public byte? Parity { get; set; }
|
||||
#endregion
|
||||
|
||||
#region S7 参数(S7 协议专用)
|
||||
/// <summary>
|
||||
/// S7 CPU 型号(如 S71200、S71500)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "S7 CPU型号", Length = 20, IsNullable = true)]
|
||||
public string? CpuType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// S7 Rack(默认 0)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "S7 Rack", IsNullable = true)]
|
||||
public byte? Rack { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// S7 Slot(默认 1)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "S7 Slot", IsNullable = true)]
|
||||
public byte? Slot { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 状态
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否启用")]
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 在线状态(0=离线 1=在线 3=异常,由测试连接更新)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "在线状态")]
|
||||
public byte OnlineStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后连接成功时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "最后连接时间", IsNullable = true)]
|
||||
public DateTime? LastConnectedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近错误
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "最近错误", Length = 500, IsNullable = true)]
|
||||
public string? LastError { get; set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "备注", Length = 500, IsNullable = true)]
|
||||
public string? Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,10 @@ namespace Model.Entity.Config
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属网关Code(对应网关实体/通道的标识,连接时据此刻查找 IP/端口/串口)
|
||||
/// 所属网关Id(关联 GatewayEntity.Id,0=未分配)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "所属网关Code", Length = 64)]
|
||||
public string GatewayCode { get; set; }
|
||||
[SugarColumn(ColumnDescription = "所属网关Id", DefaultValue = "0")]
|
||||
public long GatewayId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 从站地址(协议从站号,网关下区分设备)
|
||||
|
||||
Reference in New Issue
Block a user