diff --git a/JiShe.CollectBus.Console/JiShe.CollectBus.Console.csproj b/JiShe.CollectBus.Console/JiShe.CollectBus.Console.csproj
index bdd95c7..ff9c209 100644
--- a/JiShe.CollectBus.Console/JiShe.CollectBus.Console.csproj
+++ b/JiShe.CollectBus.Console/JiShe.CollectBus.Console.csproj
@@ -19,12 +19,17 @@
-
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/JiShe.CollectBus.Console/appsettings.json b/JiShe.CollectBus.Console/appsettings.json
index d09fdc5..46483bc 100644
--- a/JiShe.CollectBus.Console/appsettings.json
+++ b/JiShe.CollectBus.Console/appsettings.json
@@ -1,4 +1,8 @@
{
+ "ConnectionStrings": {
+ "Default": "Data Source=192.168.111.248;Port=3306;Database=JiSheCollectBus;uid=root;pwd=123456abcD;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
+ },
+
"TCP": {
"Port": 10500
},
diff --git a/JiShe.CollectBus.Core/JiShe.CollectBus.Core.csproj b/JiShe.CollectBus.Core/JiShe.CollectBus.Core.csproj
index 6dd2744..9286c2d 100644
--- a/JiShe.CollectBus.Core/JiShe.CollectBus.Core.csproj
+++ b/JiShe.CollectBus.Core/JiShe.CollectBus.Core.csproj
@@ -13,11 +13,12 @@
-
-
+
+
+
diff --git a/JiShe.CollectBus.EntityFrameworkCore/AuditLogs/AuditLog.cs b/JiShe.CollectBus.EntityFrameworkCore/AuditLogs/AuditLog.cs
new file mode 100644
index 0000000..28faa98
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/AuditLogs/AuditLog.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JiShe.CollectBus.EntityFrameworkCore.Entities;
+
+namespace JiShe.CollectBus.EntityFrameworkCore.AuditLogs
+{
+ public class AuditLog : EntityBase,ICreationAudited
+ {
+ public string Re
+ public long? CreatorId { get; set; }
+ public DateTime CreationTime { get; set; }
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/CollectBusDbContext.cs b/JiShe.CollectBus.EntityFrameworkCore/CollectBusDbContext.cs
new file mode 100644
index 0000000..0a1cb22
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/CollectBusDbContext.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
+
+namespace JiShe.CollectBus.EntityFrameworkCore
+{
+ public class CollectBusDbContext : DbContext
+ {
+ private readonly IConfiguration _configuration;
+
+
+ private DbSet Devices { set; get; }
+
+ public CollectBusDbContext(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ }
+
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseMySql(_configuration.GetConnectionString("Default"),ServerVersion.AutoDetect(_configuration.GetConnectionString("Default")));
+ }
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Device.cs b/JiShe.CollectBus.EntityFrameworkCore/Device.cs
new file mode 100644
index 0000000..853de5c
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/Device.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JiShe.CollectBus.EntityFrameworkCore.Entities;
+
+namespace JiShe.CollectBus.EntityFrameworkCore
+{
+ public class Device : EntityBase, ICreationAudited, IModificationAudited
+ {
+ public string DeviceNo { get; set; }
+ public DeviceStatusEnum DeviceStatus { get; set; }
+ public long? CreatorId { get; set; }
+ public DateTime CreationTime { get; set; }
+ public long? LastModifierId { get; set; }
+ public DateTime? LastModificationTime { get; set; }
+ }
+
+ public enum DeviceStatusEnum
+ {
+ Unknown = 0,
+ Online = 1,
+ Offline = 2,
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/JiShe.CollectBus.EntityFrameworkCore.csproj b/JiShe.CollectBus.EntityFrameworkCore/JiShe.CollectBus.EntityFrameworkCore.csproj
index dc31f27..a5d38eb 100644
--- a/JiShe.CollectBus.EntityFrameworkCore/JiShe.CollectBus.EntityFrameworkCore.csproj
+++ b/JiShe.CollectBus.EntityFrameworkCore/JiShe.CollectBus.EntityFrameworkCore.csproj
@@ -8,7 +8,12 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.Designer.cs b/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.Designer.cs
new file mode 100644
index 0000000..f235302
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.Designer.cs
@@ -0,0 +1,60 @@
+//
+using System;
+using JiShe.CollectBus.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace JiShe.CollectBus.EntityFrameworkCore.Migrations
+{
+ [DbContext(typeof(CollectBusDbContext))]
+ [Migration("20241022055227_Init")]
+ partial class Init
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
+
+ modelBuilder.Entity("JiShe.CollectBus.EntityFrameworkCore.Device", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnType("bigint");
+
+ b.Property("DeviceNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("DeviceStatus")
+ .HasColumnType("int");
+
+ b.Property("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.ToTable("Devices");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.cs b/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.cs
new file mode 100644
index 0000000..c6a8a4f
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/Migrations/20241022055227_Init.cs
@@ -0,0 +1,44 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace JiShe.CollectBus.EntityFrameworkCore.Migrations
+{
+ ///
+ public partial class Init : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Devices",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ DeviceNo = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ DeviceStatus = table.Column(type: "int", nullable: false),
+ CreatorId = table.Column(type: "bigint", nullable: true),
+ CreationTime = table.Column(type: "datetime(6)", nullable: false),
+ LastModifierId = table.Column(type: "bigint", nullable: true),
+ LastModificationTime = table.Column(type: "datetime(6)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Devices", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Devices");
+ }
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Migrations/CollectBusDbContextModelSnapshot.cs b/JiShe.CollectBus.EntityFrameworkCore/Migrations/CollectBusDbContextModelSnapshot.cs
new file mode 100644
index 0000000..6976aaf
--- /dev/null
+++ b/JiShe.CollectBus.EntityFrameworkCore/Migrations/CollectBusDbContextModelSnapshot.cs
@@ -0,0 +1,57 @@
+//
+using System;
+using JiShe.CollectBus.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace JiShe.CollectBus.EntityFrameworkCore.Migrations
+{
+ [DbContext(typeof(CollectBusDbContext))]
+ partial class CollectBusDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
+
+ modelBuilder.Entity("JiShe.CollectBus.EntityFrameworkCore.Device", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatorId")
+ .HasColumnType("bigint");
+
+ b.Property("DeviceNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("DeviceStatus")
+ .HasColumnType("int");
+
+ b.Property("LastModificationTime")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastModifierId")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.ToTable("Devices");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Repositories/IRepository.cs b/JiShe.CollectBus.EntityFrameworkCore/Repositories/IRepository.cs
index 65c95fd..8f3a2f0 100644
--- a/JiShe.CollectBus.EntityFrameworkCore/Repositories/IRepository.cs
+++ b/JiShe.CollectBus.EntityFrameworkCore/Repositories/IRepository.cs
@@ -8,7 +8,7 @@ using JiShe.CollectBus.EntityFrameworkCore.Entities;
namespace JiShe.CollectBus.EntityFrameworkCore.Repositories
{
- public interface IRepository where TEntity : class, IEntity
+ public interface IRepository where TEntity : class, IEntity
{
IQueryable GetAll(params Expression>[] propertySelectors);
diff --git a/JiShe.CollectBus.EntityFrameworkCore/Repositories/Repository.cs b/JiShe.CollectBus.EntityFrameworkCore/Repositories/Repository.cs
index ce1ad5e..5d12a8a 100644
--- a/JiShe.CollectBus.EntityFrameworkCore/Repositories/Repository.cs
+++ b/JiShe.CollectBus.EntityFrameworkCore/Repositories/Repository.cs
@@ -10,15 +10,14 @@ using Microsoft.EntityFrameworkCore;
namespace JiShe.CollectBus.EntityFrameworkCore.Repositories
{
- public class Repository : IRepository
+ public class Repository : IRepository
where TEntity : class, IEntity
- where TDbContext : DbContext
{
- public virtual DbContext DbContext { private set; get; }
+ public virtual CollectBusDbContext DbContext { private set; get; }
public virtual DbSet Table => DbContext.Set();
- public Repository(DbContext dbContext)
+ public Repository(CollectBusDbContext dbContext)
{
DbContext = dbContext;
}
diff --git a/JiShe.CollectBus.Protocol.Contracts/JiShe.CollectBus.Protocol.Contracts.csproj b/JiShe.CollectBus.Protocol.Contracts/JiShe.CollectBus.Protocol.Contracts.csproj
index 2434590..79afffb 100644
--- a/JiShe.CollectBus.Protocol.Contracts/JiShe.CollectBus.Protocol.Contracts.csproj
+++ b/JiShe.CollectBus.Protocol.Contracts/JiShe.CollectBus.Protocol.Contracts.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj b/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj
index f260732..708f4a0 100644
--- a/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj
+++ b/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj
@@ -8,7 +8,7 @@
-
+