ok
This commit is contained in:
parent
dab31a7c8f
commit
c1219e0238
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,4 +14,5 @@ Logs/
|
||||
|
||||
node_modules/
|
||||
|
||||
*.lscache
|
||||
*.lscache
|
||||
/src/SimpleAdmin.Api/wwwroot/
|
||||
|
||||
6
Directory.Build.props
Normal file
6
Directory.Build.props
Normal file
@ -0,0 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<!-- All Fake packages -->
|
||||
<FakePackageVersion>8.0.5.12</FakePackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -10,11 +10,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{BE5132AD
|
||||
NuGet.Config = NuGet.Config
|
||||
SPEC.md = SPEC.md
|
||||
开发复刻说明.md = 开发复刻说明.md
|
||||
oms表结构与接口设计2026040802.md = oms表结构与接口设计2026040802.md
|
||||
.gitignore = .gitignore
|
||||
.dockerignore = .dockerignore
|
||||
oms表结构与接口设计20260427.md = oms表结构与接口设计20260427.md
|
||||
db.sql = db.sql
|
||||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleAdmin.Api", "src\SimpleAdmin.Api\SimpleAdmin.Api.csproj", "{229ED167-9ECC-4736-8DFB-522EEA8FF680}"
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlBuilderProvider_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F38bf349295324397b2c739e7e632b4bd2d5000_003F71_003F77c8fbe4_003FSqlBuilderProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSugarClient_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F38bf349295324397b2c739e7e632b4bd2d5000_003Fe8_003Ffcf6435d_003FSqlSugarClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSugarProvider_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F38bf349295324397b2c739e7e632b4bd2d5000_003F26_003Fce9a7a77_003FSqlSugarProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUnauthorizedAccessException_002Ecs_002Fl_003AC_0021_003FUsers_003FBSI_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3e10648195244ebfa276c71cb5b3f877c90750_003F74_003F8418b441_003FUnauthorizedAccessException_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=9c7e285e_002D68dc_002D4e8e_002D88cb_002De8df37de5da5/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;src&gt;\&lt;SimpleAdmin.Api.IntegrationTests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||
<Project Location="D:\my\itfx\admin\src\SimpleAdmin.Api.IntegrationTests" Presentation="&lt;src&gt;\&lt;SimpleAdmin.Api.IntegrationTests&gt;" />
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
||||
@ -16,9 +16,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.Rbac.Application" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.Rbac.Infrastructure" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.Rbac.Application" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.Rbac.Infrastructure" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="MiniExcel" Version="1.43.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -23,9 +23,9 @@ public class CustomerService : ApplicationService
|
||||
|
||||
private ICustomerRepository CustomerRepository => LazyServiceProvider.GetRequiredService<ICustomerRepository>();
|
||||
|
||||
private IUserService UserService => LazyServiceProvider.GetRequiredService<IUserService>();
|
||||
private UserService UserService => LazyServiceProvider.GetRequiredService<UserService>();
|
||||
|
||||
private IRoleService RoleService => LazyServiceProvider.GetRequiredService<IRoleService>();
|
||||
private RoleService RoleService => LazyServiceProvider.GetRequiredService<RoleService>();
|
||||
|
||||
private FakeRbacDbContext RbacDbContext => LazyServiceProvider.GetRequiredService<FakeRbacDbContext>();
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.5.11" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.214" />
|
||||
<PackageReference Include="Fake.Ddd.Domain" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.SqlSugarCore" Version="$(FakePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -3,7 +3,7 @@ using Fake.Modularity;
|
||||
|
||||
namespace Oms.Domain;
|
||||
|
||||
[DependsOn(typeof(FakeDomainDrivenDesignModule))]
|
||||
[DependsOn(typeof(FakeDddDomainModule))]
|
||||
public class OmsDomainModule : FakeModule
|
||||
{
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.SqlSugarCore" Version="$(FakePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -2,7 +2,6 @@ using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using Fake.Application;
|
||||
using Fake.Domain.Exceptions;
|
||||
using Fake.Helpers;
|
||||
using Fake.Rbac.Application.Dtos.Auth;
|
||||
using Fake.Rbac.Application.Dtos.Menu;
|
||||
using Fake.Rbac.Application.Dtos.User;
|
||||
@ -11,10 +10,8 @@ using Fake.Rbac.Application.Services;
|
||||
using Fake.Rbac.Domain.Managers;
|
||||
using Fake.Rbac.Domain.UserAggregate;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.Users;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Shared;
|
||||
@ -33,8 +30,8 @@ namespace SimpleAdmin.Api.Auth;
|
||||
[ApiExplorerSettings(GroupName = "RBAC")]
|
||||
public class AuthService(
|
||||
AccountManager accountManager,
|
||||
IUserService userService,
|
||||
IMenuService menuService,
|
||||
UserService userService,
|
||||
MenuService menuService,
|
||||
IJwtService jwtService,
|
||||
IUserRepository userRepository,
|
||||
IWebHostEnvironment webHostEnvironment,
|
||||
@ -43,6 +40,8 @@ public class AuthService(
|
||||
ICustomerRepository customerRepository)
|
||||
: ApplicationService
|
||||
{
|
||||
private Guid CurrentUserGuid => CurrentUser.FindClaimValueOrNull(ClaimTypes.NameIdentifier)!.To<Guid>();
|
||||
|
||||
/// <summary>
|
||||
/// 用户或客户登录。
|
||||
/// </summary>
|
||||
@ -116,12 +115,10 @@ public class AuthService(
|
||||
|
||||
if (IsCustomerPrincipal())
|
||||
{
|
||||
var currentUserId = CurrentUser.Id ?? throw new UnauthorizedAccessException("用户未登录");
|
||||
return await BuildAdminUserInfoAsync(currentUserId, cancellationToken);
|
||||
return await BuildAdminUserInfoAsync(CurrentUserGuid, cancellationToken);
|
||||
}
|
||||
|
||||
var userId = CurrentUser.Id ?? throw new UnauthorizedAccessException("用户未登录");
|
||||
return await BuildAdminUserInfoAsync(userId, cancellationToken);
|
||||
return await BuildAdminUserInfoAsync(CurrentUserGuid, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,9 +135,8 @@ public class AuthService(
|
||||
await ChangeCustomerPasswordAsync(input.OldPassword, input.NewPassword, cancellationToken);
|
||||
return;
|
||||
}
|
||||
|
||||
var userId = CurrentUser.Id ?? throw new UnauthorizedAccessException("用户未登录");
|
||||
await accountManager.UpdatePasswordAsync(userId, input.OldPassword, input.NewPassword, cancellationToken);
|
||||
|
||||
await accountManager.UpdatePasswordAsync(CurrentUserGuid, input.OldPassword, input.NewPassword, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -154,7 +150,7 @@ public class AuthService(
|
||||
{
|
||||
EnsureAdminPrincipal();
|
||||
|
||||
var userId = CurrentUser.Id ?? throw new UnauthorizedAccessException("用户未登录");
|
||||
var userId = CurrentUserGuid;
|
||||
var user = await userRepository.FirstAsync(u => u.Id == userId, cancellationToken: cancellationToken);
|
||||
user.Update(input.Name, input.Email);
|
||||
await userRepository.UpdateAsync(user, cancellationToken: cancellationToken);
|
||||
@ -173,7 +169,7 @@ public class AuthService(
|
||||
{
|
||||
EnsureAdminPrincipal();
|
||||
|
||||
var userId = CurrentUser.Id ?? throw new UnauthorizedAccessException("用户未登录");
|
||||
var userId = CurrentUserGuid;
|
||||
if (file == null || file.Length == 0)
|
||||
{
|
||||
throw new DomainException("请选择要上传的文件");
|
||||
@ -415,7 +411,7 @@ public class AuthService(
|
||||
|
||||
return new CustomerPrincipalContext
|
||||
{
|
||||
PrincipalId = CurrentUser.Id ?? throw new UnauthorizedAccessException("客户未登录"),
|
||||
PrincipalId = CurrentUserGuid,
|
||||
Customer = customer,
|
||||
DisplayName = customer.WechatNickname ?? customer.CustomerName,
|
||||
AccountCode = customer.CustomerCode,
|
||||
|
||||
@ -4,7 +4,7 @@ using Fake.Rbac.Application.Services;
|
||||
|
||||
namespace SimpleAdmin.Api.Auth;
|
||||
|
||||
public class CustomerRoleSeedContributor(IRoleService roleService) : IDataSeedContributor
|
||||
public class CustomerRoleSeedContributor(RoleService roleService) : IDataSeedContributor
|
||||
{
|
||||
public const string CustomerRoleCode = "Customer";
|
||||
public const string CustomerRoleName = "客户";
|
||||
|
||||
@ -6,21 +6,13 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.Autofac" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.Consul" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.Rbac.Application" Version="8.0.5.11" />
|
||||
<PackageReference Include="Fake.Serilog" Version="8.0.5.11" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
<PackageReference Include="Fake.Autofac" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.Consul" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.Rbac.Application" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Fake.Serilog" Version="$(FakePackageVersion)" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -4,12 +4,14 @@ using Fake.Modularity;
|
||||
using Fake.Rbac.Application;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.AspNetCore.Auditing;
|
||||
using Fake.AspNetCore.Mvc;
|
||||
using Fake.AspNetCore.Authentication;
|
||||
using Fake.AspNetCore.ExceptionHandling;
|
||||
using Fake.AspNetCore.Newtonsoft;
|
||||
using Fake.AspNetCore.Swagger;
|
||||
using Fake.FeiShu;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.Serilog;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Oms.Application;
|
||||
using Oms.SqlSugarCore;
|
||||
using SimpleAdmin.Api.Auth;
|
||||
@ -53,6 +55,9 @@ public class SimpleAdminApiModule : FakeModule
|
||||
settings.TypePredicate = type => type != typeof(Fake.Rbac.Application.Services.AuthService);
|
||||
});
|
||||
});
|
||||
|
||||
//Json格式化全局处理
|
||||
context.Services.AddFakeNewtonsoft();
|
||||
|
||||
services.AddFakeAspNetCoreAuditing();
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ namespace SimpleAdmin.Api;
|
||||
/// 自定义simple-admin auth jwt service
|
||||
/// </summary>
|
||||
[Dependency(Replace = true)]
|
||||
public class SimpleJwtService(IOptions<JwtOptions> jwtOptions, IUserService userService, FakeRbacDbContext rbacDbContext)
|
||||
public class SimpleJwtService(IOptions<FakeJwtOptions> jwtOptions, UserService userService, FakeRbacDbContext rbacDbContext)
|
||||
: JwtService(jwtOptions, userService)
|
||||
{
|
||||
public override async Task<List<Claim>> GenerateClaimsByUserIdAsync(Guid userId,
|
||||
@ -28,6 +28,7 @@ public class SimpleJwtService(IOptions<JwtOptions> jwtOptions, IUserService user
|
||||
{
|
||||
claims.RemoveAll(x => x.Type == FakeClaimTypes.UserId);
|
||||
claims.Add(new Claim(FakeClaimTypes.UserId, mapId.Value.ToString()));
|
||||
claims.Add(new Claim(ClaimTypes.NameIdentifier, userId.ToString()));
|
||||
}
|
||||
|
||||
return claims;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user