diff --git a/src/UserPointManagement.Application/Services/UserPointService.cs b/src/UserPointManagement.Application/Services/UserPointService.cs
index 39afa77..bead2cd 100644
--- a/src/UserPointManagement.Application/Services/UserPointService.cs
+++ b/src/UserPointManagement.Application/Services/UserPointService.cs
@@ -32,7 +32,8 @@ public class UserPointService : IUserPointService
UserPointId = userPoint.Id,
UserId = user.Id,
Name = user.Name,
- Point = userPoint.Point
+ Point = userPoint.Point,
+ CreateTime = userPoint.CreateTime
};
var count = queryable.Count();
diff --git a/src/UserPointManagement.Model/Entities/UserPoint.cs b/src/UserPointManagement.Model/Entities/UserPoint.cs
index 1359b09..b8b2470 100644
--- a/src/UserPointManagement.Model/Entities/UserPoint.cs
+++ b/src/UserPointManagement.Model/Entities/UserPoint.cs
@@ -14,6 +14,6 @@ public class UserPoint
{
UserId = userId;
Point = point;
- CreateTime = DateTime.UtcNow;
+ CreateTime = DateTime.Now;
}
}
\ No newline at end of file
diff --git a/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.Designer.cs b/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.Designer.cs
deleted file mode 100644
index 12afa0b..0000000
--- a/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.Designer.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using UserPointManagement.Persistence;
-
-#nullable disable
-
-namespace UserPointManagement.Persistence.Migrations
-{
- [DbContext(typeof(UserPointManagementDbContext))]
- [Migration("20230728165153_Initial")]
- partial class Initial
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "6.0.0")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("UserPointManagement.Model.Entities.User", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id")
- .HasComment("主键");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("Mobile")
- .IsRequired()
- .HasMaxLength(30)
- .HasColumnType("character varying(30)")
- .HasColumnName("mobile")
- .HasComment("手机号");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)")
- .HasColumnName("name")
- .HasComment("姓名");
-
- b.HasKey("Id")
- .HasName("pk_user");
-
- b.ToTable("user", (string)null);
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.cs b/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.cs
deleted file mode 100644
index 49f9e87..0000000
--- a/src/UserPointManagement.Persistence/Migrations/20230728165153_Initial.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace UserPointManagement.Persistence.Migrations
-{
- public partial class Initial : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "user",
- columns: table => new
- {
- id = table.Column(type: "integer", nullable: false, comment: "主键")
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false, comment: "姓名"),
- mobile = table.Column(type: "character varying(30)", maxLength: 30, nullable: false, comment: "手机号")
- },
- constraints: table =>
- {
- table.PrimaryKey("pk_user", x => x.id);
- });
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "user");
- }
- }
-}
diff --git a/src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.Designer.cs b/src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.Designer.cs
similarity index 95%
rename from src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.Designer.cs
rename to src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.Designer.cs
index c2b90c4..db21540 100644
--- a/src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.Designer.cs
+++ b/src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.Designer.cs
@@ -12,8 +12,8 @@ using UserPointManagement.Persistence;
namespace UserPointManagement.Persistence.Migrations
{
[DbContext(typeof(UserPointManagementDbContext))]
- [Migration("20230729051855_AddUserPoint")]
- partial class AddUserPoint
+ [Migration("20230730041015_Initial")]
+ partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -65,7 +65,7 @@ namespace UserPointManagement.Persistence.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreateTime")
- .HasColumnType("timestamp with time zone")
+ .HasColumnType("timestamp without time zone")
.HasColumnName("create_time")
.HasComment("新增时间");
diff --git a/src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.cs b/src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.cs
similarity index 56%
rename from src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.cs
rename to src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.cs
index 49cd731..1329403 100644
--- a/src/UserPointManagement.Persistence/Migrations/20230729051855_AddUserPoint.cs
+++ b/src/UserPointManagement.Persistence/Migrations/20230730041015_Initial.cs
@@ -6,10 +6,24 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace UserPointManagement.Persistence.Migrations
{
- public partial class AddUserPoint : Migration
+ public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.CreateTable(
+ name: "user",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false, comment: "主键")
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false, comment: "姓名"),
+ mobile = table.Column(type: "character varying(30)", maxLength: 30, nullable: false, comment: "手机号")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("pk_user", x => x.id);
+ });
+
migrationBuilder.CreateTable(
name: "user_point",
columns: table => new
@@ -18,7 +32,7 @@ namespace UserPointManagement.Persistence.Migrations
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
user_id = table.Column(type: "integer", nullable: false, comment: "用户Id"),
point = table.Column(type: "integer", nullable: false, comment: "积分"),
- create_time = table.Column(type: "timestamp with time zone", nullable: false, comment: "新增时间")
+ create_time = table.Column(type: "timestamp without time zone", nullable: false, comment: "新增时间")
},
constraints: table =>
{
@@ -28,6 +42,9 @@ namespace UserPointManagement.Persistence.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.DropTable(
+ name: "user");
+
migrationBuilder.DropTable(
name: "user_point");
}
diff --git a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs
index 8a3c442..ff15431 100644
--- a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs
+++ b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs
@@ -63,7 +63,7 @@ namespace UserPointManagement.Persistence.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreateTime")
- .HasColumnType("timestamp with time zone")
+ .HasColumnType("timestamp without time zone")
.HasColumnName("create_time")
.HasComment("新增时间");
diff --git a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs
index f8cdfdb..6edfa7e 100644
--- a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs
+++ b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs
@@ -12,6 +12,9 @@ public class UserPointManagementDbContextFactory : IDesignTimeDbContextFactory
+
diff --git a/src/UserPointManagement.Web/Startup.cs b/src/UserPointManagement.Web/Startup.cs
index 00307f6..4271cda 100644
--- a/src/UserPointManagement.Web/Startup.cs
+++ b/src/UserPointManagement.Web/Startup.cs
@@ -43,6 +43,9 @@ namespace UserPointManagement.Web
BaseAddress = new Uri(sp.GetService().BaseUri)
});
services.Configure(Configuration.GetSection("ProSettings"));
+
+ AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
+ AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.