mirror of https://github.com/abpframework/abp.git
21 changed files with 381 additions and 26 deletions
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.Json; |
||||
|
|
||||
|
namespace BackendAdminApp.Host.Controllers |
||||
|
{ |
||||
|
public class TestController : AbpController |
||||
|
{ |
||||
|
private readonly IJsonSerializer _jsonSerializer; |
||||
|
|
||||
|
public TestController(IJsonSerializer jsonSerializer) |
||||
|
{ |
||||
|
_jsonSerializer = jsonSerializer; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult> Index() |
||||
|
{ |
||||
|
var newLine = Environment.NewLine + Environment.NewLine; |
||||
|
|
||||
|
return Content( |
||||
|
"Claims: " + User.Claims.Select(c => $"{c.Type} = {c.Value}").JoinAsString(" | ") + newLine + |
||||
|
"CurrentUser: " + _jsonSerializer.Serialize(CurrentUser) + newLine |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace ProductService.Host.Controllers |
||||
|
{ |
||||
|
public class HomeController : AbpController |
||||
|
{ |
||||
|
public ActionResult Index() |
||||
|
{ |
||||
|
return Redirect("/swagger"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System.IO; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
|
||||
|
namespace ProductService.Host.EntityFrameworkCore |
||||
|
{ |
||||
|
public class ProductServiceMigrationDbContextFactory : IDesignTimeDbContextFactory<ProductServiceMigrationDbContext> |
||||
|
{ |
||||
|
public ProductServiceMigrationDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
var configuration = BuildConfiguration(); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<ProductServiceMigrationDbContext>() |
||||
|
.UseSqlServer(configuration.GetConnectionString("ProductManagement")); |
||||
|
|
||||
|
return new ProductServiceMigrationDbContext(builder.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using ProductManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace ProductService.Host.EntityFrameworkCore |
||||
|
{ |
||||
|
public class ProductServiceMigrationDbContext : AbpDbContext<ProductServiceMigrationDbContext> |
||||
|
{ |
||||
|
public ProductServiceMigrationDbContext( |
||||
|
DbContextOptions<ProductServiceMigrationDbContext> options |
||||
|
) : base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureProductManagement(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,71 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using ProductService.Host.EntityFrameworkCore; |
||||
|
|
||||
|
namespace ProductService.Host.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(ProductServiceMigrationDbContext))] |
||||
|
[Migration("20190121115908_Initial")] |
||||
|
partial class Initial |
||||
|
{ |
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
modelBuilder.Entity("ProductManagement.Product", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd(); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(32); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256); |
||||
|
|
||||
|
b.Property<float>("Price"); |
||||
|
|
||||
|
b.Property<int>("StockCount"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Code"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("PmProducts"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace ProductService.Host.Migrations |
||||
|
{ |
||||
|
public partial class Initial : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "PmProducts", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(nullable: false), |
||||
|
ExtraProperties = table.Column<string>(nullable: true), |
||||
|
ConcurrencyStamp = table.Column<string>(nullable: true), |
||||
|
CreationTime = table.Column<DateTime>(nullable: false), |
||||
|
CreatorId = table.Column<Guid>(nullable: true), |
||||
|
LastModificationTime = table.Column<DateTime>(nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(nullable: true), |
||||
|
Code = table.Column<string>(maxLength: 32, nullable: false), |
||||
|
Name = table.Column<string>(maxLength: 256, nullable: false), |
||||
|
Price = table.Column<float>(nullable: false), |
||||
|
StockCount = table.Column<int>(nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_PmProducts", x => x.Id); |
||||
|
}); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_PmProducts_Code", |
||||
|
table: "PmProducts", |
||||
|
column: "Code"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_PmProducts_Name", |
||||
|
table: "PmProducts", |
||||
|
column: "Name"); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "PmProducts"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using ProductService.Host.EntityFrameworkCore; |
||||
|
|
||||
|
namespace ProductService.Host.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(ProductServiceMigrationDbContext))] |
||||
|
partial class ProductServiceMigrationDbContextModelSnapshot : ModelSnapshot |
||||
|
{ |
||||
|
protected override void BuildModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
modelBuilder.Entity("ProductManagement.Product", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd(); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(32); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256); |
||||
|
|
||||
|
b.Property<float>("Price"); |
||||
|
|
||||
|
b.Property<int>("StockCount"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Code"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("PmProducts"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue