mirror of https://github.com/abpframework/abp.git
11 changed files with 214 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public static class TagConsts |
|||
{ |
|||
public static int MaxNameLength { get; set; } = 32; |
|||
|
|||
public static int MaxColorHexLength { get; set; } = 6; |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class EntityTag : AggregateRoot |
|||
{ |
|||
protected EntityTag() |
|||
{ |
|||
} |
|||
|
|||
public EntityTag(string entityType, string entityId, Guid tagId) |
|||
{ |
|||
EntityType = entityType; |
|||
EntityId = entityId; |
|||
TagId = tagId; |
|||
} |
|||
|
|||
public virtual string EntityType { get; protected set; } |
|||
|
|||
public virtual string EntityId { get; protected set; } |
|||
|
|||
public virtual Guid TagId { get; set; } |
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] |
|||
{ |
|||
EntityType, |
|||
EntityId, |
|||
TagId |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.EntityTags; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.EntityTags |
|||
{ |
|||
public class EntityTagManager : IEntityTagManager |
|||
{ |
|||
private readonly ITagRepository tagRepository; |
|||
private readonly IEntityTagRepository entityTagRepository; |
|||
|
|||
public EntityTagManager( |
|||
ITagRepository tagRepository, |
|||
IEntityTagRepository entityTagRepository) |
|||
{ |
|||
this.tagRepository = tagRepository; |
|||
this.entityTagRepository = entityTagRepository; |
|||
} |
|||
|
|||
public Task AddTagToEntityAsync(Guid tagId, string entityType, string entityId) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Task<IList<Tag>> GetEntityTagsAsync(string entityType, string entityId) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Task RemoveTagFromEntityAsync(Guid tagId, string entityType, string entityId) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.EntityTags |
|||
{ |
|||
public interface IEntityTagManager |
|||
{ |
|||
Task AddTagToEntityAsync(Guid tagId, string entityType, string entityId); |
|||
Task RemoveTagFromEntityAsync(Guid tagId, string entityType, string entityId); |
|||
Task<IList<Tag>> GetEntityTagsAsync(string entityType, string entityId); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.EntityTags |
|||
{ |
|||
public interface IEntityTagRepository : IBasicRepository<EntityTag> |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public interface ITagRepository : IBasicRepository<Tag, Guid> |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Auditing; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class Tag : BasicAggregateRoot<Guid>, IMultiTenant, IHasCreationTime |
|||
{ |
|||
protected Tag() |
|||
{ |
|||
} |
|||
|
|||
public Tag( |
|||
[NotNull] string name, |
|||
[CanBeNull] string colorHex, |
|||
[NotNull] Guid? tenantId = null) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TagConsts.MaxNameLength); |
|||
ColorHex = Check.Length(colorHex, nameof(colorHex), TagConsts.MaxColorHexLength); |
|||
TenantId = tenantId; |
|||
} |
|||
|
|||
public virtual string Name { get; set; } |
|||
public virtual string ColorHex { get; set; } |
|||
public Guid? TenantId { get; } |
|||
public DateTime CreationTime { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.CmsKit.EntityFrameworkCore; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.EntityTags |
|||
{ |
|||
public class EfCoreEntityTagRepository : EfCoreRepository<ICmsKitDbContext, EntityTag>, IEntityTagRepository |
|||
{ |
|||
public EfCoreEntityTagRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.CmsKit.EntityFrameworkCore; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public class EfCoreTagRepository : EfCoreRepository<ICmsKitDbContext, Tag, Guid>, ITagRepository |
|||
{ |
|||
public EfCoreTagRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.Domain.Repositories.MongoDB; |
|||
using Volo.Abp.MongoDB; |
|||
using Volo.CmsKit.EntityTags; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.MongoDB.EntityTags |
|||
{ |
|||
public class MongoEntityTagRepository : MongoDbRepository<ICmsKitMongoDbContext, EntityTag>, IEntityTagRepository |
|||
{ |
|||
public MongoEntityTagRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Repositories.MongoDB; |
|||
using Volo.Abp.MongoDB; |
|||
using Volo.CmsKit.MongoDB; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace CmsKit.MongoDB.Tags |
|||
{ |
|||
public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Tag, Guid>, ITagRepository |
|||
{ |
|||
public MongoTagRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue