mirror of
https://github.com/hmaxnl/DotBased.git
synced 2025-02-22 22:55:01 +01:00
[ADD] Added EF Core project for authority db
This commit is contained in:
parent
c27890a31f
commit
e914023c5a
12
DotBased.AspNet.Authority.EFCore/AuthorityContext.cs
Normal file
12
DotBased.AspNet.Authority.EFCore/AuthorityContext.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using DotBased.AspNet.Authority.Models.Authority;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DotBased.AspNet.Authority.EFCore;
|
||||||
|
|
||||||
|
public class AuthorityContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<AuthorityAttribute> Attributes { get; set; }
|
||||||
|
public DbSet<AuthorityGroup> Groups { get; set; }
|
||||||
|
public DbSet<AuthorityRole> Roles { get; set; }
|
||||||
|
public DbSet<AuthorityUser> Users { get; set; }
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DotBased.AspNet.Authority\DotBased.AspNet.Authority.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
using DotBased.AspNet.Authority.Models.Authority;
|
||||||
|
using DotBased.AspNet.Authority.Repositories;
|
||||||
|
|
||||||
|
namespace DotBased.AspNet.Authority.EFCore.Repositories;
|
||||||
|
|
||||||
|
public class RoleRepository : IRoleRepository
|
||||||
|
{
|
||||||
|
public Task<ListResult<AuthorityRole>> GetRolesAsync(int limit = 20, int offset = 0, string search = "", CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
|
using DotBased.AspNet.Authority.Models.Authority;
|
||||||
|
|
||||||
namespace DotBased.AspNet.Authority.Repositories;
|
namespace DotBased.AspNet.Authority.Repositories;
|
||||||
|
|
||||||
public interface IRoleRepository
|
public interface IRoleRepository
|
||||||
{
|
{
|
||||||
|
public Task<ListResult<AuthorityRole>> GetRolesAsync(int limit = 20, int offset = 0, string search = "", CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
|
@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.AspNet.Authority",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.Data", "DotBased.Data\DotBased.Data.csproj", "{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.Data", "DotBased.Data\DotBased.Data.csproj", "{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.AspNet.Authority.EFCore", "DotBased.AspNet.Authority.EFCore\DotBased.AspNet.Authority.EFCore.csproj", "{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -66,6 +68,10 @@ Global
|
||||||
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
||||||
|
@ -76,5 +82,6 @@ Global
|
||||||
{624E7B11-8A18-46E5-AB1F-6AF6097F9D4D} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
{624E7B11-8A18-46E5-AB1F-6AF6097F9D4D} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
||||||
{A3ADC9AF-39B7-4EC4-8022-946118A8C322} = {624E7B11-8A18-46E5-AB1F-6AF6097F9D4D}
|
{A3ADC9AF-39B7-4EC4-8022-946118A8C322} = {624E7B11-8A18-46E5-AB1F-6AF6097F9D4D}
|
||||||
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
|
||||||
|
{F1F3F60B-911F-4036-8A2B-CEC18A8F59DD} = {624E7B11-8A18-46E5-AB1F-6AF6097F9D4D}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class Result<TValue> : Result
|
||||||
|
|
||||||
public class ListResult<TItem> : Result
|
public class ListResult<TItem> : Result
|
||||||
{
|
{
|
||||||
public ListResult(bool success, string message, int totalCount, IEnumerable<TItem>? items, Exception? exception) : base(success, message, exception)
|
public ListResult(bool success, string message, int totalCount, IEnumerable<TItem>? items, int limit = -1, int offset = -1, Exception? exception = null) : base(success, message, exception)
|
||||||
{
|
{
|
||||||
Items = items != null ? new List<TItem>(items) : new List<TItem>();
|
Items = items != null ? new List<TItem>(items) : new List<TItem>();
|
||||||
TotalCount = totalCount;
|
TotalCount = totalCount;
|
||||||
|
@ -69,9 +69,19 @@ public class ListResult<TItem> : Result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalCount { get; }
|
public int TotalCount { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The limit this result contains
|
||||||
|
/// </summary>
|
||||||
|
public int Limit { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The offset this result has the items from.
|
||||||
|
/// </summary>
|
||||||
|
public int Offset { get; }
|
||||||
|
|
||||||
public static ListResult<TItem> Ok(IEnumerable<TItem> items, int totalCount = -1) =>
|
public static ListResult<TItem> Ok(IEnumerable<TItem> items, int totalCount = -1) =>
|
||||||
new(true, string.Empty, totalCount, items, null);
|
new(true, string.Empty, totalCount, items);
|
||||||
|
|
||||||
public new static ListResult<TItem> Failed(string message, Exception? exception = null) =>
|
public new static ListResult<TItem> Failed(string message, Exception? exception = null) =>
|
||||||
new(false, message, -1, null, exception);
|
new(false, message, -1, null);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user