refactor: abstract IWebHostEnvironment to IReceiptStorageOptions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace MoneyMap.Services;
|
||||
|
||||
public interface IReceiptStorageOptions
|
||||
{
|
||||
string ReceiptsBasePath { get; }
|
||||
}
|
||||
@@ -21,8 +21,7 @@ namespace MoneyMap.Services
|
||||
public class ReceiptManager : IReceiptManager
|
||||
{
|
||||
private readonly MoneyMapContext _db;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IReceiptStorageOptions _receiptStorage;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IReceiptParseQueue _parseQueue;
|
||||
private readonly ILogger<ReceiptManager> _logger;
|
||||
@@ -46,15 +45,13 @@ namespace MoneyMap.Services
|
||||
|
||||
public ReceiptManager(
|
||||
MoneyMapContext db,
|
||||
IWebHostEnvironment environment,
|
||||
IConfiguration configuration,
|
||||
IReceiptStorageOptions receiptStorage,
|
||||
IServiceProvider serviceProvider,
|
||||
IReceiptParseQueue parseQueue,
|
||||
ILogger<ReceiptManager> logger)
|
||||
{
|
||||
_db = db;
|
||||
_environment = environment;
|
||||
_configuration = configuration;
|
||||
_receiptStorage = receiptStorage;
|
||||
_serviceProvider = serviceProvider;
|
||||
_parseQueue = parseQueue;
|
||||
_logger = logger;
|
||||
@@ -62,9 +59,7 @@ namespace MoneyMap.Services
|
||||
|
||||
private string GetReceiptsBasePath()
|
||||
{
|
||||
// Get from config, default to "receipts" in wwwroot
|
||||
var relativePath = _configuration["Receipts:StoragePath"] ?? "receipts";
|
||||
return Path.Combine(_environment.WebRootPath, relativePath);
|
||||
return _receiptStorage.ReceiptsBasePath;
|
||||
}
|
||||
|
||||
public async Task<ReceiptUploadResult> UploadReceiptAsync(long transactionId, IFormFile file)
|
||||
|
||||
Reference in New Issue
Block a user