mirror of https://github.com/abpframework/abp.git
7 changed files with 102 additions and 4 deletions
@ -0,0 +1,16 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class EntityTagCreateDto |
|||
{ |
|||
[Required] |
|||
public string TagName { get; set; } |
|||
|
|||
[Required] |
|||
public string EntityType { get; set; } |
|||
|
|||
[Required] |
|||
public string EntityId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class EntityTagRemoveDto |
|||
{ |
|||
[Required] |
|||
public Guid TagId { get; set; } |
|||
|
|||
[Required] |
|||
public string EntityType { get; set; } |
|||
|
|||
[Required] |
|||
public string EntityId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public interface IEntityTagAdminAppService |
|||
{ |
|||
Task AddTagToEntityAsync(EntityTagCreateDto input); |
|||
|
|||
Task RemoveTagFromEntityAsync(EntityTagRemoveDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.Admin.Tags; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Admin.Application.Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class EntityTagAdminAppService : CmsKitAdminAppServiceBase, IEntityTagAdminAppService |
|||
{ |
|||
protected ITagDefinitionStore _tagDefinitionStore; |
|||
protected IEntityTagManager _entityTagManager; |
|||
protected ITagManager _tagManager; |
|||
|
|||
public EntityTagAdminAppService( |
|||
ITagDefinitionStore tagDefinitionStore, |
|||
IEntityTagManager entityTagManager, |
|||
ITagManager tagManager) |
|||
{ |
|||
_tagDefinitionStore = tagDefinitionStore; |
|||
_entityTagManager = entityTagManager; |
|||
_tagManager = tagManager; |
|||
} |
|||
|
|||
public async Task AddTagToEntityAsync(EntityTagCreateDto input) |
|||
{ |
|||
var definition = await _tagDefinitionStore.GetTagDefinitionAsync(input.EntityType); |
|||
|
|||
await CheckPolicyAsync(definition.CreatePolicy); |
|||
|
|||
var tag = await _tagManager.GetOrAddAsync(input.EntityType, input.TagName, CurrentTenant?.Id); |
|||
|
|||
await _entityTagManager.AddTagToEntityAsync( |
|||
tag.Id, |
|||
input.EntityType, |
|||
input.EntityId, |
|||
CurrentTenant?.Id); |
|||
} |
|||
|
|||
public async Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) |
|||
{ |
|||
var definition = await _tagDefinitionStore.GetTagDefinitionAsync(input.EntityType); |
|||
|
|||
await CheckPolicyAsync(definition.DeletePolicy); |
|||
|
|||
await _entityTagManager.RemoveTagFromEntityAsync( |
|||
input.TagId, |
|||
input.EntityType, |
|||
input.EntityId, |
|||
CurrentTenant?.Id); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue