😎匿名接口增加数据时默认租户ID

This commit is contained in:
zuohuaijun 2025-04-25 16:43:03 +08:00
parent f5183e4acc
commit 39ef29673c
3 changed files with 14 additions and 3 deletions

View File

@ -67,4 +67,15 @@ public class TestService : IDynamicApiController
_logger.LogWarning($"信息{DateTime.Now}");
}
/// <summary>
/// 匿名上传文件测试
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[AllowAnonymous]
public async Task<SysFile> UploadFile([FromForm] UploadFileInput input)
{
return await App.GetRequiredService<SysFileService>().UploadFile(input);
}
}

View File

@ -54,9 +54,9 @@
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.12.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.189" />
<PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1226" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1227" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@ -238,7 +238,7 @@ public static class SqlSugarSetup
if (entityInfo.PropertyName == nameof(EntityTenantId.TenantId))
{
if (entityValue.TenantId == null || entityValue.TenantId == 0)
entityInfo.SetValue(App.User.FindFirst(ClaimConst.TenantId)?.Value);
entityInfo.SetValue(App.User.FindFirst(ClaimConst.TenantId)?.Value ?? SqlSugarConst.DefaultTenantId.ToString());
}
else if (entityInfo.PropertyName == nameof(EntityBase.CreateUserId))
{