调整了一下项目框架与前端JS代码

This commit is contained in:
yubaolee
2015-09-20 21:59:36 +08:00
parent 2dea364b2b
commit 43f8130e7e
224 changed files with 17851 additions and 3449 deletions

View File

@@ -1,7 +1,13 @@
namespace OpenAuth.Repository
using OpenAuth.Repository.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenAuth.Repository
{
public class BaseRepository
public class BaseRepository
{
protected OpenAuthDBContext _Context = new OpenAuthDBContext();
protected OpenAuthDBContext Context = new OpenAuthDBContext();
}
}

View File

@@ -1,4 +1,4 @@
<connectionStrings>
<connectionStrings>
<add name="OpenAuthDBContext" connectionString="Data Source=.;Initial Catalog=OpenAuthDB;Persist Security Info=True;User ID=sa;Password=516688;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

View File

@@ -1,17 +1,17 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain.Model;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class ButtonMap : EntityTypeConfiguration<Button>
{
public ButtonMap()
{
// Primary Key
this.HasKey(t => t.Id);
this.HasKey(t => t.ButtonId);
// Properties
this.Property(t => t.Id)
this.Property(t => t.ButtonId)
.IsRequired()
.HasMaxLength(50);
@@ -22,7 +22,7 @@ namespace OpenAuth.Repository.Mapping
.HasMaxLength(50);
this.Property(t => t.Event)
.HasMaxLength(200);
.HasMaxLength(50);
this.Property(t => t.Control_ID)
.HasMaxLength(50);
@@ -31,11 +31,11 @@ namespace OpenAuth.Repository.Mapping
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("Button");
this.Property(t => t.Id).HasColumnName("ButtonId");
this.Property(t => t.ButtonId).HasColumnName("ButtonId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Img).HasColumnName("Img");
this.Property(t => t.Event).HasColumnName("Event");

View File

@@ -1,7 +1,7 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain.Model;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class DataPermissionMap : EntityTypeConfiguration<DataPermission>
{
@@ -28,12 +28,6 @@ namespace OpenAuth.Repository.Mapping
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.ResourceId).HasColumnName("ResourceId");
this.Property(t => t.ObjectId).HasColumnName("ObjectId");
// Relationships
this.HasRequired(t => t.Role)
.WithMany(t => t.DataPermissions)
.HasForeignKey(d => d.RoleId);
}
}
}

View File

@@ -1,33 +1,20 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain.Model;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class DepartmentMap : EntityTypeConfiguration<Department>
{
public DepartmentMap()
{
// Primary Key
this.HasKey(t => t.Id);
this.HasKey(t => t.DepartmentId);
// Properties
this.Property(t => t.Id)
this.Property(t => t.DepartmentId)
.IsRequired()
.HasMaxLength(50);
this.HasMany(d => d.Users)
.WithMany(u => u.Departments)
.Map(
m =>
{
m.MapLeftKey("DepartmentId");
m.MapRightKey("UserId");
m.ToTable("UserDepartment");
});
this.HasMany(d => d.Roles)
.WithRequired(r => r.Department);
this.Property(t => t.ParentId)
.HasMaxLength(50);
@@ -39,7 +26,7 @@ namespace OpenAuth.Repository.Mapping
// Table & Column Mappings
this.ToTable("Department");
this.Property(t => t.Id).HasColumnName("DepartmentId");
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Description).HasColumnName("Description");

View File

@@ -0,0 +1,33 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class MenuButtonMap : EntityTypeConfiguration<MenuButton>
{
public MenuButtonMap()
{
// Primary Key
this.HasKey(t => t.MenuButtonId);
// Properties
this.Property(t => t.MenuButtonId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ButtonId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("MenuButton");
this.Property(t => t.MenuButtonId).HasColumnName("MenuButtonId");
this.Property(t => t.MenuId).HasColumnName("MenuId");
this.Property(t => t.ButtonId).HasColumnName("ButtonId");
}
}
}

View File

@@ -1,18 +1,17 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
using OpenAuth.Domain.Model;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class MenuMap : EntityTypeConfiguration<Menu>
{
public MenuMap()
{
// Primary Key
this.HasKey(t => t.Id);
this.HasKey(t => t.MenuId);
// Properties
this.Property(t => t.Id)
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
@@ -23,7 +22,7 @@ namespace OpenAuth.Repository.Mapping
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
.HasMaxLength(50);
this.Property(t => t.Img)
.HasMaxLength(50);
@@ -37,28 +36,9 @@ namespace OpenAuth.Repository.Mapping
this.Property(t => t.Target)
.HasMaxLength(50);
//菜单包含的按钮
this.HasMany(t => t.Buttons)
.WithMany(b => b.Menus)
.Map(m =>
{
m.MapLeftKey("MenuId");
m.MapRightKey("ButtonId");
m.ToTable("MenuButton");
});
//TODO:菜单包含的角色如果不加这句EF查询时会自动添加Role_RoleId列
this.HasMany(t => t.Roles)
.WithMany(b => b.RoleMenus)
.Map(m =>
{
m.MapLeftKey("MenuId");
m.MapRightKey("RoleId");
m.ToTable("RoleMenu");
});
// Table & Column Mappings
this.ToTable("Menu");
this.Property(t => t.Id).HasColumnName("MenuId");
this.Property(t => t.MenuId).HasColumnName("MenuId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Description).HasColumnName("Description");

View File

@@ -1,18 +1,17 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
using OpenAuth.Domain.Model;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class RoleMap : EntityTypeConfiguration<Role>
{
public RoleMap()
{
// Primary Key
this.HasKey(t => t.Id);
this.HasKey(t => t.RoleId);
// Properties
this.Property(t => t.Id)
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
@@ -26,36 +25,14 @@ namespace OpenAuth.Repository.Mapping
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
.HasMaxLength(50);
this.Property(t => t.DepartmentId)
.HasMaxLength(50);
//角色包含的用户;
this.HasMany(d => d.Users)
.WithMany(u => u.Roles)
.Map(
m =>
{
m.MapLeftKey("RoleId");
m.MapRightKey("UserId");
m.ToTable("UserRole");
});
//角色包含的菜单
this.HasMany(m => m.RoleMenus)
.WithMany(r => r.Roles)
.Map(m =>
{
m.MapLeftKey("RoleId");
m.MapRightKey("MenuId");
m.ToTable("RoleMenu");
});
// Table & Column Mappings
this.ToTable("Role");
this.Property(t => t.Id).HasColumnName("RoleId");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Category).HasColumnName("Category");
@@ -64,7 +41,6 @@ namespace OpenAuth.Repository.Mapping
this.Property(t => t.SortCode).HasColumnName("SortCode");
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class RoleMenuButtonMap : EntityTypeConfiguration<RoleMenuButton>
{
public RoleMenuButtonMap()
{
// Primary Key
this.HasKey(t => t.RoleMenuButtonId);
// Properties
this.Property(t => t.RoleMenuButtonId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ButtonId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("RoleMenuButton");
this.Property(t => t.RoleMenuButtonId).HasColumnName("RoleMenuButtonId");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.MenuId).HasColumnName("MenuId");
this.Property(t => t.ButtonId).HasColumnName("ButtonId");
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class RoleMenuMap : EntityTypeConfiguration<RoleMenu>
{
public RoleMenuMap()
{
// Primary Key
this.HasKey(t => t.RoleMenuId);
// Properties
this.Property(t => t.RoleMenuId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("RoleMenu");
this.Property(t => t.RoleMenuId).HasColumnName("RoleMenuId");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.MenuId).HasColumnName("MenuId");
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class UserDepartmentMap : EntityTypeConfiguration<UserDepartment>
{
public UserDepartmentMap()
{
// Primary Key
this.HasKey(t => t.UserDepartmentId);
// Properties
this.Property(t => t.UserDepartmentId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.DepartmentId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.UserId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("UserDepartment");
this.Property(t => t.UserDepartmentId).HasColumnName("UserDepartmentId");
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
this.Property(t => t.UserId).HasColumnName("UserId");
}
}
}

View File

@@ -1,18 +1,17 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
using OpenAuth.Domain.Model;
namespace OpenAuth.Repository.Mapping
namespace OpenAuth.Repository.Models.Mapping
{
public class UserMap : EntityTypeConfiguration<User>
{
public UserMap()
{
// Primary Key
this.HasKey(t => t.Id);
this.HasKey(t => t.UserId);
// Properties
this.Property(t => t.Id)
this.Property(t => t.UserId)
.IsRequired()
.HasMaxLength(50);
@@ -28,40 +27,15 @@ namespace OpenAuth.Repository.Mapping
this.Property(t => t.RoleId)
.HasMaxLength(50);
this.HasMany(u => u.Departments)
.WithMany(d => d.Users)
.Map(m =>
{
m.MapLeftKey("UserId");
m.MapRightKey("DepartmentId");
m.ToTable("UserDepartment");
});
this.HasMany(u => u.Roles)
.WithMany(r => r.Users)
.Map(m =>
{
m.MapLeftKey("UserId");
m.MapRightKey("RoleId");
m.ToTable("UserRole");
});
//ĬÈϽÇÉ«
this.HasOptional(u => u.DefaultRole)
.WithMany()
.HasForeignKey(u =>u.RoleId);
// Table & Column Mappings
this.ToTable("User");
this.Property(t => t.Id).HasColumnName("UserId");
this.Property(t => t.UserId).HasColumnName("UserId");
this.Property(t => t.Account).HasColumnName("Account");
this.Property(t => t.Password).HasColumnName("Password");
this.Property(t => t.RealName).HasColumnName("RealName");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class UserRoleMap : EntityTypeConfiguration<UserRole>
{
public UserRoleMap()
{
// Primary Key
this.HasKey(t => t.UserRoleId);
// Properties
this.Property(t => t.UserRoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.UserId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("UserRole");
this.Property(t => t.UserRoleId).HasColumnName("UserRoleId");
this.Property(t => t.UserId).HasColumnName("UserId");
this.Property(t => t.RoleId).HasColumnName("RoleId");
}
}
}

View File

@@ -0,0 +1,27 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Repository.Models.Mapping
{
public class sysdiagramMap : EntityTypeConfiguration<sysdiagram>
{
public sysdiagramMap()
{
// Primary Key
this.HasKey(t => t.diagram_id);
// Properties
this.Property(t => t.name)
.IsRequired()
.HasMaxLength(128);
// Table & Column Mappings
this.ToTable("sysdiagrams");
this.Property(t => t.name).HasColumnName("name");
this.Property(t => t.principal_id).HasColumnName("principal_id");
this.Property(t => t.diagram_id).HasColumnName("diagram_id");
this.Property(t => t.version).HasColumnName("version");
this.Property(t => t.definition).HasColumnName("definition");
}
}
}

View File

@@ -1,8 +1,8 @@
using System.Data.Entity;
using OpenAuth.Domain.Model;
using OpenAuth.Repository.Mapping;
using OpenAuth.Domain;
using OpenAuth.Repository.Models.Mapping;
namespace OpenAuth.Repository
namespace OpenAuth.Repository.Models
{
public partial class OpenAuthDBContext : DbContext
{
@@ -20,8 +20,14 @@ namespace OpenAuth.Repository
public DbSet<DataPermission> DataPermissions { get; set; }
public DbSet<Department> Departments { get; set; }
public DbSet<Menu> Menus { get; set; }
public DbSet<MenuButton> MenuButtons { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<RoleMenu> RoleMenus { get; set; }
public DbSet<RoleMenuButton> RoleMenuButtons { get; set; }
public DbSet<sysdiagram> sysdiagrams { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<UserDepartment> UserDepartments { get; set; }
public DbSet<UserRole> UserRoles { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
@@ -29,8 +35,14 @@ namespace OpenAuth.Repository
modelBuilder.Configurations.Add(new DataPermissionMap());
modelBuilder.Configurations.Add(new DepartmentMap());
modelBuilder.Configurations.Add(new MenuMap());
modelBuilder.Configurations.Add(new MenuButtonMap());
modelBuilder.Configurations.Add(new RoleMap());
modelBuilder.Configurations.Add(new RoleMenuMap());
modelBuilder.Configurations.Add(new RoleMenuButtonMap());
modelBuilder.Configurations.Add(new sysdiagramMap());
modelBuilder.Configurations.Add(new UserMap());
modelBuilder.Configurations.Add(new UserDepartmentMap());
modelBuilder.Configurations.Add(new UserRoleMap());
}
}
}

View File

@@ -46,15 +46,21 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Mapping\ButtonMap.cs" />
<Compile Include="Mapping\DataPermissionMap.cs" />
<Compile Include="Mapping\DepartmentMap.cs" />
<Compile Include="Mapping\MenuMap.cs" />
<Compile Include="Mapping\RoleMap.cs" />
<Compile Include="Mapping\UserMap.cs" />
<Compile Include="OpenAuthDBContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BaseRepository.cs" />
<Compile Include="Models\Mapping\ButtonMap.cs" />
<Compile Include="Models\Mapping\DataPermissionMap.cs" />
<Compile Include="Models\Mapping\DepartmentMap.cs" />
<Compile Include="Models\Mapping\MenuButtonMap.cs" />
<Compile Include="Models\Mapping\MenuMap.cs" />
<Compile Include="Models\Mapping\RoleMap.cs" />
<Compile Include="Models\Mapping\RoleMenuButtonMap.cs" />
<Compile Include="Models\Mapping\RoleMenuMap.cs" />
<Compile Include="Models\Mapping\sysdiagramMap.cs" />
<Compile Include="Models\Mapping\UserDepartmentMap.cs" />
<Compile Include="Models\Mapping\UserMap.cs" />
<Compile Include="Models\Mapping\UserRoleMap.cs" />
<Compile Include="Models\OpenAuthDBContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserRepository.cs" />
</ItemGroup>
<ItemGroup>
@@ -65,12 +71,17 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="CodeTemplates\ReverseEngineerCodeFirst\Context.tt" />
<None Include="CodeTemplates\ReverseEngineerCodeFirst\Entity.tt" />
<None Include="CodeTemplates\ReverseEngineerCodeFirst\Mapping.tt" />
<None Include="DB.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下

View File

@@ -1,35 +1,27 @@
using System;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain.Interface;
using OpenAuth.Domain.Model;
using System.Text;
using OpenAuth.Domain;
namespace OpenAuth.Repository
{
public class UserRepository :BaseRepository, IUserRepository
{
public User FindByAccount(string username)
public User FindByAccount(string account)
{
try
{
return _Context.Users.First(e => e.Account == username);
}
catch (Exception)
{
return null;
}
return Context.Users.SingleOrDefault(u => u.Account == account);
}
public User FindById(string id)
{
try
{
return _Context.Users.First(e => e.Id == id);
}
catch (Exception)
{
return null;
}
return Context.Users.SingleOrDefault(u => u.UserId == id);
}
public IEnumerable<User> LoadUsers()
{
return Context.Users.ToList();
}
}
}