Browse Source

feat: 重新设计文件模块

feat/file
Hanpaopao 1 year ago
parent
commit
0adb292d5a
  1. 38
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/CreateFileObjectInput.cs
  2. 12
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/DeleteFileObjectInput.cs
  3. 8
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/CreateFileInput.cs
  4. 19
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/FileTokenOutput.cs
  5. 14
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/PagingFileOutput.cs
  6. 6
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/PagingInput.cs
  7. 9
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/GetFileObjectInput.cs
  8. 44
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/GetFileObjectOutput.cs
  9. 25
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/IFileAppService.cs
  10. 22
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/PageFileObjectInput.cs
  11. 47
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/PageFileObjectOutput.cs
  12. 43
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/UpdateFileInput.cs
  13. 13
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/UploadOutput.cs
  14. 1
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Lion.AbpPro.FileManagement.Application.Contracts.csproj
  15. 5
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Permissions/FileManagementPermissionDefinitionProvider.cs
  16. 5
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/FileManagementApplicationAutoMapperProfile.cs
  17. 27
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/FileManagementApplicationModule.cs
  18. 120
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/Files/FileAppService.cs
  19. 6
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/GlobalUsings.cs
  20. 2
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/Lion.AbpPro.FileManagement.Application.csproj
  21. 51
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Files/FileObjectDto.cs
  22. 26
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Provider/UpdateDto.cs
  23. 17
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Provider/UpdateResult.cs
  24. 2
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDbProperties.cs
  25. 13
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDomainAutoMapperProfile.cs
  26. 7
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDomainModule.cs
  27. 22
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/Aggregates/File.cs
  28. 33
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileManager.cs
  29. 137
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileObject.cs
  30. 65
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileObjectManager.cs
  31. 15
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileManager.cs
  32. 8
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileObjectRepository.cs
  33. 13
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileRepository.cs
  34. 1
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Lion.AbpPro.FileManagement.Domain.csproj
  35. 30
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Provider/DatabaseFileProvider.cs
  36. 6
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Provider/IFileProvider.cs
  37. 2
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/FileManagementDbContext.cs
  38. 13
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/FileManagementDbContextModelCreatingExtensions.cs
  39. 49
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/Files/EfCoreFileObjectRepository.cs
  40. 31
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/Files/EfCoreFileRepository.cs
  41. 6
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/IFileManagementDbContext.cs
  42. 1
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/Lion.AbpPro.FileManagement.EntityFrameworkCore.csproj
  43. 38
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.HttpApi/Files/FileController.cs
  44. 1
      aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.HttpApi/GlobalUsings.cs
  45. 2
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json
  46. 5
      aspnet-core/services/src/Lion.AbpPro.Application.Contracts/AbpProApplicationContractsModule.cs
  47. 1
      aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj
  48. 3
      aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs
  49. 1
      aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj
  50. 4
      aspnet-core/services/src/Lion.AbpPro.Domain.Shared/AbpProDomainSharedModule.cs
  51. 1
      aspnet-core/services/src/Lion.AbpPro.Domain.Shared/Lion.AbpPro.Domain.Shared.csproj
  52. 5
      aspnet-core/services/src/Lion.AbpPro.Domain/AbpProDomainModule.cs
  53. 1
      aspnet-core/services/src/Lion.AbpPro.Domain/Lion.AbpPro.Domain.csproj
  54. 12
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/EntityFrameworkCore/AbpProDbContext.cs
  55. 4
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/EntityFrameworkCore/AbpProEntityFrameworkCoreModule.cs
  56. 1
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj
  57. 2179
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/20250215074519_1.0.2.Designer.cs
  58. 61
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/20250215074519_1.0.2.cs
  59. 90
      aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/AbpProDbContextModelSnapshot.cs
  60. 4
      aspnet-core/services/src/Lion.AbpPro.HttpApi.Client/AbpProHttpApiClientModule.cs
  61. 1
      aspnet-core/services/src/Lion.AbpPro.HttpApi.Client/Lion.AbpPro.HttpApi.Client.csproj
  62. 4
      aspnet-core/services/src/Lion.AbpPro.HttpApi/AbpProHttpApiModule.cs
  63. 1
      aspnet-core/services/src/Lion.AbpPro.HttpApi/Lion.AbpPro.HttpApi.csproj

38
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/CreateFileObjectInput.cs

@ -0,0 +1,38 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 创建文件
/// </summary>
public class CreateFileObjectInput
{
/// <summary>
/// 文件Provider
/// </summary>
[Required(ErrorMessage = "文件Provider不能为空")]
public string ProviderKey { get; set; }
/// <summary>
/// 文件扩展名
/// </summary>
[Required(ErrorMessage = "文件扩展名不能为空")]
public string FileExtension { get; set; }
/// <summary>
/// 二进制数据
/// </summary>
[Required(ErrorMessage = "二进制数据不能为空")]
public long Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
[Required(ErrorMessage = "文件大小不能为空")]
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
[Required(ErrorMessage = "文件名称不能为空")]
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
[Required(ErrorMessage = "文件名称不能为空")]
public string FileName { get; set; }
}

12
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/DeleteFileObjectInput.cs

@ -0,0 +1,12 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 删除文件
/// </summary>
public class DeleteFileObjectInput
{
/// <summary>
/// 文件Id
/// </summary>
public Guid Id { get; set; }
}

8
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/CreateFileInput.cs

@ -1,8 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files.Dto;
public class CreateFileInput
{
[Required(ErrorMessage = "文件名不能为空")] public string FileName { get; set; }
[Required(ErrorMessage = "文件地址不能为空")] public string FilePath { get; set; }
}

19
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/FileTokenOutput.cs

@ -1,19 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files.Dto;
public class FileTokenOutput
{
public string AccessKeyId { get; set; }
public string AccessKeySecret { get; set; }
public string Token { get; set; }
/// <summary>
/// 过期时间
/// </summary>
public string Expiration { get; set; }
public string Bucket { get; set; }
public string Region { get; set; }
}

14
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/PagingFileOutput.cs

