Metadata Downloading (#3525)

This commit is contained in:
Joe Milazzo 2025-02-05 16:16:44 -06:00 committed by GitHub
parent eb66763078
commit f4fd7230ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 6296 additions and 484 deletions

View file

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.DTOs.KavitaPlus.Metadata;
using API.DTOs.SeriesDetail;
using API.DTOs.Settings;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Metadata;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using Microsoft.EntityFrameworkCore;
namespace API.Data.Repositories;
@ -14,11 +16,15 @@ namespace API.Data.Repositories;
public interface ISettingsRepository
{
void Update(ServerSetting settings);
void Update(MetadataSettings settings);
void RemoveRange(List<MetadataFieldMapping> fieldMappings);
Task<ServerSettingDto> GetSettingsDtoAsync();
Task<ServerSetting> GetSettingAsync(ServerSettingKey key);
Task<IEnumerable<ServerSetting>> GetSettingsAsync();
void Remove(ServerSetting setting);
Task<ExternalSeriesMetadata?> GetExternalSeriesMetadata(int seriesId);
Task<MetadataSettings> GetMetadataSettings();
Task<MetadataSettingsDto> GetMetadataSettingDto();
}
public class SettingsRepository : ISettingsRepository
{
@ -36,6 +42,16 @@ public class SettingsRepository : ISettingsRepository
_context.Entry(settings).State = EntityState.Modified;
}
public void Update(MetadataSettings settings)
{
_context.Entry(settings).State = EntityState.Modified;
}
public void RemoveRange(List<MetadataFieldMapping> fieldMappings)
{
_context.MetadataFieldMapping.RemoveRange(fieldMappings);
}
public void Remove(ServerSetting setting)
{
_context.Remove(setting);
@ -48,6 +64,21 @@ public class SettingsRepository : ISettingsRepository
.FirstOrDefaultAsync();
}
public async Task<MetadataSettings> GetMetadataSettings()
{
return await _context.MetadataSettings
.Include(m => m.FieldMappings)
.FirstAsync();
}
public async Task<MetadataSettingsDto> GetMetadataSettingDto()
{
return await _context.MetadataSettings
.Include(m => m.FieldMappings)
.ProjectTo<MetadataSettingsDto>(_mapper.ConfigurationProvider)
.FirstAsync();
}
public async Task<ServerSettingDto> GetSettingsDtoAsync()
{
var settings = await _context.ServerSetting