网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
namespace Dpz.Core.Service.RepositoryServiceImpl;

public class BackupRecordService(
    IRepository<BackupRecord> repository,
    IMapper mapper,
    ILogger<BackupRecordService> logger
) : IBackupRecordService
{
    public async Task AddRecordAsync(VmBackupRecord? backupRecord)
    {
        if (backupRecord == null)
        {
            logger.LogWarning("backupRecord is null");
            return;
        }
        var entity = mapper.Map<BackupRecord>(backupRecord);
        if (entity == null)
        {
            logger.LogWarning("mapper backupRecord to entity fail");
            return;
        }
        await repository.InsertAsync(entity);
    }

    public async Task<VmBackupRecord?> GetLastNewBackupRecordAsync(string database)
    {
        var entity = await repository.SearchFor(x => x.Database == database)
            .OrderByDescending(x => x.Id)
            .FirstOrDefaultAsync();
        if (entity == null)
        {
            return null;
        }

        return mapper.Map<VmBackupRecord>(entity);
    }
}
loading