@ -1,14 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files.Dto;
public class PagingFileOutput
{
public Guid Id { get; set; }
public Guid? TenantId { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
public DateTime CreationTime { get; set; }
}

6
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/Dto/PagingInput.cs

@ -1,6 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files.Dto;
public class PagingFileInput : PagingBase
{
public string Filter { get; set; }
}

9
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/GetFileObjectInput.cs

@ -0,0 +1,9 @@
namespace Lion.AbpPro.FileManagement.Files;
public class GetFileObjectInput
{
/// <summary>
/// 文件Id
/// </summary>
public Guid Id { get; set; }
}

44
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/GetFileObjectOutput.cs

@ -0,0 +1,44 @@
namespace Lion.AbpPro.FileManagement.Files;
public class GetFileObjectOutput
{
/// <summary>
/// 文件Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 文件Provider
/// </summary>
public string ProviderKey { get; set; }
/// <summary>
/// 文件扩展名
/// </summary>
public string FileExtension { get; set; }
/// <summary>
/// 二进制数据
/// </summary>
public byte[] Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreationTime { get; set; }
}

25
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/IFileAppService.cs

@ -1,15 +1,28 @@
using System.Collections.Generic; using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Lion.AbpPro.FileManagement.Files.Dto;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace Lion.AbpPro.FileManagement.Files; namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 文件
/// </summary>
public interface IFileAppService : IApplicationService public interface IFileAppService : IApplicationService
{ {
Task<FileTokenOutput> GetFileTokenAsync(); /// <summary>
Task CreateAsync(CreateFileInput input); /// 分页查询文件
/// </summary>
Task<PagedResultDto<PageFileObjectOutput>> PageAsync(PageFileObjectInput input);
Task<PagedResultDto<PagingFileOutput>> PagingAsync(PagingFileInput input); /// <summary>
/// 上传文件
/// </summary>
Task<List<UploadOutput>> UploadAsync(List<IFormFile> files);
/// <summary>
/// 删除文件
/// </summary>
Task DeleteAsync(DeleteFileObjectInput input);
Task<GetFileObjectOutput> GetAsync(GetFileObjectInput input);
} }

22
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/PageFileObjectInput.cs

@ -0,0 +1,22 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 分页查询文件
/// </summary>
public class PageFileObjectInput : PagingBase
{
/// <summary>
/// 开始创建时间
/// </summary>
public DateTime? StartCreationTime { get; set; }
/// <summary>
/// 结束创建时间
/// </summary>
public DateTime? EndCreationTime { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
}

47
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/PageFileObjectOutput.cs

@ -0,0 +1,47 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 分页查询文件
/// </summary>
public class PageFileObjectOutput
{
/// <summary>
/// 文件Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 文件Provider
/// </summary>
public string ProviderKey { get; set; }
/// <summary>
/// 文件扩展名
/// </summary>
public string FileExtension { get; set; }
// /// <summary>
// /// 二进制数据
// /// </summary>
// public byte[] Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreationTime { get; set; }
}

43
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/UpdateFileInput.cs

@ -0,0 +1,43 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 更新文件
/// </summary>
public class UpdateFileInput
{
/// <summary>
/// 文件Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 文件Provider
/// </summary>
[Required(ErrorMessage = "文件Provider不能为空")]
public string ProviderKey { get; set; }
/// <summary>
/// 文件扩展名
/// </summary>
[Required(ErrorMessage = "文件扩展名不能为空")]
public string FileExtension { get; set; }
/// <summary>
/// 二进制数据
/// </summary>
[Required(ErrorMessage = "二进制数据不能为空")]
public long Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
[Required(ErrorMessage = "文件大小不能为空")]
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
[Required(ErrorMessage = "文件名称不能为空")]
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
[Required(ErrorMessage = "文件名称不能为空")]
public string FileName { get; set; }
}

13
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Files/UploadOutput.cs

@ -0,0 +1,13 @@
namespace Lion.AbpPro.FileManagement.Files;
public class UploadOutput
{
public Guid Id { get; set; }
public string Name { get; set; }
public bool Success { get; set; }
public string Path { get; set; }
}

1
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Lion.AbpPro.FileManagement.Application.Contracts.csproj

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" /> <PackageReference Include="Volo.Abp.Ddd.Application.Contracts" />
<PackageReference Include="Volo.Abp.Authorization" /> <PackageReference Include="Volo.Abp.Authorization" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" />
<ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain.Shared\Lion.AbpPro.FileManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain.Shared\Lion.AbpPro.FileManagement.Domain.Shared.csproj" />
</ItemGroup> </ItemGroup>

5
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application.Contracts/Permissions/FileManagementPermissionDefinitionProvider.cs

@ -4,13 +4,10 @@ public class FileManagementPermissionDefinitionProvider : PermissionDefinitionPr
{ {
public override void Define(IPermissionDefinitionContext context) public override void Define(IPermissionDefinitionContext context)
{ {
var abpIdentityGroup = context.GetGroup("AbpIdentity"); var abpIdentityGroup = context.GetGroup("AbpIdentity");
var dataDictionaryManagement = abpIdentityGroup.AddPermission(FileManagementPermissions.FileManagement.Default, var fileManagement = abpIdentityGroup.AddPermission(FileManagementPermissions.FileManagement.Default,
L("Permission:FileManagement")); L("Permission:FileManagement"));
dataDictionaryManagement.AddChild(FileManagementPermissions.FileManagement.Upload, L("Permission:Upload"));
//dataDictionaryManagement.AddChild(FileManagementPermissions.FileManagement.Down, L("Permission:Down"));
} }
private static LocalizableString L(string name) private static LocalizableString L(string name)

5
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/FileManagementApplicationAutoMapperProfile.cs

@ -1,9 +1,12 @@
using Lion.AbpPro.FileManagement.Files;
namespace Lion.AbpPro.FileManagement; namespace Lion.AbpPro.FileManagement;
public class FileManagementApplicationAutoMapperProfile : Profile public class FileManagementApplicationAutoMapperProfile : Profile
{ {
public FileManagementApplicationAutoMapperProfile() public FileManagementApplicationAutoMapperProfile()
{ {
CreateMap<Lion.AbpPro.FileManagement.Files.File, PagingFileOutput>(); CreateMap<Files.FileObjectDto, PageFileObjectOutput>();
CreateMap<Files.FileObjectDto, GetFileObjectOutput>();
} }
} }

27
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/FileManagementApplicationModule.cs

@ -4,38 +4,13 @@ namespace Lion.AbpPro.FileManagement;
typeof(FileManagementDomainModule), typeof(FileManagementDomainModule),
typeof(FileManagementApplicationContractsModule), typeof(FileManagementApplicationContractsModule),
typeof(AbpDddApplicationModule), typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule), typeof(AbpAutoMapperModule)
typeof(AbpBlobStoringAliyunModule)
)] )]
public class FileManagementApplicationModule : AbpModule public class FileManagementApplicationModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<FileManagementApplicationModule>(); context.Services.AddAutoMapperObjectMapper<FileManagementApplicationModule>();
ConfigureBlobStoringAliyun(context);
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<FileManagementApplicationModule>(true); }); Configure<AbpAutoMapperOptions>(options => { options.AddMaps<FileManagementApplicationModule>(true); });
} }
private void ConfigureBlobStoringAliyun(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<AbpBlobStoringOptions>(options =>
{
options.Containers.ConfigureDefault(container =>
{
container.UseAliyun(aliyun =>
{
aliyun.AccessKeyId =
configuration.GetValue<string>("AliYun:OSS:AccessKeyId");
aliyun.AccessKeySecret =
configuration.GetValue<string>("AliYun:OSS:AccessKeySecret");
aliyun.Endpoint = configuration.GetValue<string>("AliYun:OSS:Endpoint");
aliyun.RegionId = configuration.GetValue<string>("AliYun:OSS:RegionId");
aliyun.ContainerName =
configuration.GetValue<string>("AliYun:OSS:ContainerName");
});
});
});
}
} }

120
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/Files/FileAppService.cs

@ -1,59 +1,97 @@
namespace Lion.AbpPro.FileManagement.Files; using Lion.AbpPro.FileManagement.Provider;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
[Authorize(FileManagementPermissions.FileManagement.Default)] namespace Lion.AbpPro.FileManagement.Files;
public class FileAppService : FileManagementAppService, IFileAppService
/// <summary>
/// 文件
/// </summary>
[Authorize]
public class FileAppService : ApplicationService, IFileAppService
{ {
private readonly IFileManager _fileManager; private readonly FileObjectManager _fileObjectManager;
private readonly IConfiguration _configuration; private readonly IFileProvider _fileProvider;
public FileAppService(IFileManager fileManager, IConfiguration configuration) public FileAppService(FileObjectManager fileObjectManager, IFileProvider fileProvider)
{ {
_fileManager = fileManager; _fileObjectManager = fileObjectManager;
_configuration = configuration; _fileProvider = fileProvider;
} }
public virtual async Task<FileTokenOutput> GetFileTokenAsync() /// <summary>
/// 分页查询文件
/// </summary>
public async Task<PagedResultDto<PageFileObjectOutput>> PageAsync(PageFileObjectInput input)
{ {
// 如何设置 sts https://help.aliyun.com/document_detail/100624.html var result = new PagedResultDto<PageFileObjectOutput>();
var regionId = _configuration.GetValue<string>("AliYun:OSS:RegionId"); var totalCount = await _fileObjectManager.GetCountAsync(input.FileName, input.StartCreationTime, input.EndCreationTime);
var accessKeyId = _configuration.GetValue<string>("AliYun:OSS:AccessKeyId"); result.TotalCount = totalCount;
var accessKeySecret = _configuration.GetValue<string>("AliYun:OSS:AccessKeySecret"); if (totalCount <= 0) return result;
var profile = DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret); var list = await _fileObjectManager.GetListAsync(input.FileName, input.StartCreationTime, input.EndCreationTime, input.PageSize, input.SkipCount);
var client = new DefaultAcsClient(profile); result.Items = ObjectMapper.Map<List<FileObjectDto>, List<PageFileObjectOutput>>(list);
var request = new AssumeRoleRequest() return result;
}
public async Task<List<UploadOutput>> UploadAsync(List<IFormFile> files)
{ {
RoleArn = _configuration.GetValue<string>("AliYun:OSS:RoleArn"), var result = new List<UploadOutput>();
RoleSessionName = "Lion.AbpPro" foreach (var formFile in files)
}; {
var response = client.GetAcsResponse(request); try
{
var item = new UploadOutput();
// 获取文件的二进制数据
using var memoryStream = new MemoryStream();
await formFile.CopyToAsync(memoryStream);
var fileBytes = memoryStream.ToArray();
var result = new FileTokenOutput() // 这里可以对 fileBytes 进行后续处理,例如保存到数据库或文件系统等
// 示例:将文件保存到数据库
var updateResult = await _fileProvider.UploadAsync(new UpdateDto()
{ {
AccessKeyId = response.Credentials.AccessKeyId, FileName = formFile.FileName,
AccessKeySecret = response.Credentials.AccessKeySecret, Bytes = fileBytes,
Token = response.Credentials.SecurityToken, ContentType = formFile.ContentType,
Expiration = response.Credentials.Expiration, FileSize = formFile.Length
Region = _configuration.GetValue<string>("AliYun:OSS:RegionId"), });
Bucket = _configuration.GetValue<string>("AliYun:OSS:ContainerName"),
}; result.Add(new UploadOutput()
return await Task.FromResult(result); {
Id = updateResult.Id,
Name = updateResult.FileName,
Path = updateResult.FilePath,
Success = true
});
} }
catch (Exception e)
{
Logger.LogError(e, "上传文件失败");
result.Add(new UploadOutput()
{
Id = Guid.Empty,
Name = formFile.FileName,
Path = string.Empty,
Success = false
});
}
}
return result;
}
[Authorize(FileManagementPermissions.FileManagement.Upload)] /// <summary>
public virtual async Task CreateAsync(CreateFileInput input) /// 删除文件
/// </summary>
public Task DeleteAsync(DeleteFileObjectInput input)
{ {
await _fileManager.CreateAsync(input.FileName, input.FilePath); return _fileObjectManager.DeleteAsync(input.Id);
} }
public virtual async Task<PagedResultDto<PagingFileOutput>> PagingAsync(PagingFileInput input) public async Task<GetFileObjectOutput> GetAsync(GetFileObjectInput input)
{ {
var result = new PagedResultDto<PagingFileOutput>(); var file = await _fileObjectManager.GetAsync(input.Id);
var totalCount = await _fileManager.CountAsync(input.Filter); return ObjectMapper.Map<FileObjectDto, GetFileObjectOutput>(file);
result.TotalCount = totalCount;
if (totalCount <= 0) return result;
var entities = await _fileManager.PagingAsync(input.Filter, input.PageSize,
input.SkipCount);
result.Items = ObjectMapper.Map<List<File>, List<PagingFileOutput>>(entities);
return result;
} }
} }

6
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/GlobalUsings.cs

@ -2,11 +2,7 @@
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.Threading.Tasks; global using System.Threading.Tasks;
global using Aliyun.Acs.Core;
global using Aliyun.Acs.Core.Auth.Sts;
global using Aliyun.Acs.Core.Profile;
global using AutoMapper; global using AutoMapper;
global using Lion.AbpPro.FileManagement.Files.Dto;
global using Lion.AbpPro.FileManagement.Localization; global using Lion.AbpPro.FileManagement.Localization;
global using Lion.AbpPro.FileManagement.Permissions; global using Lion.AbpPro.FileManagement.Permissions;
global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Authorization;
@ -16,6 +12,4 @@ global using Volo.Abp.Application;
global using Volo.Abp.Application.Dtos; global using Volo.Abp.Application.Dtos;
global using Volo.Abp.Application.Services; global using Volo.Abp.Application.Services;
global using Volo.Abp.AutoMapper; global using Volo.Abp.AutoMapper;
global using Volo.Abp.BlobStoring;
global using Volo.Abp.BlobStoring.Aliyun;
global using Volo.Abp.Modularity; global using Volo.Abp.Modularity;

2
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Application/Lion.AbpPro.FileManagement.Application.csproj

@ -7,9 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
<PackageReference Include="Volo.Abp.AutoMapper" /> <PackageReference Include="Volo.Abp.AutoMapper" />
<PackageReference Include="Volo.Abp.Ddd.Application" /> <PackageReference Include="Volo.Abp.Ddd.Application" />
<PackageReference Include="Volo.Abp.BlobStoring.Aliyun" />
<ProjectReference Include="..\Lion.AbpPro.FileManagement.Application.Contracts\Lion.AbpPro.FileManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\Lion.AbpPro.FileManagement.Application.Contracts\Lion.AbpPro.FileManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain\Lion.AbpPro.FileManagement.Domain.csproj" /> <ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain\Lion.AbpPro.FileManagement.Domain.csproj" />
</ItemGroup> </ItemGroup>

51
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Files/FileObjectDto.cs

@ -0,0 +1,51 @@
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 文件
/// </summary>
public class FileObjectDto
{
/// <summary>
/// 主键Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreationTime { get; set; }
/// <summary>
/// 文件Provider
/// </summary>
public string ProviderKey { get; set; }
/// <summary>
/// 文件扩展名
/// </summary>
public string FileExtension { get; set; }
/// <summary>
/// 二进制数据
/// </summary>
public byte[] Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
private const string CacheKeyFormat = "i:{0}";
public static string CalculateCacheKey(Guid id)
{
return string.Format(CacheKeyFormat, id);
}
}

26
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Provider/UpdateDto.cs

@ -0,0 +1,26 @@
namespace Lion.AbpPro.FileManagement.Provider;
public class UpdateDto
{
/// <summary>
/// 二进制数据
/// </summary>
public byte[] Bytes { get; set; }
/// <summary>
/// 文件大小
/// </summary>
public long FileSize { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}

17
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain.Shared/Provider/UpdateResult.cs

@ -0,0 +1,17 @@
namespace Lion.AbpPro.FileManagement.Provider;
public class UpdateResult
{
public Guid Id { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
public UpdateResult()
{
ExtraProperties = new Dictionary<string, object>();
}
public Dictionary<string, object> ExtraProperties { get; set; }
}

2
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDbProperties.cs

@ -3,7 +3,7 @@
public static class FileManagementDbProperties public static class FileManagementDbProperties
{ {
public const string ConnectionStringName = "FileManagement"; public const string ConnectionStringName = "FileManagement";
public static string DbTablePrefix { get; set; } = ""; public static string DbTablePrefix { get; set; } = "Abp";
public static string DbSchema { get; set; } = null; public static string DbSchema { get; set; } = null;
} }

13
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDomainAutoMapperProfile.cs

@ -0,0 +1,13 @@
using AutoMapper;
using Lion.AbpPro.FileManagement.Files;
namespace Lion.AbpPro.FileManagement
{
public class FileManagementDomainAutoMapperProfile : Profile
{
public FileManagementDomainAutoMapperProfile()
{
CreateMap<FileObject, FileObjectDto>();
}
}
}

7
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/FileManagementDomainModule.cs

@ -1,9 +1,16 @@
using Volo.Abp.AutoMapper;
namespace Lion.AbpPro.FileManagement; namespace Lion.AbpPro.FileManagement;
[DependsOn( [DependsOn(
typeof(AbpDddDomainModule), typeof(AbpDddDomainModule),
typeof(AbpAutoMapperModule),
typeof(FileManagementDomainSharedModule) typeof(FileManagementDomainSharedModule)
)] )]
public class FileManagementDomainModule : AbpModule public class FileManagementDomainModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<FileManagementDomainModule>(); });
}
} }

22
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/Aggregates/File.cs

@ -1,22 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files;
public class File: FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; private set; }
public string FileName { get; private set; }
public string FilePath { get; private set; }
private File()
{
}
public File(Guid id, Guid? tenantId, string fileName, string filePath) : base(id)
{
TenantId = tenantId;
FileName = fileName;
FilePath = filePath;
}
}

33
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileManager.cs

@ -1,33 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files;
public class FileManager : DomainService, IFileManager
{
private readonly IFileRepository _fileRepository;
public FileManager(IFileRepository fileRepository)
{
_fileRepository = fileRepository;
}
public virtual async Task CreateAsync(string fileName, string filePath)
{
Check.NotNullOrWhiteSpace(fileName, nameof(fileName));
Check.NotNullOrWhiteSpace(filePath, nameof(filePath));
var entity = new File(GuidGenerator.Create(), CurrentTenant.Id, fileName, filePath);
await _fileRepository.InsertAsync(entity);
}
public virtual async Task<List<File>> PagingAsync(
string filter = null,
int maxResultCount = 10,
int skipCount = 0)
{
return await _fileRepository.GetPagingListAsync(filter, maxResultCount, skipCount);
}
public virtual async Task<long> CountAsync(string filter = null)
{
return await _fileRepository.GetPagingCountAsync(filter);
}
}

137
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileObject.cs

@ -0,0 +1,137 @@
using Lion.AbpPro.Core;
namespace Lion.AbpPro.FileManagement.Files;
/// <summary>
/// 文件
/// </summary>
public class FileObject : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public FileObject(
Guid id,
string providerKey,
byte[] bytes,
long fileSize,
string contentType,
string fileName,
Guid? tenantId = null
) : base(id)
{
SetProviderKey(providerKey);
SetBytes(bytes);
SetFileSize(fileSize);
SetContentType(contentType);
SetFileName(fileName);
TenantId = tenantId;
}
public Guid? TenantId { get; private set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; private set; }
/// <summary>
/// 文件名称
/// </summary>
public string ContentType { get; private set; }
/// <summary>
/// 文件大小
/// </summary>
public long FileSize { get; private set; }
/// <summary>
/// 文件扩展名
/// </summary>
public string FileExtension { get; private set; }
/// <summary>
/// 二进制数据
/// </summary>
public byte[] Bytes { get; private set; }
/// <summary>
/// 文件Provider
/// </summary>
public string ProviderKey { get; private set; }
/// <summary>
/// 设置文件Provider
/// </summary>
private void SetProviderKey(string providerKey)
{
Guard.NotNullOrWhiteSpace(providerKey, nameof(providerKey), 128, 0);
ProviderKey = providerKey;
}
/// <summary>
/// 设置文件扩展名
/// </summary>
private void SetFileExtension(string fileExtension)
{
Guard.NotNullOrWhiteSpace(fileExtension, nameof(fileExtension), 36, 0);
FileExtension = fileExtension;
}
/// <summary>
/// 设置二进制数据
/// </summary>
private void SetBytes(byte[] bytes)
{
Bytes = bytes;
}
/// <summary>
/// 设置文件大小
/// </summary>
private void SetFileSize(long fileSize)
{
FileSize = fileSize;
}
/// <summary>
/// 设置文件名称
/// </summary>
private void SetContentType(string contentType)
{
Guard.NotNullOrWhiteSpace(contentType, nameof(contentType), 128, 0);
ContentType = contentType;
}
/// <summary>
/// 设置文件名称
/// </summary>
private void SetFileName(string fileName)
{
Guard.NotNullOrWhiteSpace(fileName, nameof(fileName), 128, 0);
SetFileExtension(Path.GetExtension(fileName));
FileName = fileName;
}
/// <summary>
/// 更新文件
/// </summary>
public void Update(
string providerKey,
string fileExtension,
byte[] bytes,
long fileSize,
string contentType,
string fileName
)
{
SetProviderKey(providerKey);
SetFileExtension(fileExtension);
SetBytes(bytes);
SetFileSize(fileSize);
SetContentType(contentType);
SetFileName(fileName);
}
}

65
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/FileObjectManager.cs

@ -0,0 +1,65 @@
using Volo.Abp.ObjectMapping;
namespace Lion.AbpPro.FileManagement.Files;
public class FileObjectManager : DomainService
{
private readonly IFileObjectRepository _fileObjectRepository;
private readonly IObjectMapper _objectMapper;
private readonly ICurrentTenant _currentTenant;
public FileObjectManager(IFileObjectRepository iIFileObjectRepository, IObjectMapper objectMapper, ICurrentTenant currentTenant)
{
_fileObjectRepository = iIFileObjectRepository;
_objectMapper = objectMapper;
_currentTenant = currentTenant;
}
public async Task<List<FileObjectDto>> GetListAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null, int maxResultCount = 10, int skipCount = 0)
{
return await _fileObjectRepository.GetListAsync(fileName, startDateTime, endDateTime, maxResultCount, skipCount);
}
public async Task<long> GetCountAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null)
{
return await _fileObjectRepository.GetCountAsync(fileName, startDateTime, endDateTime);
}
/// <summary>
/// 创建文件
/// </summary>
public async Task<FileObjectDto> CreateAsync(
Guid id,
string fileName,
byte[] bytes,
long fileSize,
string contentType,
string providerKey
)
{
var entity = new FileObject(id, providerKey, bytes, fileSize, contentType, fileName, _currentTenant.Id);
entity = await _fileObjectRepository.InsertAsync(entity);
return _objectMapper.Map<FileObject, FileObjectDto>(entity);
}
/// <summary>
/// 删除文件
/// </summary>
public async Task DeleteAsync(Guid id)
{
var entity = await _fileObjectRepository.FindAsync(id);
if (entity == null) throw new UserFriendlyException($"文件不存在");
await _fileObjectRepository.DeleteAsync(entity);
}
/// <summary>
/// 删除文件
/// </summary>
public async Task<FileObjectDto> GetAsync(Guid id)
{
var entity = await _fileObjectRepository.FindAsync(id);
if (entity == null) throw new UserFriendlyException($"文件不存在");
return _objectMapper.Map<FileObject, FileObjectDto>(entity);
}
}

15
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileManager.cs

@ -1,15 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files;
public interface IFileManager
{
Task CreateAsync(string fileName, string filePath);
Task<List<File>> PagingAsync(
string filter = null,
int maxResultCount = 10,
int skipCount = 0);
Task<long> CountAsync(string filter = null);
IAbpLazyServiceProvider LazyServiceProvider { get; set; }
IServiceProvider ServiceProvider { get; set; }
}

8
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileObjectRepository.cs

@ -0,0 +1,8 @@
namespace Lion.AbpPro.FileManagement.Files;
public interface IFileObjectRepository : IBasicRepository<FileObject, Guid>
{
Task<List<FileObjectDto>> GetListAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null, int maxResultCount = 10, int skipCount = 0);
Task<long> GetCountAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null);
}

13
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Files/IFileRepository.cs

@ -1,13 +0,0 @@
namespace Lion.AbpPro.FileManagement.Files;
public interface IFileRepository: IRepository<File, Guid>
{
Task<List<File>> GetPagingListAsync(
string filter = null,
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default);
Task<long> GetPagingCountAsync(string filter = null,
CancellationToken cancellationToken = default);
}

1
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Lion.AbpPro.FileManagement.Domain.csproj

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" /> <PackageReference Include="Volo.Abp.Ddd.Domain" />
<PackageReference Include="Volo.Abp.AutoMapper" />
<ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain.Shared\Lion.AbpPro.FileManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain.Shared\Lion.AbpPro.FileManagement.Domain.Shared.csproj" />
</ItemGroup> </ItemGroup>

30
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Provider/DatabaseFileProvider.cs

@ -0,0 +1,30 @@
using Lion.AbpPro.FileManagement.Files;
using Volo.Abp.Guids;
namespace Lion.AbpPro.FileManagement.Provider;
public class DatabaseFileProvider : IFileProvider, ITransientDependency
{
public const string Name = nameof(DatabaseFileProvider);
private readonly FileObjectManager _fileObjectManager;
private readonly IGuidGenerator _guidGenerator;
public DatabaseFileProvider(FileObjectManager fileObjectManager, IGuidGenerator guidGenerator)
{
_fileObjectManager = fileObjectManager;
_guidGenerator = guidGenerator;
}
public async Task<UpdateResult> UploadAsync(UpdateDto input)
{
var id = _guidGenerator.Create();
var fileName = id + "_" + input.FileName;
await _fileObjectManager.CreateAsync(id, fileName, input.Bytes, input.FileSize, input.ContentType, Name);
return new UpdateResult()
{
Id = id,
FileName = fileName,
FilePath = fileName
};
}
}

6
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.Domain/Provider/IFileProvider.cs

@ -0,0 +1,6 @@
namespace Lion.AbpPro.FileManagement.Provider;
public interface IFileProvider
{
Task<UpdateResult> UploadAsync(UpdateDto input);
}

2
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/FileManagementDbContext.cs

@ -19,5 +19,5 @@ public class FileManagementDbContext : AbpDbContext<FileManagementDbContext>, IF
builder.ConfigureFileManagement(); builder.ConfigureFileManagement();
} }
public DbSet<Lion.AbpPro.FileManagement.Files.File> Files { get; } public DbSet<FileObject> FileObjects { get; set; }
} }

13
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/FileManagementDbContextModelCreatingExtensions.cs

@ -8,11 +8,16 @@ public static class FileManagementDbContextModelCreatingExtensions
Check.NotNull(builder, nameof(builder)); Check.NotNull(builder, nameof(builder));
builder.Entity<Lion.AbpPro.FileManagement.Files.File>(b => builder.Entity<FileObject>(b =>
{ {
b.ToTable(FileManagementDbProperties.DbTablePrefix + nameof(Lion.AbpPro.FileManagement.Files.File), FileManagementDbProperties.DbSchema); b.ToTable(FileManagementDbProperties.DbTablePrefix + "FileObjects");
b.HasIndex(q => q.FileName); b.Property(e => e.ProviderKey).IsRequired().HasMaxLength(128).HasComment("文件Provider");
b.HasIndex(q => q.CreationTime); b.Property(e => e.FileExtension).IsRequired().HasMaxLength(36).HasComment("文件扩展名");
b.Property(e => e.Bytes).HasComment("二进制数据");
b.Property(e => e.FileSize).HasComment("文件大小");
b.Property(e => e.ContentType).IsRequired().HasMaxLength(128).HasComment("文件名称");
b.Property(e => e.FileName).IsRequired().HasMaxLength(128).HasComment("文件名称");
b.HasIndex(e => e.FileName);
b.ConfigureByConvention(); b.ConfigureByConvention();
}); });
} }

49
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/Files/EfCoreFileObjectRepository.cs

@ -0,0 +1,49 @@
using System.Linq.Dynamic.Core;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace Lion.AbpPro.FileManagement.EntityFrameworkCore.Files;
/// <summary>
/// 文件 仓储Ef core 实现
/// </summary>
public class EfCoreFileObjectRepository :
EfCoreRepository<FileManagementDbContext, FileObject, Guid>,
IFileObjectRepository
{
public EfCoreFileObjectRepository(IDbContextProvider<FileManagementDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<FileObjectDto>> GetListAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null,int maxResultCount = 10, int skipCount = 0)
{
return await (await GetDbSetAsync())
.WhereIf(fileName.IsNotNullOrWhiteSpace(),e=>e.FileName.Contains(fileName))
.WhereIf(startDateTime.HasValue, e => e.CreationTime >= startDateTime.Value)
.WhereIf(endDateTime.HasValue, e => e.CreationTime <= endDateTime.Value)
.OrderByDescending(e => e.CreationTime)
.PageBy(skipCount, maxResultCount)
.Select(e => new FileObjectDto
{
Id = e.Id,
CreationTime = e.CreationTime,
FileName = e.FileName,
FileSize = e.FileSize,
FileExtension = e.FileExtension,
ContentType = e.ContentType,
ProviderKey = e.ProviderKey
}) // 选择指定字段
.ToListAsync();
}
public async Task<long> GetCountAsync(string fileName, DateTime? startDateTime = null, DateTime? endDateTime = null)
{
return await (await GetDbSetAsync())
.WhereIf(fileName.IsNotNullOrWhiteSpace(),e=>e.FileName.Contains(fileName))
.WhereIf(startDateTime.HasValue, e => e.CreationTime >= startDateTime.Value)
.WhereIf(endDateTime.HasValue, e => e.CreationTime <= endDateTime.Value)
.CountAsync();
}
}

31
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/Files/EfCoreFileRepository.cs

@ -1,31 +0,0 @@
namespace Lion.AbpPro.FileManagement.EntityFrameworkCore.Files;
public class EfCoreFileRepository: EfCoreRepository<IFileManagementDbContext,Lion.AbpPro.FileManagement.Files.File, Guid>, IFileRepository
{
public EfCoreFileRepository(IDbContextProvider<IFileManagementDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<Lion.AbpPro.FileManagement.Files.File>> GetPagingListAsync(
string filter = null,
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(),
e => (e.FileName.Contains(filter)))
.OrderByDescending(e => e.CreationTime)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetPagingCountAsync(string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(),
e => (e.FileName.Contains(filter)))
.CountAsync(cancellationToken: cancellationToken);
}
}

6
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/EntityFrameworkCore/IFileManagementDbContext.cs

@ -1,4 +1,6 @@
namespace Lion.AbpPro.FileManagement.EntityFrameworkCore; 
namespace Lion.AbpPro.FileManagement.EntityFrameworkCore;
[ConnectionStringName(FileManagementDbProperties.ConnectionStringName)] [ConnectionStringName(FileManagementDbProperties.ConnectionStringName)]
public interface IFileManagementDbContext : IEfCoreDbContext public interface IFileManagementDbContext : IEfCoreDbContext
@ -6,5 +8,5 @@ public interface IFileManagementDbContext : IEfCoreDbContext
/* Add DbSet for each Aggregate Root here. Example: /* Add DbSet for each Aggregate Root here. Example:
* DbSet<Question> Questions { get; } * DbSet<Question> Questions { get; }
*/ */
DbSet<Lion.AbpPro.FileManagement.Files.File> Files { get; } DbSet<FileObject> FileObjects { get; }
} }

1
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.EntityFrameworkCore/Lion.AbpPro.FileManagement.EntityFrameworkCore.csproj

@ -7,7 +7,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.EntityFrameworkCore" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore" />
<ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain\Lion.AbpPro.FileManagement.Domain.csproj" /> <ProjectReference Include="..\Lion.AbpPro.FileManagement.Domain\Lion.AbpPro.FileManagement.Domain.csproj" />
</ItemGroup> </ItemGroup>

38
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.HttpApi/Files/FileController.cs

@ -1,7 +1,9 @@
namespace Lion.AbpPro.FileManagement.Files; using Microsoft.AspNetCore.Http;
namespace Lion.AbpPro.FileManagement.Files;
[Route("Files")] [Route("Files")]
public class FileController: FileManagementController, IFileAppService public class FileController : AbpController, IFileAppService
{ {
private readonly IFileAppService _fileAppService; private readonly IFileAppService _fileAppService;
@ -10,24 +12,32 @@ public class FileController: FileManagementController, IFileAppService
_fileAppService = fileAppService; _fileAppService = fileAppService;
} }
[HttpGet("getFileToken")] [HttpPost("Page")]
[SwaggerOperation(summary: "获取上传文件临时Token", Tags = new[] { "Files" })] [SwaggerOperation(summary: "分页查询文件", Tags = new[] { "Files" })]
public Task<FileTokenOutput> GetFileTokenAsync() public async Task<PagedResultDto<PageFileObjectOutput>> PageAsync(PageFileObjectInput input)
{ {
return _fileAppService.GetFileTokenAsync(); return await _fileAppService.PageAsync(input);
} }
[HttpPost("create")] [HttpPost("Upload")]
[SwaggerOperation(summary: "创建文件", Tags = new[] { "Files" })] [SwaggerOperation(summary: "上传文件", Tags = new[] { "Files" })]
public Task CreateAsync(CreateFileInput input) public async Task<List<UploadOutput>> UploadAsync(List<IFormFile> files)
{
return await _fileAppService.UploadAsync(files);
}
[HttpPost("Delete")]
[SwaggerOperation(summary: "删除文件", Tags = new[] { "Files" })]
public async Task DeleteAsync(DeleteFileObjectInput input)
{ {
return _fileAppService.CreateAsync(input); await _fileAppService.DeleteAsync(input);
} }
[HttpPost("page")] [HttpPost("Get")]
[SwaggerOperation(summary: "分页查询", Tags = new[] { "Files" })] [SwaggerOperation(summary: "获取文件", Tags = new[] { "Files" })]
public Task<PagedResultDto<PagingFileOutput>> PagingAsync(PagingFileInput input) public Task<GetFileObjectOutput> GetAsync(GetFileObjectInput input)
{ {
return _fileAppService.PagingAsync(input); return _fileAppService.GetAsync(input);
} }
} }

1
aspnet-core/modules/FileManagement/src/Lion.AbpPro.FileManagement.HttpApi/GlobalUsings.cs

@ -1,7 +1,6 @@
// Global using directives // Global using directives
global using System.Threading.Tasks; global using System.Threading.Tasks;
global using Lion.AbpPro.FileManagement.Files.Dto;
global using Lion.AbpPro.FileManagement.Localization; global using Lion.AbpPro.FileManagement.Localization;
global using Localization.Resources.AbpUi; global using Localization.Resources.AbpUi;
global using Microsoft.AspNetCore.Mvc; global using Microsoft.AspNetCore.Mvc;

2
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json

