mirror of https://github.com/abpframework/abp.git
17 changed files with 218 additions and 11 deletions
@ -0,0 +1,8 @@ |
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagDefinitionDto |
|||
{ |
|||
public string EntityType { get; set; } |
|||
public string DisplayName { get; set; } |
|||
} |
|||
} |
|||
@ -1,16 +1,15 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.CmsKit.Reactions; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit |
|||
{ |
|||
public class CmsKitOptions |
|||
{ |
|||
[NotNull] |
|||
public ReactionDefinitionDictionary Reactions { get; } |
|||
public ReactionDefinitionDictionary Reactions { get; } = new ReactionDefinitionDictionary(); |
|||
|
|||
public CmsKitOptions() |
|||
{ |
|||
Reactions = new ReactionDefinitionDictionary(); |
|||
} |
|||
[NotNull] |
|||
public TagDefinitionDictionary Tags { get; } = new TagDefinitionDictionary(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,37 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace Volo.CmsKit.Domain.Volo.CmsKit |
|||
{ |
|||
public abstract class PolicySpecifiedDefinition |
|||
{ |
|||
protected PolicySpecifiedDefinition() |
|||
{ |
|||
} |
|||
|
|||
public PolicySpecifiedDefinition( |
|||
[CanBeNull] ILocalizableString displayName = null, |
|||
[CanBeNull] string createPolicy = null, |
|||
[CanBeNull] string updatePolicy = null, |
|||
[CanBeNull] string deletePolicy = null) |
|||
{ |
|||
DisplayName = displayName; |
|||
CreatePolicy = createPolicy; |
|||
DeletePolicy = deletePolicy; |
|||
UpdatePolicy = updatePolicy; |
|||
} |
|||
|
|||
[CanBeNull] |
|||
public virtual ILocalizableString DisplayName { get; } |
|||
|
|||
[CanBeNull] |
|||
public virtual string CreatePolicy { get; set; } |
|||
|
|||
[CanBeNull] |
|||
public virtual string UpdatePolicy { get; set; } |
|||
|
|||
[CanBeNull] |
|||
public virtual string DeletePolicy { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class DefaultTagDefinitionStore : ITagDefinitionStore, ITransientDependency |
|||
{ |
|||
private readonly CmsKitOptions options; |
|||
|
|||
public DefaultTagDefinitionStore(IOptions<CmsKitOptions> options) |
|||
{ |
|||
this.options = options.Value; |
|||
} |
|||
|
|||
public Task<TagDefiniton> GetTagDefinitionOrNullAsync([NotNull] string entityType) |
|||
{ |
|||
Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); |
|||
return Task.FromResult(options.Tags.GetOrDefault(entityType)); |
|||
} |
|||
|
|||
public Task<List<TagDefiniton>> GetTagDefinitionsAsync() |
|||
{ |
|||
return Task.FromResult(options.Tags.Values.ToList()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using JetBrains.Annotations; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public interface ITagDefinitionStore |
|||
{ |
|||
Task<List<TagDefiniton>> GetTagDefinitionsAsync(); |
|||
|
|||
Task<TagDefiniton> GetTagDefinitionOrNullAsync([NotNull] string entityType); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using JetBrains.Annotations; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class TagDefinitionDictionary : Dictionary<string, TagDefiniton> |
|||
{ |
|||
public void AddOrReplace( |
|||
[NotNull] string entityType, |
|||
[CanBeNull] ILocalizableString displayName = null, |
|||
[CanBeNull] string createPolicy = null, |
|||
[CanBeNull] string updatePolicy = null, |
|||
[CanBeNull] string deletePolicy = null |
|||
) |
|||
{ |
|||
this[entityType] = new TagDefiniton(entityType, displayName, createPolicy, updatePolicy, deletePolicy); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Localization; |
|||
using Volo.CmsKit.Domain.Volo.CmsKit; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class TagDefiniton : PolicySpecifiedDefinition |
|||
{ |
|||
public string EntityType { get; } |
|||
|
|||
public TagDefiniton() |
|||
{ |
|||
} |
|||
|
|||
public TagDefiniton( |
|||
[NotNull] string entityType, |
|||
[CanBeNull] ILocalizableString displayName = null, |
|||
[CanBeNull] string createPolicy = null, |
|||
[CanBeNull] string updatePolicy = null, |
|||
[CanBeNull] string deletePolicy = null) : base(displayName, createPolicy, updatePolicy, deletePolicy) |
|||
{ |
|||
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); |
|||
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue