添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,42 @@
using FileService.Application.Ports;
using FileService.Application.StorageContracts;
using FileService.Domain.ValueObjects;
using IM.Commons;
using MassTransit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileService.Infrastructure.Storage
{
public class LocalStorageAdapter : IObjectStoragePort
{
private readonly IRedisService redis;
public LocalStorageAdapter(IRedisService redis)
{
this.redis = redis;
}
public string ProviderCode => "Local";
public Task<CompleteUploadResult> CompleteUploadAsync(CompleteUploadCommand command, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<PresignedUrl> GenerateUploadUrlAsync(GenerateUploadUrlCommand command, CancellationToken token)
{
throw new NotImplementedException();
}
public async Task<InitiateUploadResult> InitUploadAsync(InitiateUploadCommand command, CancellationToken token)
{
var sessionId = Guid.NewGuid();
var location = new StorageLocation();
return new InitiateUploadResult(sessionId.ToString(),location);
}
}
}
@@ -0,0 +1,24 @@
using FileService.Application.Ports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileService.Infrastructure.Storage
{
public class ObjectStorageRouter : IObjectStorageRouter
{
private IReadOnlyDictionary<string, IObjectStoragePort> adpters;
public ObjectStorageRouter(IEnumerable<IObjectStoragePort> storages)
{
this.adpters = storages.ToDictionary(x => x.ProviderCode, StringComparer.OrdinalIgnoreCase);
}
public IObjectStoragePort Route(string providerCode)
{
return this.adpters[providerCode];
}
}
}
@@ -0,0 +1,43 @@
using FileService.Application.Ports;
using FileService.Application.StorageContracts;
using IM.Commons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileService.Infrastructure.Storage
{
public class StorageCacheService:IStorageRedisCache
{
private readonly IRedisService redis;
public StorageCacheService(IRedisService redis)
{
this.redis = redis;
}
public async Task SetAsync(UploadRuntimeCache upload)
{
string key = RedisHelper.GetUploadInfoKey(upload.UploadSessionId);
await redis.SetAsync<UploadRuntimeCache>(key, upload);
}
public async Task DeleteAsync(string sessionId)
{
string key = RedisHelper.GetUploadInfoKey(sessionId);
await redis.RemoveAsync(key);
}
public Task DeleteByTaskIdAsync(string taskId)
{
throw new NotImplementedException();
}
public async Task<UploadRuntimeCache?> GetAsync(string sessionId)
{
var key = RedisHelper.GetUploadInfoKey(sessionId);
return await redis.GetAsync<UploadRuntimeCache>(key);
}
}
}