@ -34,7 +34,7 @@
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100" "CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" "Default": "Data Source=localhost;Port=3306;Database=LionAbpPro9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
}, },
"Hangfire": { "Hangfire": {
"Redis": { "Redis": {

5
aspnet-core/services/src/Lion.AbpPro.Application.Contracts/AbpProApplicationContractsModule.cs

@ -1,3 +1,5 @@
using Lion.AbpPro.FileManagement;
namespace Lion.AbpPro namespace Lion.AbpPro
{ {
[DependsOn( [DependsOn(
@ -6,7 +8,8 @@ namespace Lion.AbpPro
typeof(BasicManagementApplicationContractsModule), typeof(BasicManagementApplicationContractsModule),
typeof(DataDictionaryManagementApplicationContractsModule), typeof(DataDictionaryManagementApplicationContractsModule),
typeof(LanguageManagementApplicationContractsModule), typeof(LanguageManagementApplicationContractsModule),
typeof(NotificationManagementApplicationContractsModule) typeof(NotificationManagementApplicationContractsModule),
typeof(FileManagementApplicationContractsModule)
)] )]
public class AbpProApplicationContractsModule : AbpModule public class AbpProApplicationContractsModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj

@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application.Contracts\Lion.AbpPro.BasicManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application.Contracts\Lion.AbpPro.BasicManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application.Contracts\Lion.AbpPro.DataDictionaryManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application.Contracts\Lion.AbpPro.DataDictionaryManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Application.Contracts\Lion.AbpPro.FileManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Application.Contracts\Lion.AbpPro.NotificationManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Application.Contracts\Lion.AbpPro.NotificationManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Application.Contracts\Lion.AbpPro.LanguageManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Application.Contracts\Lion.AbpPro.LanguageManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Domain.Shared\Lion.AbpPro.Domain.Shared.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Domain.Shared\Lion.AbpPro.Domain.Shared.csproj" />

3
aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs

@ -1,3 +1,5 @@
using Lion.AbpPro.FileManagement;
namespace Lion.AbpPro namespace Lion.AbpPro
{ {
[DependsOn( [DependsOn(
@ -8,6 +10,7 @@ namespace Lion.AbpPro
typeof(NotificationManagementApplicationModule), typeof(NotificationManagementApplicationModule),
typeof(LanguageManagementApplicationModule), typeof(LanguageManagementApplicationModule),
typeof(NotificationManagementApplicationModule), typeof(NotificationManagementApplicationModule),
typeof(FileManagementApplicationModule),
typeof(AbpProFreeSqlModule) typeof(AbpProFreeSqlModule)
)] )]
public class AbpProApplicationModule : AbpModule public class AbpProApplicationModule : AbpModule

1
aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application\Lion.AbpPro.BasicManagement.Application.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application\Lion.AbpPro.BasicManagement.Application.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application\Lion.AbpPro.DataDictionaryManagement.Application.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application\Lion.AbpPro.DataDictionaryManagement.Application.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Application\Lion.AbpPro.FileManagement.Application.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Application\Lion.AbpPro.NotificationManagement.Application.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Application\Lion.AbpPro.NotificationManagement.Application.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Application\Lion.AbpPro.LanguageManagement.Application.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Application\Lion.AbpPro.LanguageManagement.Application.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Domain\Lion.AbpPro.Domain.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Domain\Lion.AbpPro.Domain.csproj" />

4
aspnet-core/services/src/Lion.AbpPro.Domain.Shared/AbpProDomainSharedModule.cs

@ -1,6 +1,7 @@
using Lion.AbpPro.BasicManagement; using Lion.AbpPro.BasicManagement;
using Lion.AbpPro.BasicManagement.Localization; using Lion.AbpPro.BasicManagement.Localization;
using Lion.AbpPro.Core; using Lion.AbpPro.Core;
using Lion.AbpPro.FileManagement;
using Lion.AbpPro.LanguageManagement; using Lion.AbpPro.LanguageManagement;
namespace Lion.AbpPro namespace Lion.AbpPro
@ -10,7 +11,8 @@ namespace Lion.AbpPro
typeof(BasicManagementDomainSharedModule), typeof(BasicManagementDomainSharedModule),
typeof(DataDictionaryManagementDomainSharedModule), typeof(DataDictionaryManagementDomainSharedModule),
typeof(NotificationManagementDomainSharedModule), typeof(NotificationManagementDomainSharedModule),
typeof(LanguageManagementDomainSharedModule) typeof(LanguageManagementDomainSharedModule),
typeof(FileManagementDomainSharedModule)
)] )]
public class AbpProDomainSharedModule : AbpModule public class AbpProDomainSharedModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.Domain.Shared/Lion.AbpPro.Domain.Shared.csproj

@ -17,6 +17,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Domain.Shared\Lion.AbpPro.BasicManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Domain.Shared\Lion.AbpPro.BasicManagement.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Domain.Shared\Lion.AbpPro.DataDictionaryManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Domain.Shared\Lion.AbpPro.DataDictionaryManagement.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Domain.Shared\Lion.AbpPro.FileManagement.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Domain.Shared\Lion.AbpPro.NotificationManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Domain.Shared\Lion.AbpPro.NotificationManagement.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Domain.Shared\Lion.AbpPro.LanguageManagement.Domain.Shared.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Domain.Shared\Lion.AbpPro.LanguageManagement.Domain.Shared.csproj" />
</ItemGroup> </ItemGroup>

5
aspnet-core/services/src/Lion.AbpPro.Domain/AbpProDomainModule.cs

@ -1,3 +1,5 @@
using Lion.AbpPro.FileManagement;
namespace Lion.AbpPro namespace Lion.AbpPro
{ {
[DependsOn( [DependsOn(
@ -6,7 +8,8 @@ namespace Lion.AbpPro
typeof(BasicManagementDomainModule), typeof(BasicManagementDomainModule),
typeof(DataDictionaryManagementDomainModule), typeof(DataDictionaryManagementDomainModule),
typeof(NotificationManagementDomainModule), typeof(NotificationManagementDomainModule),
typeof(LanguageManagementDomainModule) typeof(LanguageManagementDomainModule),
typeof(FileManagementDomainModule)
)] )]
public class AbpProDomainModule : AbpModule public class AbpProDomainModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.Domain/Lion.AbpPro.Domain.csproj

@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Domain\Lion.AbpPro.BasicManagement.Domain.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Domain\Lion.AbpPro.BasicManagement.Domain.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Domain\Lion.AbpPro.DataDictionaryManagement.Domain.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Domain\Lion.AbpPro.DataDictionaryManagement.Domain.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Domain\Lion.AbpPro.FileManagement.Domain.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Domain\Lion.AbpPro.NotificationManagement.Domain.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Domain\Lion.AbpPro.NotificationManagement.Domain.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Domain\Lion.AbpPro.LanguageManagement.Domain.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.Domain\Lion.AbpPro.LanguageManagement.Domain.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Domain.Shared\Lion.AbpPro.Domain.Shared.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Domain.Shared\Lion.AbpPro.Domain.Shared.csproj" />

12
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/EntityFrameworkCore/AbpProDbContext.cs

@ -1,9 +1,10 @@
using Lion.AbpPro.DataDictionaryManagement.DataDictionaries.Aggregates; using Lion.AbpPro.DataDictionaryManagement.DataDictionaries.Aggregates;
using Lion.AbpPro.FileManagement.EntityFrameworkCore;
using Lion.AbpPro.FileManagement.Files;
using Lion.AbpPro.LanguageManagement.EntityFrameworkCore; using Lion.AbpPro.LanguageManagement.EntityFrameworkCore;
using Lion.AbpPro.LanguageManagement.Languages.Aggregates; using Lion.AbpPro.LanguageManagement.Languages.Aggregates;
using Lion.AbpPro.LanguageManagement.LanguageTexts.Aggregates; using Lion.AbpPro.LanguageManagement.LanguageTexts.Aggregates;
using Lion.AbpPro.NotificationManagement.Notifications.Aggregates; using Lion.AbpPro.NotificationManagement.Notifications.Aggregates;
namespace Lion.AbpPro.EntityFrameworkCore namespace Lion.AbpPro.EntityFrameworkCore
{ {
/* This is your actual DbContext used on runtime. /* This is your actual DbContext used on runtime.
@ -20,7 +21,8 @@ namespace Lion.AbpPro.EntityFrameworkCore
IBasicManagementDbContext, IBasicManagementDbContext,
INotificationManagementDbContext, INotificationManagementDbContext,
IDataDictionaryManagementDbContext, IDataDictionaryManagementDbContext,
ILanguageManagementDbContext ILanguageManagementDbContext,
IFileManagementDbContext
{ {
public DbSet<IdentityUser> Users { get; set; } public DbSet<IdentityUser> Users { get; set; }
public DbSet<IdentityRole> Roles { get; set; } public DbSet<IdentityRole> Roles { get; set; }
@ -47,6 +49,7 @@ namespace Lion.AbpPro.EntityFrameworkCore
public DbSet<DataDictionary> DataDictionaries { get; set; } public DbSet<DataDictionary> DataDictionaries { get; set; }
public DbSet<Language> Languages { get; set; } public DbSet<Language> Languages { get; set; }
public DbSet<LanguageText> LanguageTexts { get; set; } public DbSet<LanguageText> LanguageTexts { get; set; }
public DbSet<FileObject> FileObjects { get; set; }
public AbpProDbContext(DbContextOptions<AbpProDbContext> options) public AbpProDbContext(DbContextOptions<AbpProDbContext> options)
: base(options) : base(options)
@ -80,7 +83,12 @@ namespace Lion.AbpPro.EntityFrameworkCore
// 多语言 // 多语言
builder.ConfigureLanguageManagement(); builder.ConfigureLanguageManagement();
// 文件模块
builder.ConfigureFileManagement();
} }
} }
} }

4
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/EntityFrameworkCore/AbpProEntityFrameworkCoreModule.cs

@ -1,3 +1,4 @@
using Lion.AbpPro.FileManagement.EntityFrameworkCore;
using Lion.AbpPro.LanguageManagement.EntityFrameworkCore; using Lion.AbpPro.LanguageManagement.EntityFrameworkCore;
using Volo.Abp.Guids; using Volo.Abp.Guids;
@ -9,7 +10,8 @@ namespace Lion.AbpPro.EntityFrameworkCore
typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(DataDictionaryManagementEntityFrameworkCoreModule), typeof(DataDictionaryManagementEntityFrameworkCoreModule),
typeof(NotificationManagementEntityFrameworkCoreModule), typeof(NotificationManagementEntityFrameworkCoreModule),
typeof(LanguageManagementEntityFrameworkCoreModule) typeof(LanguageManagementEntityFrameworkCoreModule),
typeof(FileManagementEntityFrameworkCoreModule)
)] )]
public class AbpProEntityFrameworkCoreModule : AbpModule public class AbpProEntityFrameworkCoreModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.EntityFrameworkCore\Lion.AbpPro.BasicManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.EntityFrameworkCore\Lion.AbpPro.BasicManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.EntityFrameworkCore\Lion.AbpPro.DataDictionaryManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.EntityFrameworkCore\Lion.AbpPro.DataDictionaryManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.EntityFrameworkCore\Lion.AbpPro.FileManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.EntityFrameworkCore\Lion.AbpPro.NotificationManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.EntityFrameworkCore\Lion.AbpPro.NotificationManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.EntityFrameworkCore\Lion.AbpPro.LanguageManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.EntityFrameworkCore\Lion.AbpPro.LanguageManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Domain\Lion.AbpPro.Domain.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Domain\Lion.AbpPro.Domain.csproj" />

2179
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/20250215074519_1.0.2.Designer.cs

File diff suppressed because it is too large

61
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/20250215074519_1.0.2.cs

@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lion.AbpPro.Migrations
{
/// <inheritdoc />
public partial class _102 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpFileObjects",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FileName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "文件名称")
.Annotation("MySql:CharSet", "utf8mb4"),
ContentType = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "文件名称")
.Annotation("MySql:CharSet", "utf8mb4"),
FileSize = table.Column<long>(type: "bigint", nullable: false, comment: "文件大小"),
FileExtension = table.Column<string>(type: "varchar(36)", maxLength: 36, nullable: false, comment: "文件扩展名")
.Annotation("MySql:CharSet", "utf8mb4"),
Bytes = table.Column<byte[]>(type: "longblob", nullable: true, comment: "二进制数据"),
ProviderKey = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "文件Provider")
.Annotation("MySql:CharSet", "utf8mb4"),
ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpFileObjects", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpFileObjects_FileName",
table: "AbpFileObjects",
column: "FileName");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpFileObjects");
}
}
}

90
aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Migrations/AbpProDbContextModelSnapshot.cs

@ -141,6 +141,96 @@ namespace Lion.AbpPro.Migrations
b.ToTable("AbpDataDictionaryDetails", (string)null); b.ToTable("AbpDataDictionaryDetails", (string)null);
}); });
modelBuilder.Entity("Lion.AbpPro.FileManagement.Files.FileObject", b =>
{
b.Property<Guid>("Id")
.HasColumnType("char(36)");
b.Property<byte[]>("Bytes")
.HasColumnType("longblob")
.HasComment("二进制数据");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ContentType")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasComment("文件名称");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("ExtraProperties")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<string>("FileExtension")
.IsRequired()
.HasMaxLength(36)
.HasColumnType("varchar(36)")
.HasComment("文件扩展名");
b.Property<string>("FileName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasComment("文件名称");
b.Property<long>("FileSize")
.HasColumnType("bigint")
.HasComment("文件大小");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("ProviderKey")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasComment("文件Provider");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("FileName");
b.ToTable("AbpFileObjects", (string)null);
});
modelBuilder.Entity("Lion.AbpPro.LanguageManagement.LanguageTexts.Aggregates.LanguageText", b => modelBuilder.Entity("Lion.AbpPro.LanguageManagement.LanguageTexts.Aggregates.LanguageText", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")

4
aspnet-core/services/src/Lion.AbpPro.HttpApi.Client/AbpProHttpApiClientModule.cs

@ -1,4 +1,5 @@
using Lion.AbpPro.BasicManagement; using Lion.AbpPro.BasicManagement;
using Lion.AbpPro.FileManagement;
using Lion.AbpPro.LanguageManagement; using Lion.AbpPro.LanguageManagement;
using Lion.AbpPro.NotificationManagement; using Lion.AbpPro.NotificationManagement;
@ -9,7 +10,8 @@ namespace Lion.AbpPro
typeof(BasicManagementHttpApiClientModule), typeof(BasicManagementHttpApiClientModule),
typeof(DataDictionaryManagementHttpApiClientModule), typeof(DataDictionaryManagementHttpApiClientModule),
typeof(NotificationManagementHttpApiClientModule), typeof(NotificationManagementHttpApiClientModule),
typeof(LanguageManagementHttpApiClientModule) typeof(LanguageManagementHttpApiClientModule),
typeof(FileManagementHttpApiClientModule)
)] )]
public class AbpProHttpApiClientModule : AbpModule public class AbpProHttpApiClientModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.HttpApi.Client/Lion.AbpPro.HttpApi.Client.csproj

@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.HttpApi.Client\Lion.AbpPro.BasicManagement.HttpApi.Client.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.HttpApi.Client\Lion.AbpPro.BasicManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.HttpApi.Client\Lion.AbpPro.DataDictionaryManagement.HttpApi.Client.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.HttpApi.Client\Lion.AbpPro.DataDictionaryManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.HttpApi.Client\Lion.AbpPro.FileManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.HttpApi.Client\Lion.AbpPro.NotificationManagement.HttpApi.Client.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.HttpApi.Client\Lion.AbpPro.NotificationManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.HttpApi.Client\Lion.AbpPro.LanguageManagement.HttpApi.Client.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.HttpApi.Client\Lion.AbpPro.LanguageManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Application.Contracts\Lion.AbpPro.Application.Contracts.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Application.Contracts\Lion.AbpPro.Application.Contracts.csproj" />

4
aspnet-core/services/src/Lion.AbpPro.HttpApi/AbpProHttpApiModule.cs

@ -1,4 +1,5 @@
using Lion.AbpPro.BasicManagement; using Lion.AbpPro.BasicManagement;
using Lion.AbpPro.FileManagement;
using Lion.AbpPro.LanguageManagement; using Lion.AbpPro.LanguageManagement;
namespace Lion.AbpPro namespace Lion.AbpPro
@ -8,7 +9,8 @@ namespace Lion.AbpPro
typeof(BasicManagementHttpApiModule), typeof(BasicManagementHttpApiModule),
typeof(DataDictionaryManagementHttpApiModule), typeof(DataDictionaryManagementHttpApiModule),
typeof(NotificationManagementHttpApiModule), typeof(NotificationManagementHttpApiModule),
typeof(LanguageManagementHttpApiModule) typeof(LanguageManagementHttpApiModule),
typeof(FileManagementHttpApiModule)
)] )]
public class AbpProHttpApiModule : AbpModule public class AbpProHttpApiModule : AbpModule
{ {

1
aspnet-core/services/src/Lion.AbpPro.HttpApi/Lion.AbpPro.HttpApi.csproj

@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.HttpApi\Lion.AbpPro.BasicManagement.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.HttpApi\Lion.AbpPro.BasicManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.HttpApi\Lion.AbpPro.DataDictionaryManagement.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.HttpApi\Lion.AbpPro.DataDictionaryManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.HttpApi\Lion.AbpPro.FileManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.HttpApi\Lion.AbpPro.NotificationManagement.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.HttpApi\Lion.AbpPro.NotificationManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.HttpApi\Lion.AbpPro.LanguageManagement.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\LanguageManagement\src\Lion.AbpPro.LanguageManagement.HttpApi\Lion.AbpPro.LanguageManagement.HttpApi.csproj" />
<ProjectReference Include="..\Lion.AbpPro.Application.Contracts\Lion.AbpPro.Application.Contracts.csproj" /> <ProjectReference Include="..\Lion.AbpPro.Application.Contracts\Lion.AbpPro.Application.Contracts.csproj" />

Loading…
Cancel
Save