last ...
This commit is contained in:
@@ -1,60 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
using System.Collections.Generic;
|
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
|
|
||||||
namespace xContentService.Interfaces.Dtos
|
namespace xContentService.Interfaces.Dtos
|
||||||
{
|
{
|
||||||
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
|
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
|
||||||
{
|
{ }
|
||||||
//
|
|
||||||
#region Enrichers ...
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Item ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XContentDto> Enrich(
|
|
||||||
XContent source,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Item ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XContentDto> Enrich(
|
|
||||||
XContentDto source,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Items ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sources"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XContentDto>> EnrichRange(
|
|
||||||
IEnumerable<XContent> sources,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Items ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sources"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XContentDto>> EnrichRange(
|
|
||||||
IEnumerable<XContentDto> sources,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,21 @@ namespace xContentService.Interfaces
|
|||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
string language = null,
|
string language = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// /// Create Content Used Locales for Creating Posts ...
|
||||||
|
// /// </summary>
|
||||||
|
// /// <param name="item"></param>
|
||||||
|
// /// <param name="userInfo"></param>
|
||||||
|
// /// <param name="connectionId"></param>
|
||||||
|
// /// <param name="cancellationToken"></param>
|
||||||
|
// /// <returns></returns>
|
||||||
|
// public Task<XContentDto> Create(
|
||||||
|
// XContentDto item,
|
||||||
|
// XUserClaimsInfoDto userInfo = null,
|
||||||
|
// string connectionId = null,
|
||||||
|
// CancellationToken cancellationToken = default
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,15 @@ namespace xContentService.Models.Dtos
|
|||||||
{
|
{
|
||||||
public string OwnerId { get; set; }
|
public string OwnerId { get; set; }
|
||||||
public virtual XPersonDto Owner { get; set; }
|
public virtual XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public virtual XResourceDto TitleResource { get; set; }
|
public virtual XResourceDto TitleResource { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public virtual XResourceDto DescriptionResource { get; set; }
|
public virtual XResourceDto DescriptionResource { get; set; }
|
||||||
|
|
||||||
|
public string[] Tags { get; set; }
|
||||||
|
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
public DateTime UpdatedAt { get; set; }
|
public DateTime UpdatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using System.Linq;
|
|
||||||
using xModels.Dtos;
|
|
||||||
using System.Threading;
|
|
||||||
using xCommons.Extensions;
|
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xContentService.Interfaces;
|
|
||||||
using xContentService.Models.Dtos;
|
using xContentService.Models.Dtos;
|
||||||
using xIdentityService.Interfaces;
|
|
||||||
using xIdentityService.Extensions;
|
|
||||||
using xContentService.Interfaces.Dtos;
|
using xContentService.Interfaces.Dtos;
|
||||||
using xContentService.Models.Entities;
|
using xContentService.Models.Entities;
|
||||||
using xContentService.Interfaces.Entities;
|
using xContentService.Interfaces.Entities;
|
||||||
@@ -19,156 +11,13 @@ namespace xContentService.Providers.Dtos
|
|||||||
{
|
{
|
||||||
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
|
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
|
||||||
{
|
{
|
||||||
private readonly IXIdentityProvider identityProvider;
|
|
||||||
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
|
||||||
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
|
||||||
|
|
||||||
public XContentRepositoryService(
|
public XContentRepositoryService(
|
||||||
IXContentRepository repository,
|
IXContentRepository repository,
|
||||||
IXIdentityProvider identityProvider,
|
|
||||||
IXContentTitleResourceProvider titleResourceProvider,
|
|
||||||
IXContentDescriptionResourceProvider descriptionResourceProvider,
|
|
||||||
IEnumerable<Profile> mapperProfiles = null
|
IEnumerable<Profile> mapperProfiles = null
|
||||||
) : base(
|
) : base(
|
||||||
repository,
|
repository,
|
||||||
mapperProfiles
|
mapperProfiles
|
||||||
)
|
)
|
||||||
{
|
{ }
|
||||||
this.identityProvider = identityProvider;
|
|
||||||
this.titleResourceProvider = titleResourceProvider;
|
|
||||||
this.descriptionResourceProvider = descriptionResourceProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Enrichers ...
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Item ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<XContentDto> Enrich(
|
|
||||||
XContent source,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Mapping Default ...
|
|
||||||
var result = Mapper.Map<XContentDto>(source);
|
|
||||||
result = await Enrich(
|
|
||||||
source: result,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Item ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<XContentDto> Enrich(
|
|
||||||
XContentDto source,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Handdle Owner ...
|
|
||||||
XPersonDto owner = null;
|
|
||||||
if (!source.OwnerId.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Try to Retrieve User Info ...
|
|
||||||
var device = identityProvider.GetDevice();
|
|
||||||
var userInfo = await identityProvider.GetUserInfo(
|
|
||||||
device: device,
|
|
||||||
userSelectByParam: source.OwnerId
|
|
||||||
);
|
|
||||||
owner = userInfo.ToXPersonDto();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Hanlde Content Title ...
|
|
||||||
string contentTitle = string.Empty;
|
|
||||||
XResourceDto titleResource = await titleResourceProvider.GetResource(
|
|
||||||
identifier: source.Id,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
if (!titleResource.IsNullOrDefault())
|
|
||||||
{
|
|
||||||
contentTitle = titleResource.Resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Hanlde Content Description ...
|
|
||||||
string contentDescription = string.Empty;
|
|
||||||
XResourceDto descriptionResource = await descriptionResourceProvider.GetResource(
|
|
||||||
identifier: source.Id,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
if (!descriptionResource.IsNullOrDefault())
|
|
||||||
{
|
|
||||||
contentDescription = descriptionResource.Resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Attach Extracted Items ...
|
|
||||||
var result = Mapper.Map<XContentDto>(source, options =>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
options.Items[nameof(source.Owner)] = owner;
|
|
||||||
options.Items[nameof(source.Title)] = contentTitle;
|
|
||||||
options.Items[nameof(source.TitleResource)] = titleResource;
|
|
||||||
options.Items[nameof(source.Description)] = contentDescription;
|
|
||||||
options.Items[nameof(source.DescriptionResource)] = descriptionResource;
|
|
||||||
});
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Items ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sources"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<IEnumerable<XContentDto>> EnrichRange(
|
|
||||||
IEnumerable<XContent> sources,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var tasks = sources
|
|
||||||
.Select(x => Enrich(x, cancellationToken));
|
|
||||||
|
|
||||||
//
|
|
||||||
var result = await Task.WhenAll(tasks);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enrich Specified Items ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sources"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<IEnumerable<XContentDto>> EnrichRange(
|
|
||||||
IEnumerable<XContentDto> sources,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var tasks = sources
|
|
||||||
.Select(x => Enrich(x, cancellationToken));
|
|
||||||
|
|
||||||
//
|
|
||||||
var result = await Task.WhenAll(tasks);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,16 +15,19 @@ namespace xContentService.Providers.Enrichers
|
|||||||
{
|
{
|
||||||
public class XContentEnricher : IXContentEnricher
|
public class XContentEnricher : IXContentEnricher
|
||||||
{
|
{
|
||||||
|
private readonly IXContentTagProvided tagProvider;
|
||||||
private readonly IXIdentityProvider identityProvider;
|
private readonly IXIdentityProvider identityProvider;
|
||||||
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
private readonly IXContentTitleResourceProvider titleResourceProvider;
|
||||||
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
private readonly IXContentDescriptionResourceProvider descriptionResourceProvider;
|
||||||
|
|
||||||
public XContentEnricher(
|
public XContentEnricher(
|
||||||
|
IXContentTagProvided tagProvider,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
IXContentTitleResourceProvider titleResourceProvider,
|
IXContentTitleResourceProvider titleResourceProvider,
|
||||||
IXContentDescriptionResourceProvider descriptionResourceProvider
|
IXContentDescriptionResourceProvider descriptionResourceProvider
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
this.tagProvider = tagProvider;
|
||||||
this.identityProvider = identityProvider;
|
this.identityProvider = identityProvider;
|
||||||
this.titleResourceProvider = titleResourceProvider;
|
this.titleResourceProvider = titleResourceProvider;
|
||||||
this.descriptionResourceProvider = descriptionResourceProvider;
|
this.descriptionResourceProvider = descriptionResourceProvider;
|
||||||
@@ -105,10 +108,18 @@ namespace xContentService.Providers.Enrichers
|
|||||||
contentDescription = descriptionResource.Resource;
|
contentDescription = descriptionResource.Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var tags = await tagProvider.GetTags(
|
||||||
|
id: source.Id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Attach Extracted Items ...
|
// Attach Extracted Items ...
|
||||||
var result = source.MapConvert();
|
var result = source.MapConvert();
|
||||||
result.Owner = owner;
|
result.Owner = owner;
|
||||||
|
result.Tags = [..tags];
|
||||||
result.Title = contentTitle;
|
result.Title = contentTitle;
|
||||||
result.TitleResource = titleResource;
|
result.TitleResource = titleResource;
|
||||||
result.Description = contentDescription;
|
result.Description = contentDescription;
|
||||||
|
|||||||
@@ -419,10 +419,7 @@ namespace xContentService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Created On ...
|
// Created On ...
|
||||||
if (item.CreatedOn.IsNull())
|
item.CreatedOn = DateTime.UtcNow;
|
||||||
{
|
|
||||||
item.CreatedOn = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Normalized Items ...
|
// Validate Normalized Items ...
|
||||||
|
|||||||
Reference in New Issue
Block a user