mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-06 06:45:18 -04:00
Metadata Downloading (#3525)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user