From 7802ff9561ff7613599d9f080d807e385f7ab69f Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 6 Sep 2026 08:45:26 +0330 Subject: [PATCH] last ... --- Interfaces/Dtos/IXContentRepositoryService.cs | 52 +----- Interfaces/IXContentProvider.cs | 17 +- Models/Dtos/XContentDto.cs | 8 +- Providers/Dtos/XContentRepositoryService.cs | 153 +----------------- Providers/Enrichers/XContentEnricher.cs | 11 ++ Providers/XContentProvider.cs | 5 +- 6 files changed, 35 insertions(+), 211 deletions(-) diff --git a/Interfaces/Dtos/IXContentRepositoryService.cs b/Interfaces/Dtos/IXContentRepositoryService.cs index 3535164..e296d08 100644 --- a/Interfaces/Dtos/IXContentRepositoryService.cs +++ b/Interfaces/Dtos/IXContentRepositoryService.cs @@ -1,60 +1,10 @@ using System; -using System.Threading; -using System.Threading.Tasks; using xDataService.Interfaces; -using System.Collections.Generic; using xContentService.Models.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Dtos { public interface IXContentRepositoryService : IXBaseRepositoryService - { - // - #region Enrichers ... - /// - /// Enrich Specified Item ... - /// - /// - /// - /// - Task Enrich( - XContent source, - CancellationToken cancellationToken = default - ); - - /// - /// Enrich Specified Item ... - /// - /// - /// - /// - Task Enrich( - XContentDto source, - CancellationToken cancellationToken = default - ); - - /// - /// Enrich Specified Items ... - /// - /// - /// - /// - Task> EnrichRange( - IEnumerable sources, - CancellationToken cancellationToken = default - ); - - /// - /// Enrich Specified Items ... - /// - /// - /// - /// - Task> EnrichRange( - IEnumerable sources, - CancellationToken cancellationToken = default - ); - #endregion - } + { } } \ No newline at end of file diff --git a/Interfaces/IXContentProvider.cs b/Interfaces/IXContentProvider.cs index 69b8538..02bd7c5 100644 --- a/Interfaces/IXContentProvider.cs +++ b/Interfaces/IXContentProvider.cs @@ -26,6 +26,21 @@ namespace xContentService.Interfaces string connectionId = null, string language = null, CancellationToken cancellationToken = default - ); + ); + + // /// + // /// Create Content Used Locales for Creating Posts ... + // /// + // /// + // /// + // /// + // /// + // /// + // public Task Create( + // XContentDto item, + // XUserClaimsInfoDto userInfo = null, + // string connectionId = null, + // CancellationToken cancellationToken = default + // ); } } \ No newline at end of file diff --git a/Models/Dtos/XContentDto.cs b/Models/Dtos/XContentDto.cs index a25c5ea..eda2274 100644 --- a/Models/Dtos/XContentDto.cs +++ b/Models/Dtos/XContentDto.cs @@ -11,13 +11,15 @@ namespace xContentService.Models.Dtos { public string OwnerId { get; set; } public virtual XPersonDto Owner { get; set; } - + public string Title { get; set; } public virtual XResourceDto TitleResource { get; set; } - + public string Description { get; set; } public virtual XResourceDto DescriptionResource { get; set; } - + + public string[] Tags { get; set; } + public DateTime CreatedOn { get; set; } public DateTime UpdatedAt { get; set; } } diff --git a/Providers/Dtos/XContentRepositoryService.cs b/Providers/Dtos/XContentRepositoryService.cs index 677b4d7..d9b4b4c 100644 --- a/Providers/Dtos/XContentRepositoryService.cs +++ b/Providers/Dtos/XContentRepositoryService.cs @@ -1,16 +1,8 @@ using System; using AutoMapper; -using System.Linq; -using xModels.Dtos; -using System.Threading; -using xCommons.Extensions; using xDataService.Providers; -using System.Threading.Tasks; using System.Collections.Generic; -using xContentService.Interfaces; using xContentService.Models.Dtos; -using xIdentityService.Interfaces; -using xIdentityService.Extensions; using xContentService.Interfaces.Dtos; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; @@ -19,156 +11,13 @@ namespace xContentService.Providers.Dtos { public class XContentRepositoryService : XBaseRepositoryService, IXContentRepositoryService { - private readonly IXIdentityProvider identityProvider; - private readonly IXContentTitleResourceProvider titleResourceProvider; - private readonly IXContentDescriptionResourceProvider descriptionResourceProvider; - public XContentRepositoryService( IXContentRepository repository, - IXIdentityProvider identityProvider, - IXContentTitleResourceProvider titleResourceProvider, - IXContentDescriptionResourceProvider descriptionResourceProvider, IEnumerable mapperProfiles = null ) : base( repository, mapperProfiles ) - { - this.identityProvider = identityProvider; - this.titleResourceProvider = titleResourceProvider; - this.descriptionResourceProvider = descriptionResourceProvider; - } - - // - #region Enrichers ... - /// - /// Enrich Specified Item ... - /// - /// - /// - /// - public async Task Enrich( - XContent source, - CancellationToken cancellationToken = default - ) - { - // - // Mapping Default ... - var result = Mapper.Map(source); - result = await Enrich( - source: result, - cancellationToken: cancellationToken - ); - - // - return result; - } - - /// - /// Enrich Specified Item ... - /// - /// - /// - /// - public async Task 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(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; - } - - /// - /// Enrich Specified Items ... - /// - /// - /// - /// - public async Task> EnrichRange( - IEnumerable sources, - CancellationToken cancellationToken = default - ) - { - // - var tasks = sources - .Select(x => Enrich(x, cancellationToken)); - - // - var result = await Task.WhenAll(tasks); - return result; - } - - /// - /// Enrich Specified Items ... - /// - /// - /// - /// - public async Task> EnrichRange( - IEnumerable sources, - CancellationToken cancellationToken = default - ) - { - // - var tasks = sources - .Select(x => Enrich(x, cancellationToken)); - - // - var result = await Task.WhenAll(tasks); - return result; - } - #endregion + { } } } \ No newline at end of file diff --git a/Providers/Enrichers/XContentEnricher.cs b/Providers/Enrichers/XContentEnricher.cs index f51e3d5..ef7750d 100644 --- a/Providers/Enrichers/XContentEnricher.cs +++ b/Providers/Enrichers/XContentEnricher.cs @@ -15,16 +15,19 @@ namespace xContentService.Providers.Enrichers { public class XContentEnricher : IXContentEnricher { + private readonly IXContentTagProvided tagProvider; private readonly IXIdentityProvider identityProvider; private readonly IXContentTitleResourceProvider titleResourceProvider; private readonly IXContentDescriptionResourceProvider descriptionResourceProvider; public XContentEnricher( + IXContentTagProvided tagProvider, IXIdentityProvider identityProvider, IXContentTitleResourceProvider titleResourceProvider, IXContentDescriptionResourceProvider descriptionResourceProvider ) { + this.tagProvider = tagProvider; this.identityProvider = identityProvider; this.titleResourceProvider = titleResourceProvider; this.descriptionResourceProvider = descriptionResourceProvider; @@ -105,10 +108,18 @@ namespace xContentService.Providers.Enrichers contentDescription = descriptionResource.Resource; } + // + var tags = await tagProvider.GetTags( + id: source.Id, + cancellationToken: cancellationToken + ); + + // // Attach Extracted Items ... var result = source.MapConvert(); result.Owner = owner; + result.Tags = [..tags]; result.Title = contentTitle; result.TitleResource = titleResource; result.Description = contentDescription; diff --git a/Providers/XContentProvider.cs b/Providers/XContentProvider.cs index a7c0add..3e23bcc 100644 --- a/Providers/XContentProvider.cs +++ b/Providers/XContentProvider.cs @@ -419,10 +419,7 @@ namespace xContentService.Providers // // Created On ... - if (item.CreatedOn.IsNull()) - { - item.CreatedOn = DateTime.UtcNow; - } + item.CreatedOn = DateTime.UtcNow; // // Validate Normalized Items ...