feat: 添加用户积分
parent
f1e31e04e2
commit
4dd08f59fd
|
|
@ -0,0 +1,19 @@
|
||||||
|
namespace UserPointManagement.Model.Entities;
|
||||||
|
|
||||||
|
public class UserPoint
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int Point { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreateTime { get; }
|
||||||
|
|
||||||
|
public UserPoint(int userId, int point)
|
||||||
|
{
|
||||||
|
UserId = userId;
|
||||||
|
Point = point;
|
||||||
|
CreateTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using UserPointManagement.Model.Entities;
|
||||||
|
|
||||||
|
namespace UserPointManagement.Persistence.EntityTypeConfigurations;
|
||||||
|
|
||||||
|
public class UserPointConfiguration : IEntityTypeConfiguration<UserPoint>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<UserPoint> builder)
|
||||||
|
{
|
||||||
|
builder.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
builder.Property(e => e.Id)
|
||||||
|
.HasComment("主键");
|
||||||
|
|
||||||
|
builder.Property(e => e.UserId)
|
||||||
|
.HasComment("用户Id");
|
||||||
|
|
||||||
|
builder.Property(e => e.Point)
|
||||||
|
.HasComment("积分");
|
||||||
|
|
||||||
|
builder.Property(e => e.CreateTime)
|
||||||
|
.HasComment("新增时间");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
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("20230729051855_AddUserPoint")]
|
||||||
|
partial class AddUserPoint
|
||||||
|
{
|
||||||
|
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<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasComment("主键");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Mobile")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(30)
|
||||||
|
.HasColumnType("character varying(30)")
|
||||||
|
.HasColumnName("mobile")
|
||||||
|
.HasComment("手机号");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasComment("姓名");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user");
|
||||||
|
|
||||||
|
b.ToTable("user", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UserPointManagement.Model.Entities.UserPoint", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasComment("主键");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateTime")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("create_time")
|
||||||
|
.HasComment("新增时间");
|
||||||
|
|
||||||
|
b.Property<int>("Point")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("point")
|
||||||
|
.HasComment("积分");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id")
|
||||||
|
.HasComment("用户Id");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user_point");
|
||||||
|
|
||||||
|
b.ToTable("user_point", (string)null);
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace UserPointManagement.Persistence.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddUserPoint : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_point",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(type: "bigint", nullable: false, comment: "主键")
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
user_id = table.Column<int>(type: "integer", nullable: false, comment: "用户Id"),
|
||||||
|
point = table.Column<int>(type: "integer", nullable: false, comment: "积分"),
|
||||||
|
create_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "新增时间")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user_point", x => x.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_point");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
@ -50,6 +51,37 @@ namespace UserPointManagement.Persistence.Migrations
|
||||||
|
|
||||||
b.ToTable("user", (string)null);
|
b.ToTable("user", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UserPointManagement.Model.Entities.UserPoint", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasComment("主键");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateTime")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("create_time")
|
||||||
|
.HasComment("新增时间");
|
||||||
|
|
||||||
|
b.Property<int>("Point")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("point")
|
||||||
|
.HasComment("积分");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id")
|
||||||
|
.HasComment("用户Id");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user_point");
|
||||||
|
|
||||||
|
b.ToTable("user_point", (string)null);
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,12 @@ public class UserPointManagementDbContext : Microsoft.EntityFrameworkCore.DbCont
|
||||||
|
|
||||||
public virtual DbSet<User> Users { get; set; }
|
public virtual DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<UserPoint> UserPoints { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.SnakeCaseTableNameConvention();
|
modelBuilder.SnakeCaseTableNameConvention();
|
||||||
modelBuilder.ApplyConfiguration(new UserConfiguration());
|
modelBuilder.ApplyConfiguration(new UserConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new UserPointConfiguration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,6 +26,13 @@
|
||||||
Name = "用户管理",
|
Name = "用户管理",
|
||||||
Key = "user",
|
Key = "user",
|
||||||
Icon = "smile",
|
Icon = "smile",
|
||||||
|
},
|
||||||
|
new MenuDataItem
|
||||||
|
{
|
||||||
|
Path = "/user-point",
|
||||||
|
Name = "用户积分",
|
||||||
|
Key = "user-point",
|
||||||
|
Icon = "smile",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
@page "/user-point"
|
||||||
|
<PageContainer Title="用户积分">
|
||||||
|
|
||||||
|
</PageContainer>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue