diff --git a/FAuth/Controllers/api/RoleController.cs b/FAuth/Controllers/api/RoleController.cs
new file mode 100644
index 0000000..b3e7f07
--- /dev/null
+++ b/FAuth/Controllers/api/RoleController.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+
+namespace FAuth.Controllers.api
+{
+ ///
+ /// 角色控制器
+ ///
+ public class RoleController:ApiControllerBase
+ {
+ public RoleController(ILogger logger,IServiceProvider service) : base(logger,service) {
+ }
+ }
+}
diff --git a/FAuth/DataBase/FAuthDb.cs b/FAuth/DataBase/FAuthDb.cs
index 2b08e79..c6b1b6a 100644
--- a/FAuth/DataBase/FAuthDb.cs
+++ b/FAuth/DataBase/FAuthDb.cs
@@ -11,9 +11,42 @@ namespace FAuth.DataBase
public FAuthDb(DbContextOptions options) : base(options) {
Database.EnsureCreatedAsync().Wait();
}
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder) {
+ var mb = modelBuilder;
+ mb.Entity().HasKey(m => new { m.AppId,m.RoleGroupId });
+ mb.Entity().HasKey(m => new { m.RoleGroupId,m.RoleId });
+ mb.Entity().HasKey(m => new { m.RoleId,m.UserId });
+ base.OnModelCreating(modelBuilder);
+ }
+
///
- /// 用户表
+ /// 用户
///
public DbSet Users { get; set; }
+ ///
+ /// 应用信息
+ ///
+ public DbSet Apps { get; set; }
+ ///
+ /// 角色组信息
+ ///
+ public DbSet RoleGroups { get; set; }
+ ///
+ /// 角色信息
+ ///
+ public DbSet Roles { get; set; }
+ ///
+ /// 应用角色组对应关系
+ ///
+ public DbSet App_RoleGroups { get; set; }
+ ///
+ /// 角色组角色对应关系
+ ///
+ public DbSet RoleGroup_Roles { get; set; }
+ ///
+ /// 角色用户对应关系
+ ///
+ public DbSet Role_Users { get; set; }
}
}
diff --git a/FAuth/DataBase/Tables/App_RoleGroup.cs b/FAuth/DataBase/Tables/App_RoleGroup.cs
new file mode 100644
index 0000000..805fc35
--- /dev/null
+++ b/FAuth/DataBase/Tables/App_RoleGroup.cs
@@ -0,0 +1,17 @@
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 应用和角色组对应关系
+ ///
+ public class App_RoleGroup
+ {
+ ///
+ /// 应用编号
+ ///
+ public int AppId { get; set; }
+ ///
+ /// 角色组编号
+ ///
+ public int RoleGroupId { get; set; }
+ }
+}
diff --git a/FAuth/DataBase/Tables/Apps.cs b/FAuth/DataBase/Tables/Apps.cs
new file mode 100644
index 0000000..b8dc509
--- /dev/null
+++ b/FAuth/DataBase/Tables/Apps.cs
@@ -0,0 +1,28 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 应用信息
+ ///
+ [Table("Apps")]
+ public class Apps
+ {
+ ///
+ /// 应用编号
+ ///
+ [Key]
+ public int Id { get; set; }
+ ///
+ /// 应用名称
+ ///
+ [MaxLength(50), Required]
+ public string Name { get; set; }
+ ///
+ /// 应用说明
+ ///
+ [MaxLength(200)]
+ public string Description { get; set; }
+ }
+}
diff --git a/FAuth/DataBase/Tables/FUser.cs b/FAuth/DataBase/Tables/FUser.cs
index 3afce6d..1a694e6 100644
--- a/FAuth/DataBase/Tables/FUser.cs
+++ b/FAuth/DataBase/Tables/FUser.cs
@@ -1,11 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
namespace FAuth.DataBase.Tables
{
///
/// 用户信息
///
+ [Table("FUser")]
public class FUser
{
///
diff --git a/FAuth/DataBase/Tables/RoleGroup.cs b/FAuth/DataBase/Tables/RoleGroup.cs
new file mode 100644
index 0000000..0ed2239
--- /dev/null
+++ b/FAuth/DataBase/Tables/RoleGroup.cs
@@ -0,0 +1,28 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 角色组
+ ///
+ [Table("RoleGroup")]
+ public class RoleGroup
+ {
+ ///
+ /// 角色组编号
+ ///
+ [Key]
+ public int Id { get; set; }
+ ///
+ /// 角色组名称
+ ///
+ [MaxLength(50),Required]
+ public string Name { get; set; }
+ ///
+ /// 角色组说明
+ ///
+ [MaxLength(200)]
+ public string Description { get; set; }
+ }
+}
diff --git a/FAuth/DataBase/Tables/RoleGroup_Role.cs b/FAuth/DataBase/Tables/RoleGroup_Role.cs
new file mode 100644
index 0000000..14ca161
--- /dev/null
+++ b/FAuth/DataBase/Tables/RoleGroup_Role.cs
@@ -0,0 +1,17 @@
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 角色组合角色对应关系
+ ///
+ public class RoleGroup_Role
+ {
+ ///
+ /// 角色组编号
+ ///
+ public int RoleGroupId { get; set; }
+ ///
+ /// 角色编号
+ ///
+ public int RoleId { get; set; }
+ }
+}
diff --git a/FAuth/DataBase/Tables/Role_User.cs b/FAuth/DataBase/Tables/Role_User.cs
new file mode 100644
index 0000000..562d067
--- /dev/null
+++ b/FAuth/DataBase/Tables/Role_User.cs
@@ -0,0 +1,17 @@
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 角色用户对应关系
+ ///
+ public class Role_User
+ {
+ ///
+ /// 角色编号
+ ///
+ public int RoleId { get; set; }
+ ///
+ /// 用户编号
+ ///
+ public int UserId { get; set; }
+ }
+}
diff --git a/FAuth/DataBase/Tables/Roles.cs b/FAuth/DataBase/Tables/Roles.cs
new file mode 100644
index 0000000..3e19e43
--- /dev/null
+++ b/FAuth/DataBase/Tables/Roles.cs
@@ -0,0 +1,28 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 角色定义
+ ///
+ [Table("Roles")]
+ public class Roles
+ {
+ ///
+ /// 角色编号
+ ///
+ [Key]
+ public int Id { get; set; }
+ ///
+ /// 角色名称
+ ///
+ [MaxLength(50), Required]
+ public string Name { get; set; }
+ ///
+ /// 角色说明
+ ///
+ [MaxLength(50)]
+ public string Description { get; set; }
+ }
+}