Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion NetCoreBBS.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{94F5C8A4-D158-4A10-AD26-C635A376CC92}"
EndProject
Expand All @@ -12,6 +12,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreBBS", "src\NetCoreBBS\NetCoreBBS.csproj", "{7FEB182D-CFA4-4DA2-A9FF-0ABF794F8A4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\Infrastructure\Infrastructure.csproj", "{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationCore", "src\ApplicationCore\ApplicationCore.csproj", "{65AC78E9-500F-42B5-954D-93F841F5D0F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D25B2B42-A638-4F40-B51C-DCF41A3C8F4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{152AAF50-21A3-477D-BB56-A25E56D4B611}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -22,11 +30,26 @@ Global
{7FEB182D-CFA4-4DA2-A9FF-0ABF794F8A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FEB182D-CFA4-4DA2-A9FF-0ABF794F8A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FEB182D-CFA4-4DA2-A9FF-0ABF794F8A4D}.Release|Any CPU.Build.0 = Release|Any CPU
{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7}.Release|Any CPU.Build.0 = Release|Any CPU
{65AC78E9-500F-42B5-954D-93F841F5D0F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65AC78E9-500F-42B5-954D-93F841F5D0F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65AC78E9-500F-42B5-954D-93F841F5D0F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65AC78E9-500F-42B5-954D-93F841F5D0F1}.Release|Any CPU.Build.0 = Release|Any CPU
{152AAF50-21A3-477D-BB56-A25E56D4B611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{152AAF50-21A3-477D-BB56-A25E56D4B611}.Debug|Any CPU.Build.0 = Debug|Any CPU
{152AAF50-21A3-477D-BB56-A25E56D4B611}.Release|Any CPU.ActiveCfg = Release|Any CPU
{152AAF50-21A3-477D-BB56-A25E56D4B611}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7FEB182D-CFA4-4DA2-A9FF-0ABF794F8A4D} = {94F5C8A4-D158-4A10-AD26-C635A376CC92}
{1AA24171-F5E6-4E7A-B227-A6ECD34DA2E7} = {94F5C8A4-D158-4A10-AD26-C635A376CC92}
{65AC78E9-500F-42B5-954D-93F841F5D0F1} = {94F5C8A4-D158-4A10-AD26-C635A376CC92}
{152AAF50-21A3-477D-BB56-A25E56D4B611} = {D25B2B42-A638-4F40-B51C-DCF41A3C8F4C}
EndGlobalSection
EndGlobal
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# NETCoreBBS
ASP.NET Core Light forum NETCoreBBS

ASP.NET Core 1.0 + EF Core 1.0 Sqlite + Bootstrap
ASP.NET Core + EF Core Sqlite + Bootstrap

.NET Core 跨平台轻论坛

[live demo](http://104.251.232.80/)
[使用技术点介绍](http://www.cnblogs.com/linezero/p/NETCoreBBS.html)

## 开发

1. `git clone https://github.com/linezero/NETCoreBBS.git`
2. 使用 Visual Studio 2017 打开 `NetCoreBBS.sln`
3. 点击 `调试->开始调试` 即可运行起来,或者直接点击工具栏上的`NetCoreBBS`即可。

注意:默认为80端口,可能会和本地端口冲突,可以到Program.cs 中更改 `.UseUrls("http://*:80")`,然后更改启动URL既可。


## 功能

## 已开发
1. 节点功能
1. 主题发布
2. 主题回复
3. 主题筛选
3. 用户登录注册
4. 主题置顶
5. 后台管理
6. 个人中心

## License
NETCoreBBS is licensed under [MIT](LICENSE).
12 changes: 12 additions & 0 deletions src/ApplicationCore/ApplicationCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<RootNamespace>NetCoreBBS</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/ApplicationCore/Entities/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NetCoreBBS.Entities
{
public class BaseEntity
{
public int Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Entities
{
public class Topic
public class Topic:BaseEntity
{
public int Id { get; set; }
public int NodeId { get; set; }
public Guid UserId { get; set; }
[Required]
public TopicNode Node { get; set; }
public string UserId { get; set; }
public User User { get; set; }
public string Email { get; set; }
[Required]
public string Title { get; set; }
[Required]
public string Content { get; set; }
/// <summary>
/// 置顶权重
/// </summary>
public int Top { get; set; }
/// <summary>
/// 精华
/// </summary>
public bool Good { get; set; }
public TopicType Type { get; set; }
public int ViewCount { get; set; }
public int ReplyCount { get; set; }
public Guid LastReplyUserId { get; set; }
public string LastReplyUserId { get; set; }
public User LastReplyUser { get; set; }
public DateTime LastReplyTime { get; set; }
public DateTime CreateOn { get; set; }
public virtual List<TopicReply> Replys { get; set; }
}
public enum TopicType
{
Delete=0,
Normal = 1,
Top=2,
Good=3,
Hot=4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Entities
{
public class TopicNode
public class TopicNode:BaseEntity
{
public int Id { get; set; }
public int ParentId { get; set; }
public string NodeName { get; set; }
public string Name { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Entities
{
public class TopicReply
public class TopicReply:BaseEntity
{
public int Id { get; set; }
public int TopicId { get; set; }
public Guid UserId { get; set; }
[Required]
public string ReplyUserId { get; set; }
public User ReplyUser { get; set; }
public string ReplyEmail { get; set; }
[Required]
public string ReplyContent { get; set; }
public DateTime CreateOn { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Entities
{
public class User: IdentityUser
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Entities
{
public class UserTopic
public class UserCollection:BaseEntity
{
public int Id { get; set; }
public Guid UserId { get; set; }
public string UserId { get; set; }
public int TopicId { get; set; }
public Topic Topic { get; set; }
public int State { get; set; }
public DateTime CreateOn { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/ApplicationCore/Entities/UserMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreBBS.Entities
{
public class UserMessage:BaseEntity
{
public string SendUserId { get; set; }
public User SendUser { get; set; }
public string ReceiveUserId { get; set; }
public User ReceiveUser { get; set; }
public string Type { get; set; }
public string Content { get; set; }
public int State { get; set; }
public DateTime CreateOn { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/ApplicationCore/Interfaces/IRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using NetCoreBBS.Entities;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace NetCoreBBS.Interfaces
{
public interface IRepository<T> where T: BaseEntity
{
T GetById(int id);
IEnumerable<T> List();
IEnumerable<T> List(Expression<Func<T, bool>> predicate);
void Add(T entity);
void Delete(T entity);
void Edit(T entity);
}
}
8 changes: 8 additions & 0 deletions src/ApplicationCore/Interfaces/ITopicReplyRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using NetCoreBBS.Entities;

namespace NetCoreBBS.Interfaces
{
public interface ITopicReplyRepository:IRepository<TopicReply>
{
}
}
14 changes: 14 additions & 0 deletions src/ApplicationCore/Interfaces/ITopicRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using NetCoreBBS.Entities;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace NetCoreBBS.Interfaces
{
public interface ITopicRepository:IRepository<Topic>
{
Page<Topic> PageList(int pagesize,int pageindex);
Page<Topic> PageList(Expression<Func<Topic, bool>> predicate, int pagesize, int pageindex);
}
}
25 changes: 25 additions & 0 deletions src/ApplicationCore/Page.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NetCoreBBS.Entities
{
public class Page<T>
where T : class
{
public int Total { get; private set; }
public int PageSize { get; private set; }
public List<T> List { get; private set; }
public Page(List<T> list, int pageSize, int total)
{
this.List = list;
this.PageSize = pageSize;
this.Total = total;
}

public int GetPageCount()
{
return (Total + PageSize - 1) / PageSize;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NetCoreBBS.Entities;

namespace NetCoreBBS.Models
namespace NetCoreBBS.Infrastructure
{
public class DataContext : IdentityDbContext<User>
{
Expand All @@ -17,7 +18,7 @@ public DataContext(DbContextOptions<DataContext> options)
public DbSet<TopicReply> TopicReplys { get; set; }
public DbSet<TopicNode> TopicNodes { get; set; }
public DbSet<UserMessage> UserMessages { get; set; }
public DbSet<UserTopic> UserTopics { get; set; }
public DbSet<UserCollection> UserTopics { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand All @@ -27,7 +28,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<TopicNode>().ToTable("TopicNode");
modelBuilder.Entity<User>().ToTable("User");
modelBuilder.Entity<UserMessage>().ToTable("UserMessage");
modelBuilder.Entity<UserTopic>().ToTable("UserTopic");
modelBuilder.Entity<UserCollection>().ToTable("UserCollection");
}
}
}
17 changes: 17 additions & 0 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<RootNamespace>NetCoreBBS.Infrastructure</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>

</Project>
Loading