-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba112d3
commit 2e7fab4
Showing
16 changed files
with
455 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
|
||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> | ||
<connectionStrings> | ||
<add name="Default" connectionString="Database=OAuthServer;Persist Security Info=True;User ID=sa;Password=123456;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> | ||
</connectionStrings> | ||
<entityFramework> | ||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> | ||
<parameters> | ||
<parameter value="mssqllocaldb" /> | ||
</parameters> | ||
</defaultConnectionFactory> | ||
<providers> | ||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> | ||
</providers> | ||
</entityFramework> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using EntityFrameWork.Server.Entity.Auth; | ||
using EntityFrameWork.Server.Migrations; | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Data.Entity; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity | ||
{ | ||
public class AppDbContext:IdentityDbContext<AppUser,AppRole,Guid,AppUserLogin,AppUserRole,AppUserClaim> | ||
{ | ||
public AppDbContext():base(nameOrConnectionString:"Default") | ||
{ | ||
|
||
} | ||
|
||
protected override void OnModelCreating(DbModelBuilder modelBuilder) | ||
{ | ||
base.OnModelCreating(modelBuilder); | ||
Database.SetInitializer(new MigrateDatabaseToLatestVersion<AppDbContext, Configuration>()); | ||
|
||
//用户 | ||
modelBuilder.Entity<AppUser>().HasKey(k => new { k.Id }); | ||
modelBuilder.Entity<AppUser>().Property(k => k.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); | ||
|
||
//角色 | ||
modelBuilder.Entity<AppRole>().HasKey(k => new { k.Id }); | ||
modelBuilder.Entity<AppRole>().Property(k => k.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); | ||
modelBuilder.Entity<AppRole>().Property(k => k.Name).HasMaxLength(20).IsRequired().IsUnicode(); | ||
|
||
//用户角色 | ||
modelBuilder.Entity<AppUserRole>().HasKey(k => new { k.RoleId, k.UserId }); | ||
modelBuilder.Entity<AppUserRole>().HasRequired(k => k.AppRole).WithMany(k => k.AppUserRole).HasForeignKey(k => k.RoleId).WillCascadeOnDelete(true); | ||
modelBuilder.Entity<AppUserRole>().HasRequired(k => k.AppUser).WithMany(k => k.AppUserRole).HasForeignKey(k => k.UserId).WillCascadeOnDelete(true); | ||
|
||
//菜单 属性 | ||
modelBuilder.Entity<AppMenu>().HasKey(k => k.ID); | ||
modelBuilder.Entity<AppMenu>().Property(k => k.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); | ||
modelBuilder.Entity<AppMenu>().Property(p => p.Name).IsUnicode().IsRequired().HasMaxLength(20); | ||
modelBuilder.Entity<AppMenu>().Property(p => p.MenuLink).IsUnicode().IsRequired().HasMaxLength(50); | ||
modelBuilder.Entity<AppMenu>().Property(p => p.MenuIcon).IsUnicode().HasMaxLength(20); | ||
modelBuilder.Entity<AppMenu>().Property(p => p.ActionName).IsUnicode().IsRequired().HasMaxLength(20); | ||
modelBuilder.Entity<AppMenu>().Property(p => p.ControlName).IsUnicode().IsRequired().HasMaxLength(20); | ||
|
||
//菜单关系 自连接 | ||
modelBuilder.Entity<AppMenu>().HasMany(k => k.ChildrenMenu).WithOptional().HasForeignKey(k => k.ParentID); | ||
|
||
//角色菜单 | ||
modelBuilder.Entity<AppRoleMenu>().HasKey(k=>new { k.MenuID,k.RoleID }); | ||
modelBuilder.Entity<AppRoleMenu>().HasRequired(m => m.AppMenu).WithMany(m => m.RoleMenu).HasForeignKey(k => k.MenuID);//.WillCascadeOnDelete(true); | ||
modelBuilder.Entity<AppRoleMenu>().HasRequired(m => m.AppRole).WithMany(m => m.AppRoleMenu).HasForeignKey(k => k.RoleID);//.WillCascadeOnDelete(true); | ||
|
||
|
||
|
||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
/// <summary> | ||
/// 系统菜单 [key]数据注释 | ||
/// </summary> | ||
public class AppMenu | ||
{ | ||
/// <summary> | ||
/// id | ||
/// </summary> | ||
/// | ||
public Guid ID { get; set; } | ||
|
||
/// <summary> | ||
/// 名称 | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// 控制器名字 | ||
/// </summary> | ||
public string ControlName { get; set; } | ||
|
||
/// <summary> | ||
/// Action名字 | ||
/// </summary> | ||
public string ActionName { get; set; } | ||
|
||
/// <summary> | ||
/// 菜单链接 | ||
/// </summary> | ||
public string MenuLink { get; set; } | ||
|
||
/// <summary> | ||
/// 菜单图标 | ||
/// </summary> | ||
public string MenuIcon { get; set; } | ||
|
||
/// <summary> | ||
/// 父级ID | ||
/// </summary> | ||
public Guid? ParentID { get; set; } | ||
|
||
/// <summary> | ||
/// 角色菜单级联 | ||
/// </summary> | ||
public ICollection<AppRoleMenu> RoleMenu { get; set; } | ||
|
||
//public virtual AppMenu FatherMenu { get; set; } | ||
|
||
/// <summary> | ||
/// 自连接-->子级菜单 | ||
/// </summary> | ||
public ICollection<AppMenu> ChildrenMenu { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
/// <summary> | ||
/// 用户角色、继承与IdentityRole | ||
/// </summary> | ||
public class AppRole : IdentityRole<Guid, AppUserRole> | ||
{ | ||
/// <summary> | ||
/// 相关用户角色 | ||
/// </summary> | ||
public ICollection<AppUserRole> AppUserRole { get; set; } | ||
|
||
/// <summary> | ||
/// 相关角色菜单 | ||
/// </summary> | ||
public ICollection<AppRoleMenu> AppRoleMenu { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
public class AppRoleMenu | ||
{ | ||
public Guid RoleID { get; set; } | ||
public Guid MenuID { get; set; } | ||
|
||
public AppRole AppRole { get; set; } | ||
|
||
public AppMenu AppMenu { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
public class AppUser : IdentityUser<Guid, AppUserLogin, AppUserRole, AppUserClaim> | ||
{ | ||
public override Guid Id { get => base.Id; set => base.Id = value; } | ||
|
||
public ICollection<AppUserRole> AppUserRole { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
public class AppUserClaim : IdentityUserClaim<Guid> | ||
{ | ||
public override int Id { get => base.Id; set => base.Id = value; } | ||
public override Guid UserId { get => base.UserId; set => base.UserId = value; } | ||
public override string ClaimType { get => base.ClaimType; set => base.ClaimType = value; } | ||
public override string ClaimValue { get => base.ClaimValue; set => base.ClaimValue = value; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
public class AppUserLogin : IdentityUserLogin<Guid> | ||
{ | ||
public override Guid UserId { get => base.UserId; set => base.UserId = value; } | ||
|
||
public override string ProviderKey { get => base.ProviderKey; set => base.ProviderKey = value; } | ||
|
||
public override string LoginProvider { get => base.LoginProvider; set => base.LoginProvider = value; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.AspNet.Identity.EntityFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EntityFrameWork.Server.Entity.Auth | ||
{ | ||
public class AppUserRole : IdentityUserRole<Guid> | ||
{ | ||
public override Guid RoleId { get => base.RoleId; set => base.RoleId = value; } | ||
public override Guid UserId { get => base.UserId; set => base.UserId = value; } | ||
public AppUser AppUser { get; set; } | ||
|
||
public AppRole AppRole { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>EntityFrameWork.Server</RootNamespace> | ||
<AssemblyName>EntityFrameWork.Server</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> | ||
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> | ||
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.AspNet.Identity.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>packages\Microsoft.AspNet.Identity.Core.2.2.2\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>packages\Microsoft.AspNet.Identity.EntityFramework.2.2.2\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Entity\AppDbContext.cs" /> | ||
<Compile Include="Entity\Auth\AppMenu.cs" /> | ||
<Compile Include="Entity\Auth\AppRole.cs" /> | ||
<Compile Include="Entity\Auth\AppRoleMenu.cs" /> | ||
<Compile Include="Entity\Auth\AppUser.cs" /> | ||
<Compile Include="Entity\Auth\AppUserClaim.cs" /> | ||
<Compile Include="Entity\Auth\AppUserLogin.cs" /> | ||
<Compile Include="Entity\Auth\AppUserRole.cs" /> | ||
<Compile Include="Migrations\Configuration.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SeedData.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="readme.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.438 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameWork.Server", "EntityFrameWork.Server.csproj", "{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OAuthServer", "..\OAuthServer\OAuthServer.csproj", "{E0617006-5156-4512-B789-EE55628CB7E8}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{97C223CF-B5E8-4B57-AACC-AF4162A4FCFC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E0617006-5156-4512-B789-EE55628CB7E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E0617006-5156-4512-B789-EE55628CB7E8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E0617006-5156-4512-B789-EE55628CB7E8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E0617006-5156-4512-B789-EE55628CB7E8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {9BBE4420-97BE-452C-8CE5-8BF055EDF1B8} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.