-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor, Support for role and permissions
- Loading branch information
1 parent
0bf37e2
commit 2d8bcef
Showing
37 changed files
with
302 additions
and
459 deletions.
There are no files selected for viewing
28 changes: 15 additions & 13 deletions
28
...services.AuthenticationsMicroservice.Database/Database/Contexts/AuthenticationsContext.cs
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 |
---|---|---|
@@ -1,37 +1,39 @@ | ||
using EasyMicroservices.AuthenticationsMicroservice.Database.Entities; | ||
using Microsoft.EntityFrameworkCore; | ||
using EasyMicroservices.Cores.Relational.EntityFrameworkCore; | ||
using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Contexts | ||
{ | ||
public class AuthenticationsContext : RelationalCoreContext | ||
{ | ||
IDatabaseBuilder _builder; | ||
public AuthenticationsContext(IDatabaseBuilder builder) | ||
public AuthenticationsContext(IEntityFrameworkCoreDatabaseBuilder builder) : base(builder) | ||
{ | ||
_builder = builder; | ||
} | ||
|
||
public DbSet<UserEntity> Users { get; set; } | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
if (_builder != null) | ||
_builder.OnConfiguring(optionsBuilder); | ||
base.OnConfiguring(optionsBuilder); | ||
} | ||
public DbSet<RoleEntity> Roles { get; set; } | ||
public DbSet<UserRoleEntity> UserRoles { get; set; } | ||
public DbSet<ServicePermissionEntity> ServicePermissions { get; set; } | ||
public DbSet<RoleServicePermissionEntity> RoleServicePermissions { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
base.OnModelCreating(modelBuilder); | ||
base.AutoModelCreating(modelBuilder); | ||
|
||
modelBuilder.Entity<UserEntity>(model => | ||
{ | ||
model.HasKey(x => x.Id); | ||
model.HasIndex(u => u.UserName) | ||
.IsUnique(); | ||
}); | ||
|
||
modelBuilder.Entity<ServicePermissionEntity>(model => | ||
{ | ||
model.HasIndex(u => u.MicroserviceName); | ||
model.HasIndex(u => u.ServiceName); | ||
model.HasIndex(u => u.MethodName); | ||
model.HasIndex(u => new { u.MicroserviceName, u.ServiceName, u.MethodName }).IsUnique(); | ||
}); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...rp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Entities/RoleEntity.cs
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,16 @@ | ||
using EasyMicroservices.AuthenticationsMicroservice.Database.Schemas; | ||
using EasyMicroservices.Cores.Interfaces; | ||
using System.Collections.Generic; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Entities | ||
{ | ||
public class RoleEntity : RoleSchema, IIdSchema<long> | ||
{ | ||
public long Id { get; set; } | ||
public long? ParentId { get; set; } | ||
public RoleEntity Parent { get; set; } | ||
public ICollection<RoleEntity> Children { get; set; } | ||
public ICollection<UserRoleEntity> UserRoles { get; set; } | ||
public ICollection<RoleServicePermissionEntity> RoleServicePermissions { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ces.AuthenticationsMicroservice.Database/Database/Entities/RoleServicePermissionEntity.cs
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,13 @@ | ||
using EasyMicroservices.Cores.Database.Schemas; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Entities | ||
{ | ||
public class RoleServicePermissionEntity : FullAbilityIdSchema<long> | ||
{ | ||
public long RoleId { get; set; } | ||
public long ServicePermissionId { get; set; } | ||
|
||
public RoleEntity Role { get; set; } | ||
public ServicePermissionEntity ServicePermission { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ervices.AuthenticationsMicroservice.Database/Database/Entities/ServicePermissionEntity.cs
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,12 @@ | ||
using EasyMicroservices.AuthenticationsMicroservice.Database.Schemas; | ||
using EasyMicroservices.Cores.Interfaces; | ||
using System.Collections.Generic; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Entities | ||
{ | ||
public class ServicePermissionEntity : ServicePermissionSchema, IIdSchema<long> | ||
{ | ||
public long Id { get; set; } | ||
public ICollection<RoleServicePermissionEntity> RoleServicePermissions { get; set; } | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
...rp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Entities/UserEntity.cs
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 |
---|---|---|
@@ -1,16 +1,12 @@ | ||
using EasyMicroservices.AuthenticationsMicroservice.Database.Schemas; | ||
using EasyMicroservices.Cores.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Entities | ||
{ | ||
public class UserEntity : UserSchema, IIdSchema<long> | ||
{ | ||
public long Id { get; set; } | ||
public ICollection<UserRoleEntity> UserRoles { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...asyMicroservices.AuthenticationsMicroservice.Database/Database/Entities/UserRoleEntity.cs
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,13 @@ | ||
using EasyMicroservices.Cores.Database.Schemas; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Entities | ||
{ | ||
public class UserRoleEntity : FullAbilityIdSchema<long> | ||
{ | ||
public long RoleId { get; set; } | ||
public long UserId { get; set; } | ||
|
||
public RoleEntity Role { get; set; } | ||
public UserEntity User { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...arp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Schemas/RoleSchema.cs
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,9 @@ | ||
using EasyMicroservices.Cores.Database.Schemas; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Schemas | ||
{ | ||
public class RoleSchema : FullAbilitySchema | ||
{ | ||
public string Name { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...services.AuthenticationsMicroservice.Database/Database/Schemas/ServicePermissionSchema.cs
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,11 @@ | ||
using EasyMicroservices.Cores.Database.Schemas; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Database.Schemas | ||
{ | ||
public class ServicePermissionSchema : FullAbilitySchema | ||
{ | ||
public string MicroserviceName { get; set; } | ||
public string ServiceName { get; set; } | ||
public string MethodName { 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
10 changes: 10 additions & 0 deletions
10
...arp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/RoleContract.cs
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,10 @@ | ||
using EasyMicroservices.Cores.Database.Schemas; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Common | ||
{ | ||
public class RoleContract : FullAbilityIdSchema<long> | ||
{ | ||
public string Name { get; set; } | ||
public long? ParentId { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ices.AuthenticationsMicroservice.Domain/Contracts/Common/RoleServicePermissionContract.cs
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Common | ||
{ | ||
public class RoleServicePermissionContract | ||
{ | ||
public long RoleId { get; set; } | ||
public long ServicePermissionId { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...services.AuthenticationsMicroservice.Domain/Contracts/Common/ServicePermissionContract.cs
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,9 @@ | ||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Common | ||
{ | ||
public class ServicePermissionContract | ||
{ | ||
public string MicroserviceName { get; set; } | ||
public string ServiceName { get; set; } | ||
public string MethodName { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/UserRoleContract.cs
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,8 @@ | ||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Common | ||
{ | ||
public class UserRoleContract | ||
{ | ||
public long RoleId { get; set; } | ||
public long UserId { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...oservices.AuthenticationsMicroservice.Domain/Contracts/Requests/AddRoleRequestContract.cs
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,8 @@ | ||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Requests | ||
{ | ||
public class AddRoleRequestContract | ||
{ | ||
public string Name { get; set; } | ||
public long? ParentId { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...icationsMicroservice.Domain/Contracts/Requests/AddRoleServicePermissionRequestContract.cs
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Requests | ||
{ | ||
public class AddRoleServicePermissionRequestContract | ||
{ | ||
public long RoleId { get; set; } | ||
public long ServicePermissionId { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...henticationsMicroservice.Domain/Contracts/Requests/AddServicePermissionRequestContract.cs
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,9 @@ | ||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Requests | ||
{ | ||
public class AddServicePermissionRequestContract | ||
{ | ||
public string MicroserviceName { get; set; } | ||
public string ServiceName { get; set; } | ||
public string MethodName { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...vices.AuthenticationsMicroservice.Domain/Contracts/Requests/AddUserRoleRequestContract.cs
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,8 @@ | ||
namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Requests | ||
{ | ||
public class AddUserRoleRequestContract | ||
{ | ||
public long RoleId { get; set; } | ||
public long UserId { 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
16 changes: 0 additions & 16 deletions
16
...CSharp/EasyMicroservices.AuthenticationsMicroservice.Logics/Helpers/ApplicationManager.cs
This file was deleted.
Oops, something went wrong.
7 changes: 1 addition & 6 deletions
7
...harp/EasyMicroservices.AuthenticationsMicroservice.Logics/Helpers/AuthenticationHelper.cs
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
16 changes: 0 additions & 16 deletions
16
...arp/EasyMicroservices.AuthenticationsMicroservice.Logics/Interfaces/IDependencyManager.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.