mirror of https://github.com/abpframework/abp.git
21 changed files with 585 additions and 15 deletions
@ -0,0 +1,128 @@ |
|||
// <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 Volo.BloggingTestApp.EntityFrameworkCore; |
|||
|
|||
namespace Volo.BloggingTestApp.EntityFrameworkCore.Migrations |
|||
{ |
|||
[DbContext(typeof(BloggingTestAppDbContext))] |
|||
[Migration("20180621080811_Added_Blog_And_Post")] |
|||
partial class Added_Blog_And_Post |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.1.0-rtm-30799") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Blogs.Blog", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnName("Description") |
|||
.HasMaxLength(1024); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnName("IsDeleted") |
|||
.HasDefaultValue(false); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnName("Name") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<string>("ShortName") |
|||
.IsRequired() |
|||
.HasColumnName("ShortName") |
|||
.HasMaxLength(32); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("BlgBlogs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Posts.Post", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<Guid>("BlogId") |
|||
.HasColumnName("BlogId"); |
|||
|
|||
b.Property<string>("Content") |
|||
.HasColumnName("Content") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnName("IsDeleted") |
|||
.HasDefaultValue(false); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Title") |
|||
.IsRequired() |
|||
.HasColumnName("Title") |
|||
.HasMaxLength(512); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("BlogId"); |
|||
|
|||
b.ToTable("BlgPosts"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Posts.Post", b => |
|||
{ |
|||
b.HasOne("Volo.Blogging.Blogs.Blog") |
|||
.WithMany() |
|||
.HasForeignKey("BlogId") |
|||
.OnDelete(DeleteBehavior.Cascade); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.BloggingTestApp.EntityFrameworkCore.Migrations |
|||
{ |
|||
public partial class Added_Blog_And_Post : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "BlgBlogs", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
CreationTime = table.Column<DateTime>(nullable: false), |
|||
CreatorId = table.Column<Guid>(nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(nullable: true), |
|||
LastModifierId = table.Column<Guid>(nullable: true), |
|||
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(nullable: true), |
|||
DeletionTime = table.Column<DateTime>(nullable: true), |
|||
Name = table.Column<string>(maxLength: 256, nullable: false), |
|||
ShortName = table.Column<string>(maxLength: 32, nullable: false), |
|||
Description = table.Column<string>(maxLength: 1024, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_BlgBlogs", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "BlgPosts", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
CreationTime = table.Column<DateTime>(nullable: false), |
|||
CreatorId = table.Column<Guid>(nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(nullable: true), |
|||
LastModifierId = table.Column<Guid>(nullable: true), |
|||
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(nullable: true), |
|||
DeletionTime = table.Column<DateTime>(nullable: true), |
|||
BlogId = table.Column<Guid>(nullable: false), |
|||
Title = table.Column<string>(maxLength: 512, nullable: false), |
|||
Content = table.Column<string>(maxLength: 1048576, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_BlgPosts", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_BlgPosts_BlgBlogs_BlogId", |
|||
column: x => x.BlogId, |
|||
principalTable: "BlgBlogs", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_BlgPosts_BlogId", |
|||
table: "BlgPosts", |
|||
column: "BlogId"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "BlgPosts"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "BlgBlogs"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,126 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.BloggingTestApp.EntityFrameworkCore; |
|||
|
|||
namespace Volo.BloggingTestApp.EntityFrameworkCore.Migrations |
|||
{ |
|||
[DbContext(typeof(BloggingTestAppDbContext))] |
|||
partial class BloggingTestAppDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.1.0-rtm-30799") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Blogs.Blog", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnName("Description") |
|||
.HasMaxLength(1024); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnName("IsDeleted") |
|||
.HasDefaultValue(false); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnName("Name") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<string>("ShortName") |
|||
.IsRequired() |
|||
.HasColumnName("ShortName") |
|||
.HasMaxLength(32); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("BlgBlogs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Posts.Post", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<Guid>("BlogId") |
|||
.HasColumnName("BlogId"); |
|||
|
|||
b.Property<string>("Content") |
|||
.HasColumnName("Content") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnName("IsDeleted") |
|||
.HasDefaultValue(false); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Title") |
|||
.IsRequired() |
|||
.HasColumnName("Title") |
|||
.HasMaxLength(512); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("BlogId"); |
|||
|
|||
b.ToTable("BlgPosts"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Blogging.Posts.Post", b => |
|||
{ |
|||
b.HasOne("Volo.Blogging.Blogs.Blog") |
|||
.WithMany() |
|||
.HasForeignKey("BlogId") |
|||
.OnDelete(DeleteBehavior.Cascade); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.Blogging.Blogs |
|||
{ |
|||
public class BlogDto : EntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string ShortName { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
namespace Volo.Blogging.Blogs |
|||
{ |
|||
public static class BlogConsts |
|||
{ |
|||
public const int MaxNameLength = 256; |
|||
|
|||
public const int MaxShortNameLength = 32; |
|||
|
|||
public const int MaxDescriptionLength = 1024; |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace Volo.Blogging.Posts |
|||
{ |
|||
public static class PostConsts |
|||
{ |
|||
public const int MaxTitleLength = 512; |
|||
|
|||
public const int MaxContentLength = 1024 * 1024; //1MB
|
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Volo.Blogging.Blogs |
|||
{ |
|||
public class Blog : FullAuditedAggregateRoot<Guid> |
|||
{ |
|||
[NotNull] |
|||
public virtual string Name { get; protected set; } |
|||
|
|||
[NotNull] |
|||
public virtual string ShortName { get; protected set; } |
|||
|
|||
[CanBeNull] |
|||
public virtual string Description { get; set; } |
|||
|
|||
protected Blog() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public Blog(Guid id, [NotNull] string name, [NotNull] string shortName) |
|||
{ |
|||
Id = id; |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
|||
ShortName = Check.NotNullOrWhiteSpace(shortName, nameof(shortName)); |
|||
} |
|||
|
|||
public virtual Blog SetName([NotNull] string name) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
|||
return this; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Volo.Blogging.Posts |
|||
{ |
|||
public class Post : FullAuditedAggregateRoot<Guid> |
|||
{ |
|||
public virtual Guid BlogId { get; protected set; } |
|||
|
|||
[NotNull] |
|||
public virtual string Title { get; protected set; } |
|||
|
|||
[CanBeNull] |
|||
public virtual string Content { get; set; } |
|||
|
|||
protected Post() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public Post(Guid id, Guid blogId, Guid creatorId, [NotNull] string title) |
|||
{ |
|||
Id = id; |
|||
CreatorId = creatorId; |
|||
BlogId = blogId; |
|||
Title = Check.NotNullOrWhiteSpace(title, nameof(title)); |
|||
} |
|||
|
|||
public virtual Post SetTitle([NotNull] string title) |
|||
{ |
|||
Title = Check.NotNullOrWhiteSpace(title, nameof(title)); |
|||
return this; |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +1,16 @@ |
|||
using Volo.Abp.Data; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Blogging.Blogs; |
|||
using Volo.Blogging.Posts; |
|||
|
|||
namespace Volo.Blogging.EntityFrameworkCore |
|||
{ |
|||
[ConnectionStringName("Blogging")] |
|||
public interface IBloggingDbContext : IEfCoreDbContext |
|||
{ |
|||
|
|||
DbSet<Blog> Blogs { get; set; } |
|||
|
|||
DbSet<Post> Posts { get; set; } |
|||
} |
|||
} |
|||
@ -1,8 +1,18 @@ |
|||
@page |
|||
@using Volo.Blogging.Pages.Blog |
|||
@*inherits BloggingPage*@ |
|||
@model IndexModel |
|||
@{ |
|||
} |
|||
<h2> |
|||
Hi, I'm the blog module! |
|||
Blogs |
|||
</h2> |
|||
|
|||
<ul> |
|||
@foreach (var blog in Model.Blogs) |
|||
{ |
|||
<li> |
|||
@blog.Name |
|||
</li> |
|||
} |
|||
</ul> |
|||
|
|||
@ -1,11 +1,26 @@ |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
using Volo.Blogging.Blogs; |
|||
|
|||
namespace Volo.Blogging.Pages.Blog |
|||
{ |
|||
public class IndexModel : PageModel |
|||
public class IndexModel : AbpPageModel |
|||
{ |
|||
public void OnGet() |
|||
public List<BlogDto> Blogs { get; private set; } |
|||
|
|||
public IndexModel() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public async Task OnGet() |
|||
{ |
|||
Blogs = new List<BlogDto> |
|||
{ |
|||
new BlogDto {Id = Guid.NewGuid(), Name = "abp", ShortName = "abp", Description = "a b p"} |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
@page |
|||
@using Volo.Blogging.Pages.Blog.Posts |
|||
@model DetailModel |
|||
@{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Blogging.Pages.Blog.Posts |
|||
{ |
|||
public class DetailModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
@page |
|||
@model Volo.Blogging.Pages.Blog.Posts.IndexModel |
|||
@{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Blogging.Pages.Blog.Posts |
|||
{ |
|||
public class IndexModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using Microsoft.AspNetCore.Mvc.Localization; |
|||
using Microsoft.AspNetCore.Mvc.Razor.Internal; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
using Volo.Blogging.Localization; |
|||
|
|||
namespace Volo.Blogging.Pages.Blog |
|||
{ |
|||
public abstract class BloggingPage : AbpPage |
|||
{ |
|||
[RazorInject] |
|||
public IHtmlLocalizer<BloggingResource> L { get; set; } |
|||
|
|||
public const string DefaultTitle = "Blog"; |
|||
|
|||
public string GetTitle(string title = null) |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(title)) |
|||
{ |
|||
return DefaultTitle; |
|||
} |
|||
|
|||
return title; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue