1.05 #7
@ -3,6 +3,6 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- All Fake packages -->
|
||||
<FakePackageVersion>8.0.5.21</FakePackageVersion>
|
||||
<FakePackageVersion>8.0.5.22</FakePackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<PropertyGroup>
|
||||
<FakeRepoRoot Condition="'$(FakeRepoRoot)' == ''">C:\Users\BSI\RiderProjects\fake2</FakeRepoRoot>
|
||||
<!-- EventBus / Dashboard / IntegrationEventLog -->
|
||||
<UseLocalFakeEventBus Condition="'$(UseLocalFakeEventBus)' == ''">false</UseLocalFakeEventBus>
|
||||
<UseLocalFakeEventBus Condition="'$(UseLocalFakeEventBus)' == ''">true</UseLocalFakeEventBus>
|
||||
<!-- RBAC / FileManagement(表前缀 fk_ 等框架改动需同源) -->
|
||||
<UseLocalFakeModules Condition="'$(UseLocalFakeModules)' == ''">false</UseLocalFakeModules>
|
||||
<UseLocalFakeModules Condition="'$(UseLocalFakeModules)' == ''">true</UseLocalFakeModules>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.DataPerm;
|
||||
|
||||
@ -11,7 +12,7 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
public async Task<RbacUserSnapshot?> GetUserSnapshotAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
u.`Id` AS `Id`,
|
||||
u.`userid` AS `MapId`,
|
||||
@ -19,22 +20,21 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
u.`Name` AS `Name`,
|
||||
u.`OrganizationId` AS `OrganizationId`,
|
||||
o.`Name` AS `OrganizationName`
|
||||
FROM `user` u
|
||||
LEFT JOIN `organization` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.User}}` u
|
||||
LEFT JOIN `{{FakeTables.Organization}}` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
WHERE u.`Id` = {0} AND u.`IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""";
|
||||
|
||||
return await Db.Database.SqlQueryRaw<RbacUserSnapshot>(sql, userId.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> IsPureCustomerUserAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user_role` ur
|
||||
INNER JOIN `role` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
INNER JOIN `{{FakeTables.Role}}` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
WHERE ur.`UserId` = {0}
|
||||
AND r.`Code` <> 'Customer'
|
||||
AND r.`Code` NOT LIKE 'CustomerSub_%'
|
||||
@ -47,12 +47,11 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
return false;
|
||||
}
|
||||
|
||||
const string hasRoleSql = """
|
||||
var hasRoleSql = $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user_role` ur
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
WHERE ur.`UserId` = {0}
|
||||
""";
|
||||
|
||||
var roleCount = await Db.Database.SqlQueryRaw<int>(hasRoleSql, userId.ToString())
|
||||
.FirstAsync(cancellationToken);
|
||||
return roleCount > 0;
|
||||
@ -60,10 +59,10 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
public async Task<bool> IsAdminUserAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user_role` ur
|
||||
INNER JOIN `role` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
INNER JOIN `{{FakeTables.Role}}` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
WHERE ur.`UserId` = {0}
|
||||
AND r.`Code` = 'Admin'
|
||||
""";
|
||||
@ -74,21 +73,20 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
public async Task<List<Guid>> GetUserRoleIdsAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT ur.`RoleId` AS `Value`
|
||||
FROM `user_role` ur
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
WHERE ur.`UserId` = {0}
|
||||
""";
|
||||
|
||||
return await Db.Database.SqlQueryRaw<Guid>(sql, userId.ToString())
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<List<Guid>> GetUserIdsByRoleAsync(Guid roleId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT ur.`UserId` AS `Value`
|
||||
FROM `user_role` ur
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
WHERE ur.`RoleId` = {0}
|
||||
""";
|
||||
|
||||
@ -115,7 +113,6 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
WHERE p.`IsDeleted` = 0
|
||||
AND p.`RoleId` IN ({inClause})
|
||||
""";
|
||||
|
||||
return await Db.Database.SqlQueryRaw<OrgPermRow>(sql).ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
@ -385,14 +382,14 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
public async Task<List<Guid>> GetOrganizationSubtreeIdsAsync(Guid rootOrganizationId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
WITH RECURSIVE org_tree AS (
|
||||
SELECT o.`Id`
|
||||
FROM `organization` o
|
||||
FROM `{{FakeTables.Organization}}` o
|
||||
WHERE o.`Id` = {0} AND o.`IsDeleted` = 0
|
||||
UNION ALL
|
||||
SELECT c.`Id`
|
||||
FROM `organization` c
|
||||
FROM `{{FakeTables.Organization}}` c
|
||||
INNER JOIN org_tree t ON c.`ParentId` = t.`Id`
|
||||
WHERE c.`IsDeleted` = 0
|
||||
)
|
||||
@ -414,22 +411,21 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
}
|
||||
|
||||
var inClause = string.Join(",", ids.Select(x => $"'{x}'"));
|
||||
var sql = $"""
|
||||
var sql = $$"""
|
||||
SELECT o.`Id` AS `Id`, o.`Name` AS `Name`
|
||||
FROM `organization` o
|
||||
FROM `{{FakeTables.Organization}}` o
|
||||
WHERE o.`IsDeleted` = 0
|
||||
AND o.`Id` IN ({inClause})
|
||||
""";
|
||||
|
||||
var rows = await Db.Database.SqlQueryRaw<OrganizationNameRow>(sql).ToListAsync(cancellationToken);
|
||||
return rows.ToDictionary(x => x.Id, x => x.Name ?? x.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<bool> OrganizationExistsAndEnabledAsync(Guid organizationId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `organization` o
|
||||
FROM `{{FakeTables.Organization}}` o
|
||||
WHERE o.`Id` = {0}
|
||||
AND o.`IsDeleted` = 0
|
||||
""";
|
||||
@ -450,13 +446,12 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
if (dataScope == DataPermConstants.DataScopeTeam)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT u.`userid` AS `Value`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`OrganizationId` = {0}
|
||||
""";
|
||||
|
||||
return await Db.Database.SqlQueryRaw<int>(sql, organizationId.ToString())
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
@ -470,9 +465,9 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
}
|
||||
|
||||
var inClause = string.Join(",", orgIds.Select(x => $"'{x}'"));
|
||||
var sql = $"""
|
||||
var sql = $$"""
|
||||
SELECT u.`userid` AS `Value`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`OrganizationId` IN ({inClause})
|
||||
""";
|
||||
@ -485,7 +480,7 @@ public class DataPermRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
|
||||
public async Task<List<DataResourceMetaDto>> GetDataResourcesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $"""
|
||||
SELECT
|
||||
r.`Code` AS `Code`,
|
||||
r.`Name` AS `Name`,
|
||||
|
||||
@ -2,6 +2,7 @@ using System.Text.Json;
|
||||
using Fake.Application;
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Oms.Application.Dtos.DataPerm;
|
||||
@ -20,21 +21,21 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
|
||||
public async Task<UserDataPermDto> GetUserDataPermAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var user = await dbContext.Database.SqlQueryRaw<UserHeaderRow>("""
|
||||
var user = await dbContext.Database.SqlQueryRaw<UserHeaderRow>($$"""
|
||||
SELECT
|
||||
u.`Id` AS `UserId`,
|
||||
u.`Name` AS `UserName`,
|
||||
u.`OrganizationId` AS `OrganizationId`,
|
||||
o.`Name` AS `OrganizationName`
|
||||
FROM `user` u
|
||||
LEFT JOIN `organization` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.User}}` u
|
||||
LEFT JOIN `{{FakeTables.Organization}}` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
WHERE u.`Id` = {0} AND u.`IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""", userId.ToString()).FirstOrDefaultAsync(cancellationToken)
|
||||
?? throw new BusinessException("用户不存在");
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
var orgRows = await dbContext.Database.SqlQueryRaw<UserOrgPermRow>("""
|
||||
var orgRows = await dbContext.Database.SqlQueryRaw<UserOrgPermRow>($$"""
|
||||
SELECT
|
||||
p.`Id` AS `Id`,
|
||||
p.`OrganizationId` AS `OrganizationId`,
|
||||
@ -44,11 +45,11 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
p.`ExpireTime` AS `ExpireTime`,
|
||||
p.`IsTemporary` AS `IsTemporary`
|
||||
FROM `user_org_perm` p
|
||||
LEFT JOIN `organization` o ON o.`Id` = p.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
LEFT JOIN `{{FakeTables.Organization}}` o ON o.`Id` = p.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
WHERE p.`IsDeleted` = 0 AND p.`UserId` = {0}
|
||||
""", userId.ToString()).ToListAsync(cancellationToken);
|
||||
|
||||
var scopeRows = await dbContext.Database.SqlQueryRaw<UserDataScopeRow>("""
|
||||
var scopeRows = await dbContext.Database.SqlQueryRaw<UserDataScopeRow>($"""
|
||||
SELECT p.`Id` AS `Id`, p.`DataScope` AS `DataScope`, p.`DataResourceCode` AS `DataResourceCode`, p.`ExpireTime` AS `ExpireTime`
|
||||
FROM `user_data_scope` p
|
||||
WHERE p.`IsDeleted` = 0 AND p.`UserId` = {0}
|
||||
@ -129,16 +130,16 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
{
|
||||
var role = await dbContext.Database.SqlQueryRaw<RoleHeaderRow>("""
|
||||
SELECT r.`Id` AS `RoleId`, r.`Name` AS `RoleName`
|
||||
FROM `role` r
|
||||
FROM `{{FakeTables.Role}}` r
|
||||
WHERE r.`Id` = {0} AND r.`IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""", roleId.ToString()).FirstOrDefaultAsync(cancellationToken)
|
||||
?? throw new BusinessException("角色不存在");
|
||||
|
||||
var orgRows = await dbContext.Database.SqlQueryRaw<RoleOrgPermRow>("""
|
||||
var orgRows = await dbContext.Database.SqlQueryRaw<RoleOrgPermRow>($$"""
|
||||
SELECT p.`Id` AS `Id`, p.`OrganizationId` AS `OrganizationId`, o.`Name` AS `OrganizationName`, p.`OrgScope` AS `OrgScope`
|
||||
FROM `role_org_perm` p
|
||||
LEFT JOIN `organization` o ON o.`Id` = p.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
LEFT JOIN `{{FakeTables.Organization}}` o ON o.`Id` = p.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
WHERE p.`IsDeleted` = 0 AND p.`RoleId` = {0}
|
||||
""", roleId.ToString()).ToListAsync(cancellationToken);
|
||||
|
||||
@ -520,7 +521,7 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
|
||||
public async Task<List<FieldMaskItemDto>> GetFieldMasksAsync(string dataResourceCode, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $"""
|
||||
SELECT m.`FieldName` AS `FieldName`, m.`SecretLevel` AS `SecretLevel`, m.`MaskType` AS `MaskType`, m.`MaskPattern` AS `MaskPattern`
|
||||
FROM `data_perm_field_mask` m
|
||||
WHERE m.`IsDeleted` = 0 AND m.`IsEnabled` = 1 AND m.`DataResourceCode` = {0}
|
||||
@ -640,7 +641,7 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
|
||||
public async Task<DataPermTemplateDetailDto> GetTemplateDetailAsync(Guid templateId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string headerSql = """
|
||||
var headerSql = $"""
|
||||
SELECT t.`Id` AS `Id`, t.`Name` AS `Name`, t.`Code` AS `Code`, t.`Description` AS `Description`,
|
||||
t.`RoleCode` AS `RoleCode`, t.`IsBuiltIn` AS `IsBuiltIn`
|
||||
FROM `data_perm_template` t
|
||||
@ -652,7 +653,7 @@ public class DataPermStore(FakeRbacDbContext dbContext, DataPermContextCache cac
|
||||
.FirstOrDefaultAsync(cancellationToken)
|
||||
?? throw new BusinessException("模板不存在");
|
||||
|
||||
const string itemSql = """
|
||||
var itemSql = $"""
|
||||
SELECT i.`Id` AS `Id`, i.`DimensionType` AS `DimensionType`, CAST(i.`ItemContent` AS CHAR) AS `ItemContentJson`, i.`SortOrder` AS `SortOrder`
|
||||
FROM `data_perm_template_item` i
|
||||
WHERE i.`TemplateId` = {0} AND i.`IsDeleted` = 0
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.Customers;
|
||||
|
||||
@ -41,18 +42,17 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
return null;
|
||||
}
|
||||
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
u.`Name` AS `Name`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`userid` = {0}
|
||||
LIMIT 1
|
||||
""";
|
||||
|
||||
return await dbContext.Database
|
||||
.SqlQueryRaw<AdvisorRow>(sql, userId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
@ -60,13 +60,13 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
|
||||
private async Task<AdvisorRow?> FindByNameOrAccountAsync(string key, CancellationToken cancellationToken)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
u.`Name` AS `Name`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND (u.`Name` = {0} OR u.`Account` = {0})
|
||||
ORDER BY u.`CreateTime` ASC
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.Rbac;
|
||||
|
||||
@ -7,20 +8,19 @@ namespace Oms.Application.Rbac;
|
||||
|
||||
public class InternalUserRepository(FakeRbacDbContext dbContext) : IScopedDependency
|
||||
{
|
||||
private const string InternalUserFilter = """
|
||||
private static readonly string InternalUserFilter = $$"""
|
||||
(
|
||||
NOT EXISTS (SELECT 1 FROM `user_role` ur0 WHERE ur0.`UserId` = u.`Id`)
|
||||
NOT EXISTS (SELECT 1 FROM `{{FakeTables.UserRole}}` ur0 WHERE ur0.`UserId` = u.`Id`)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM `user_role` ur
|
||||
INNER JOIN `role` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
INNER JOIN `{{FakeTables.Role}}` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
WHERE ur.`UserId` = u.`Id`
|
||||
AND r.`Code` <> 'Customer'
|
||||
AND r.`Code` NOT LIKE 'CustomerSub\_%'
|
||||
)
|
||||
)
|
||||
""";
|
||||
|
||||
public async Task<InternalUserListResultDto> GetInternalUsersAsync(
|
||||
string? keyword,
|
||||
Guid? organizationId,
|
||||
@ -45,16 +45,16 @@ public class InternalUserRepository(FakeRbacDbContext dbContext) : IScopedDepend
|
||||
args.Add(organizationId.Value.ToString());
|
||||
}
|
||||
|
||||
var countSql = $"""
|
||||
var countSql = $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
{where}
|
||||
""";
|
||||
var total = await dbContext.Database.SqlQueryRaw<long>(countSql, args.ToArray())
|
||||
.FirstAsync(cancellationToken);
|
||||
|
||||
var offset = Math.Max(page - 1, 0) * pageSize;
|
||||
var listSql = $"""
|
||||
var listSql = $$"""
|
||||
SELECT
|
||||
u.`Id` AS `Id`,
|
||||
u.`Name` AS `Name`,
|
||||
@ -67,13 +67,12 @@ public class InternalUserRepository(FakeRbacDbContext dbContext) : IScopedDepend
|
||||
u.`OrganizationId` AS `OrganizationId`,
|
||||
o.`Name` AS `OrganizationName`,
|
||||
u.`CreateTime` AS `CreatedAt`
|
||||
FROM `user` u
|
||||
LEFT JOIN `organization` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.User}}` u
|
||||
LEFT JOIN `{{FakeTables.Organization}}` o ON o.`Id` = u.`OrganizationId` AND o.`IsDeleted` = 0
|
||||
{where}
|
||||
ORDER BY u.`CreateTime` DESC
|
||||
LIMIT {pageSize} OFFSET {offset}
|
||||
""";
|
||||
|
||||
var rows = await dbContext.Database.SqlQueryRaw<InternalUserRow>(listSql, args.ToArray())
|
||||
.ToListAsync(cancellationToken);
|
||||
if (rows.Count == 0)
|
||||
@ -112,14 +111,14 @@ public class InternalUserRepository(FakeRbacDbContext dbContext) : IScopedDepend
|
||||
}
|
||||
|
||||
var inClause = string.Join(",", userIds.Select(x => $"'{x}'"));
|
||||
var sql = $"""
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
ur.`UserId` AS `UserId`,
|
||||
r.`Id` AS `RoleId`,
|
||||
r.`Name` AS `RoleName`,
|
||||
r.`Code` AS `RoleCode`
|
||||
FROM `user_role` ur
|
||||
INNER JOIN `role` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
INNER JOIN `{{FakeTables.Role}}` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
WHERE ur.`UserId` IN ({inClause})
|
||||
ORDER BY r.`Name`
|
||||
""";
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.Rbac;
|
||||
|
||||
@ -15,18 +16,17 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
|
||||
public async Task<UserProfileData?> GetAsync(Guid userId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
u.`Phone` AS `Phone`,
|
||||
u.`EmployeeNo` AS `EmployeeNo`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`Id` = {0} AND u.`IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""";
|
||||
|
||||
var row = await dbContext.Database
|
||||
.SqlQueryRaw<UserProfileRow>(sql, userId.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
@ -56,7 +56,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
}
|
||||
|
||||
var inClause = string.Join(",", userIds.Select(x => $"'{x}'"));
|
||||
var sql = $"""
|
||||
var sql = $$"""
|
||||
SELECT
|
||||
u.`Id` AS `UserId`,
|
||||
u.`Phone` AS `Phone`,
|
||||
@ -64,7 +64,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`Id` IN ({inClause}) AND u.`IsDeleted` = 0
|
||||
""";
|
||||
|
||||
@ -83,8 +83,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
|
||||
public async Task SaveAsync(Guid userId, UserProfileData profile, CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
UPDATE `user`
|
||||
var sql = $$"""
|
||||
UPDATE `{{FakeTables.User}}`
|
||||
SET
|
||||
`Phone` = {1},
|
||||
`EmployeeNo` = {2},
|
||||
@ -93,7 +93,6 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
`WecomKfUrl` = {5}
|
||||
WHERE `Id` = {0} AND `IsDeleted` = 0
|
||||
""";
|
||||
|
||||
await dbContext.Database.ExecuteSqlRawAsync(
|
||||
sql,
|
||||
[
|
||||
@ -113,8 +112,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
UserProfileData profile,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
UPDATE `user`
|
||||
var sql = $$"""
|
||||
UPDATE `{{FakeTables.User}}`
|
||||
SET
|
||||
`Phone` = {1},
|
||||
`WechatId` = {2},
|
||||
@ -142,16 +141,16 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
{
|
||||
var normalized = employeeNo.Trim().ToUpperInvariant();
|
||||
var sql = excludeUserId.HasValue
|
||||
? """
|
||||
? $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`EmployeeNo` = {0}
|
||||
AND u.`Id` <> {1}
|
||||
"""
|
||||
: """
|
||||
: $$"""
|
||||
SELECT COUNT(*) AS `Value`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`EmployeeNo` = {0}
|
||||
""";
|
||||
@ -166,9 +165,9 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
|
||||
public async Task<string> GenerateNextEmployeeNoAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT u.`EmployeeNo` AS `EmployeeNo`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`EmployeeNo` IS NOT NULL
|
||||
AND u.`EmployeeNo` <> ''
|
||||
|
||||
@ -5,6 +5,7 @@ using Fake.Rbac.Application.Dtos.User;
|
||||
using Fake.Rbac.Application.Services;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.Customers;
|
||||
@ -203,8 +204,9 @@ public class CustomerService : ApplicationService
|
||||
// 同步 RBAC 登录邮箱,覆盖注册时的 @noemail.local 占位
|
||||
try
|
||||
{
|
||||
await RbacDbContext.Database.ExecuteSqlInterpolatedAsync(
|
||||
$"UPDATE `user` SET `Email` = {email} WHERE `userid` = {customer.UserId} AND `IsDeleted` = 0");
|
||||
await RbacDbContext.Database.ExecuteSqlRawAsync(
|
||||
$"UPDATE `{FakeTables.User}` SET `Email` = {{0}} WHERE `userid` = {{1}} AND `IsDeleted` = 0",
|
||||
email, customer.UserId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -390,8 +392,8 @@ public class CustomerService : ApplicationService
|
||||
|
||||
private async Task<Guid?> GetRbacUserGuidByMapIdAsync(int mapId)
|
||||
{
|
||||
return await RbacDbContext.Database.SqlQuery<Guid?>(
|
||||
$"select `Id` as `Value` from `user` where `userid` = {mapId} and `IsDeleted` = 0")
|
||||
return await RbacDbContext.Database.SqlQueryRaw<Guid?>(
|
||||
$"select `Id` as `Value` from `{FakeTables.User}` where `userid` = {{0}} and `IsDeleted` = 0", mapId)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
@ -495,8 +497,8 @@ public class CustomerService : ApplicationService
|
||||
|
||||
private async Task<int> GetRbacUserMapIdOrThrowAsync(Guid id)
|
||||
{
|
||||
var userId = await RbacDbContext.Database.SqlQuery<int?>(
|
||||
$"select `userid` as `Value` from `user` where `Id` = {id}")
|
||||
var userId = await RbacDbContext.Database.SqlQueryRaw<int?>(
|
||||
$"select `userid` as `Value` from `{FakeTables.User}` where `Id` = {{0}}", id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (!userId.HasValue || userId.Value <= 0)
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq.Expressions;
|
||||
using Fake.Application;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
@ -24,20 +25,19 @@ public class NoticeService : ApplicationService
|
||||
private const string ReceiverTypeUser = "user";
|
||||
private const string ReceiverTypeCustomer = "customer";
|
||||
|
||||
private const string InternalUserFilter = """
|
||||
private static readonly string InternalUserFilter = $$"""
|
||||
(
|
||||
NOT EXISTS (SELECT 1 FROM `user_role` ur0 WHERE ur0.`UserId` = u.`Id`)
|
||||
NOT EXISTS (SELECT 1 FROM `{{FakeTables.UserRole}}` ur0 WHERE ur0.`UserId` = u.`Id`)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM `user_role` ur
|
||||
INNER JOIN `role` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
FROM `{{FakeTables.UserRole}}` ur
|
||||
INNER JOIN `{{FakeTables.Role}}` r ON r.`Id` = ur.`RoleId` AND r.`IsDeleted` = 0
|
||||
WHERE ur.`UserId` = u.`Id`
|
||||
AND r.`Code` <> 'Customer'
|
||||
AND r.`Code` NOT LIKE 'CustomerSub\_%'
|
||||
)
|
||||
)
|
||||
""";
|
||||
|
||||
private INoticeRepository NoticeRepository => LazyServiceProvider.GetRequiredService<INoticeRepository>();
|
||||
private INoticeReadRepository NoticeReadRepository => LazyServiceProvider.GetRequiredService<INoticeReadRepository>();
|
||||
private ICustomerRepository CustomerRepository => LazyServiceProvider.GetRequiredService<ICustomerRepository>();
|
||||
@ -239,15 +239,15 @@ public class NoticeService : ApplicationService
|
||||
args.Add(pattern);
|
||||
}
|
||||
|
||||
var countSql = $"SELECT COUNT(*) AS `Value` FROM `user` u {where}";
|
||||
var countSql = $"SELECT COUNT(*) AS `Value` FROM `{{FakeTables.User}}` u {where}";
|
||||
var total = await RbacDbContext.Database.SqlQueryRaw<long>(countSql, args.ToArray()).FirstAsync();
|
||||
var offset = Math.Max(pageIndex - 1, 0) * pageSize;
|
||||
var listSql = $"""
|
||||
var listSql = $$"""
|
||||
SELECT
|
||||
u.`userid` AS `Value`,
|
||||
u.`Name` AS `Label`,
|
||||
u.`Account` AS `Extra`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
{where}
|
||||
ORDER BY u.`Name`, u.`userid`
|
||||
LIMIT {pageSize} OFFSET {offset}
|
||||
@ -465,7 +465,7 @@ public class NoticeService : ApplicationService
|
||||
return [];
|
||||
}
|
||||
|
||||
var sql = $"SELECT `userid` AS `UserId` FROM `user` WHERE `IsDeleted` = 0 AND `userid` IN ({string.Join(",", userIds)})";
|
||||
var sql = $"SELECT `userid` AS `UserId` FROM `{{FakeTables.User}}` WHERE `IsDeleted` = 0 AND `userid` IN ({string.Join(",", userIds)})";
|
||||
return await RbacDbContext.Database.SqlQueryRaw<UserIdQueryResult>(sql)
|
||||
.Select(x => x.UserId)
|
||||
.ToListAsync();
|
||||
|
||||
@ -2,6 +2,7 @@ using System.Net.Mail;
|
||||
using System.Text.RegularExpressions;
|
||||
using Fake.Application;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Oms.Application.Shared;
|
||||
@ -167,13 +168,13 @@ public static class OmsRbacRegistrationGuard
|
||||
}
|
||||
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"""
|
||||
.SqlQueryRaw<int?>(
|
||||
$$"""
|
||||
SELECT 1 AS Value
|
||||
FROM `organization`
|
||||
WHERE `Id` = {organizationId.Value.ToString()} AND `IsDeleted` = 0
|
||||
FROM `{{FakeTables.Organization}}`
|
||||
WHERE `Id` = {0} AND `IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""")
|
||||
""", organizationId.Value.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (!hit.HasValue)
|
||||
@ -201,13 +202,13 @@ public static class OmsRbacRegistrationGuard
|
||||
foreach (var roleId in ids)
|
||||
{
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"""
|
||||
.SqlQueryRaw<int?>(
|
||||
$$"""
|
||||
SELECT 1 AS Value
|
||||
FROM `role`
|
||||
WHERE `Id` = {roleId.ToString()} AND `IsDeleted` = 0
|
||||
FROM `{{FakeTables.Role}}`
|
||||
WHERE `Id` = {0} AND `IsDeleted` = 0
|
||||
LIMIT 1
|
||||
""")
|
||||
""", roleId.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (!hit.HasValue)
|
||||
@ -492,15 +493,16 @@ public static class OmsRbacRegistrationGuard
|
||||
if (excludeUserId is Guid id && id != Guid.Empty)
|
||||
{
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Account` = {account} AND `Id` <> {id.ToString()} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Account` = {0} AND `Id` <> {1} LIMIT 1",
|
||||
account, id.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return hit.HasValue;
|
||||
}
|
||||
|
||||
var any = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Account` = {account} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Account` = {0} LIMIT 1", account)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return any.HasValue;
|
||||
}
|
||||
@ -514,15 +516,16 @@ public static class OmsRbacRegistrationGuard
|
||||
if (excludeUserId is Guid id && id != Guid.Empty)
|
||||
{
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Email` = {email} AND `Id` <> {id.ToString()} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Email` = {0} AND `Id` <> {1} LIMIT 1",
|
||||
email, id.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return hit.HasValue;
|
||||
}
|
||||
|
||||
var any = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Email` = {email} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Email` = {0} LIMIT 1", email)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return any.HasValue;
|
||||
}
|
||||
@ -536,15 +539,16 @@ public static class OmsRbacRegistrationGuard
|
||||
if (excludeUserId is Guid id && id != Guid.Empty)
|
||||
{
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Phone` = {phone} AND `Id` <> {id.ToString()} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Phone` = {0} AND `Id` <> {1} LIMIT 1",
|
||||
phone, id.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return hit.HasValue;
|
||||
}
|
||||
|
||||
var any = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `Phone` = {phone} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `Phone` = {0} LIMIT 1", phone)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return any.HasValue;
|
||||
}
|
||||
@ -558,15 +562,16 @@ public static class OmsRbacRegistrationGuard
|
||||
if (excludeUserId is Guid id && id != Guid.Empty)
|
||||
{
|
||||
var hit = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `WechatId` = {wechatId} AND `Id` <> {id.ToString()} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `WechatId` = {0} AND `Id` <> {1} LIMIT 1",
|
||||
wechatId, id.ToString())
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return hit.HasValue;
|
||||
}
|
||||
|
||||
var any = await rbacDbContext.Database
|
||||
.SqlQuery<int?>(
|
||||
$"SELECT 1 AS Value FROM `user` WHERE `WechatId` = {wechatId} LIMIT 1")
|
||||
.SqlQueryRaw<int?>(
|
||||
$"SELECT 1 AS Value FROM `{{FakeTables.User}}` WHERE `WechatId` = {0} LIMIT 1", wechatId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
return any.HasValue;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Fake.DependencyInjection;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Oms.Application.Shared;
|
||||
@ -40,7 +41,7 @@ public class OmsRbacUserDisplayNameResolver : IScopedDependency
|
||||
try
|
||||
{
|
||||
var sql =
|
||||
$"SELECT `userid` AS `{nameof(RbacUserNameRow.UserId)}`, `Name` AS `{nameof(RbacUserNameRow.DisplayName)}` FROM `user` WHERE `IsDeleted` = 0 AND `userid` IN ({string.Join(",", ids)})";
|
||||
$"SELECT `userid` AS `{nameof(RbacUserNameRow.UserId)}`, `Name` AS `{nameof(RbacUserNameRow.DisplayName)}` FROM `{FakeTables.User}` WHERE `IsDeleted` = 0 AND `userid` IN ({string.Join(",", ids)})";
|
||||
var rows = await _rbacDbContext.Database
|
||||
.SqlQueryRaw<RbacUserNameRow>(sql)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oms.Domain.CustomersAggregate.Entities;
|
||||
|
||||
@ -44,9 +45,9 @@ public static class StaffAdvisorBinder
|
||||
string key,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
const string sql = """
|
||||
var sql = $$"""
|
||||
SELECT u.`Account` AS `Account`
|
||||
FROM `user` u
|
||||
FROM `{{FakeTables.User}}` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`Account` = {0}
|
||||
ORDER BY u.`CreateTime` ASC
|
||||
|
||||
@ -12,6 +12,7 @@ using Fake.Rbac.Domain.UserAggregate;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.Users;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -904,15 +905,15 @@ public partial class AuthService(
|
||||
|
||||
private async Task<Guid?> GetRbacUserGuidByMapIdAsync(int userId, CancellationToken cancellationToken)
|
||||
{
|
||||
return await rbacDbContext.Database.SqlQuery<Guid?>(
|
||||
$"select `Id` as `Value` from `user` where `IsDeleted` = 0 and `userid` = {userId}")
|
||||
return await rbacDbContext.Database.SqlQueryRaw<Guid?>(
|
||||
$"select `Id` as `Value` from `{FakeTables.User}` where `IsDeleted` = 0 and `userid` = {{0}}", userId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<int?> GetMapIdByUserGuidAsync(Guid userId, CancellationToken cancellationToken)
|
||||
{
|
||||
return await rbacDbContext.Database.SqlQuery<int?>(
|
||||
$"select `userid` as `Value` from `user` where `Id` = {userId}")
|
||||
return await rbacDbContext.Database.SqlQueryRaw<int?>(
|
||||
$"select `userid` as `Value` from `{FakeTables.User}` where `Id` = {{0}}", userId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ public class SimpleAdminApiModule : FakeModule
|
||||
// 路由 - 必须在认证和授权之前
|
||||
app.UseRouting();
|
||||
|
||||
// EventBus Dashboard(CAP 风格;也可依赖 IStartupFilter 自动挂载,这里显式保证顺序)
|
||||
// EventBus Dashboard:必须在 UsePathBase 之后,否则 /admin/eventbus 会 404
|
||||
app.UseFakeEventBusDashboard();
|
||||
|
||||
// OpenAPI 验签需读取原始 Body,允许二次读流
|
||||
|
||||
@ -5,6 +5,7 @@ using Fake.Rbac.Application.Jwt;
|
||||
using Fake.Rbac.Application.Services;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
@ -21,8 +22,8 @@ public class SimpleJwtService(IOptions<FakeJwtOptions> jwtOptions, UserService u
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var claims = await base.GenerateClaimsByUserIdAsync(userId, cancellationToken);
|
||||
var mapId = await rbacDbContext.Database.SqlQuery<int?>(
|
||||
$"select `userid` as `Value` from `user` where `Id` = {userId}")
|
||||
var mapId = await rbacDbContext.Database.SqlQueryRaw<int?>(
|
||||
$"select `userid` as `Value` from `{FakeTables.User}` where `Id` = {{0}}", userId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (mapId.HasValue)
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@ using Fake.Rbac.Application.Dtos.Role;
|
||||
using Fake.Rbac.Application.Dtos.User;
|
||||
using Fake.Rbac.Application.Services;
|
||||
using Fake.Rbac.Infrastructure;
|
||||
using Fake.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -323,8 +324,8 @@ public class WeChatCustomerService(
|
||||
|
||||
private async Task<int> GetRbacUserMapIdOrThrowAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = await rbacDbContext.Database.SqlQuery<int?>(
|
||||
$"select `userid` as `Value` from `user` where `Id` = {id}")
|
||||
var userId = await rbacDbContext.Database.SqlQueryRaw<int?>(
|
||||
$"select `userid` as `Value` from `{FakeTables.User}` where `Id` = {{0}}", id)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (!userId.HasValue || userId.Value <= 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user