diff --git a/Tag.Domain/Entities/CommentTag.cs b/Tag.Domain/Entities/CommentTag.cs new file mode 100644 index 0000000..52a0ac1 --- /dev/null +++ b/Tag.Domain/Entities/CommentTag.cs @@ -0,0 +1,24 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using InfinityNetServer.BuildingBlocks.Domain.Entities; + +namespace InfinityNetServer.Services.Tag.Domain.Entities +{ + [Table("commentTags")] + public class CommentTag : AuditEntity + { + [Key] + [Column("id")] + public Guid Id { get; set; } + + [Column("comment_id")] + public Guid CommentId { get; set; } // Links to Comment service + + [Column("tagged_profile_id")] + public Guid TaggedProfileId { get; set; } // Links to Profile service + + // Optional: To enforce unique constraint in code, this can be handled in the DbContext's OnModelCreating method. + } + +} diff --git a/Tag.Domain/Entities/PostTag.cs b/Tag.Domain/Entities/PostTag.cs new file mode 100644 index 0000000..21ad556 --- /dev/null +++ b/Tag.Domain/Entities/PostTag.cs @@ -0,0 +1,24 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using InfinityNetServer.BuildingBlocks.Domain.Entities; + +namespace InfinityNetServer.Services.Tag.Domain.Entities +{ + [Table("post_tags")] + public class PostTag : AuditEntity + { + [Key] + [Column("id")] + public Guid Id { get; set; } + + [Column("post_id")] + public Guid PostId { get; set; } // Links to Post service + + [Column("tagged_profile_id")] + public Guid TaggedProfileId { get; set; } // Links to Profile service + + // Optional: To enforce unique constraint in code, this can be handled in the DbContext's OnModelCreating method. + } + +} diff --git a/Tag.Domain/Repositories/ICommentTagRepository.cs b/Tag.Domain/Repositories/ICommentTagRepository.cs new file mode 100644 index 0000000..e44e624 --- /dev/null +++ b/Tag.Domain/Repositories/ICommentTagRepository.cs @@ -0,0 +1,13 @@ +using InfinityNetServer.BuildingBlocks.Domain.Repositories; +using InfinityNetServer.Services.Tag.Domain.Entities; +using System; + +namespace InfinityNetServer.Services.Tag.Domain.Repositories +{ + public interface ICommentTagRepository : ISqlRepository + { + + + + } +} diff --git a/Tag.Domain/Repositories/IPostTagRepository.cs b/Tag.Domain/Repositories/IPostTagRepository.cs new file mode 100644 index 0000000..6768ac2 --- /dev/null +++ b/Tag.Domain/Repositories/IPostTagRepository.cs @@ -0,0 +1,13 @@ +using InfinityNetServer.BuildingBlocks.Domain.Repositories; +using InfinityNetServer.Services.Tag.Domain.Entities; +using System; + +namespace InfinityNetServer.Services.Tag.Domain.Repositories +{ + public interface IPostTagRepository : ISqlRepository + { + + + + } +} diff --git a/Tag.Infrastructure/Data/TagDbContext.cs b/Tag.Infrastructure/Data/TagDbContext.cs index d995e02..9a8f5e3 100644 --- a/Tag.Infrastructure/Data/TagDbContext.cs +++ b/Tag.Infrastructure/Data/TagDbContext.cs @@ -1,5 +1,6 @@ using InfinityNetServer.BuildingBlocks.Application.Services; using InfinityNetServer.BuildingBlocks.Infrastructure.PostgreSQL; +using InfinityNetServer.Services.Tag.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; @@ -8,7 +9,9 @@ namespace InfinityNetServer.Services.Tag.Infrastructure.Data public class TagDbContext : PostreSqlDbContext { + DbSet PostTags { get; set; } + DbSet CommentTags { get; set; } public TagDbContext( DbContextOptions options, @@ -20,7 +23,13 @@ public TagDbContext( protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity() + .HasIndex(pt => new { pt.PostId, pt.TaggedProfileId }) + .IsUnique(); + modelBuilder.Entity() + .HasIndex(ct => new { ct.CommentId, ct.TaggedProfileId }) + .IsUnique(); } } diff --git a/Tag.Infrastructure/DependencyInjection/InfrastructureModule.cs b/Tag.Infrastructure/DependencyInjection/InfrastructureModule.cs index c9a2edc..555ecc4 100644 --- a/Tag.Infrastructure/DependencyInjection/InfrastructureModule.cs +++ b/Tag.Infrastructure/DependencyInjection/InfrastructureModule.cs @@ -2,6 +2,8 @@ using InfinityNetServer.BuildingBlocks.Domain.Repositories; using InfinityNetServer.BuildingBlocks.Infrastructure.PostgreSQL.Repositories; using InfinityNetServer.Services.Tag.Infrastructure.Data; +using InfinityNetServer.Services.Tag.Domain.Repositories; +using InfinityNetServer.Services.Tag.Infrastructure.Repositories; namespace InfinityNetServer.Services.Tag.Infrastructure.DependencyInjection; @@ -16,7 +18,8 @@ public static void AddDbContext(this IServiceCollection services) public static void AddRepositories(this IServiceCollection services) { services.AddScoped(typeof(ISqlRepository<,>), typeof(SqlRepository<,>)); - //services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } } diff --git a/Tag.Infrastructure/Repositories/CommentTagRepository.cs b/Tag.Infrastructure/Repositories/CommentTagRepository.cs new file mode 100644 index 0000000..1e5ce7f --- /dev/null +++ b/Tag.Infrastructure/Repositories/CommentTagRepository.cs @@ -0,0 +1,16 @@ +using InfinityNetServer.BuildingBlocks.Infrastructure.PostgreSQL.Repositories; +using InfinityNetServer.Services.Tag.Domain.Repositories; +using InfinityNetServer.Services.Tag.Domain.Entities; +using System; +using Microsoft.EntityFrameworkCore; + +namespace InfinityNetServer.Services.Tag.Infrastructure.Repositories +{ + public class CommentTagRepository : SqlRepository, ICommentTagRepository + { + public CommentTagRepository(DbContext context) : base(context) { } + + + + } +} diff --git a/Tag.Infrastructure/Repositories/PostTagRepository.cs b/Tag.Infrastructure/Repositories/PostTagRepository.cs new file mode 100644 index 0000000..9842e91 --- /dev/null +++ b/Tag.Infrastructure/Repositories/PostTagRepository.cs @@ -0,0 +1,16 @@ +using InfinityNetServer.BuildingBlocks.Infrastructure.PostgreSQL.Repositories; +using InfinityNetServer.Services.Tag.Domain.Repositories; +using InfinityNetServer.Services.Tag.Domain.Entities; +using System; +using Microsoft.EntityFrameworkCore; + +namespace InfinityNetServer.Services.Tag.Infrastructure.Repositories +{ + public class PostTagRepository : SqlRepository, IPostTagRepository + { + public PostTagRepository(DbContext context) : base(context) { } + + + + } +} diff --git a/Tag.Presentation/Configurations/GrpcExtensions.cs b/Tag.Presentation/Configurations/GrpcExtensions.cs index 971732b..f979af9 100644 --- a/Tag.Presentation/Configurations/GrpcExtensions.cs +++ b/Tag.Presentation/Configurations/GrpcExtensions.cs @@ -27,9 +27,24 @@ public static void AddGrpcClients(this IServiceCollection services, IConfigurati options.Address = new Uri(configuration["GrpcServers:ProfileService"]); }); + services.AddGrpcClient(options => + { + options.Address = new Uri(configuration["GrpcServers:PostService"]); + }); + + services.AddGrpcClient(options => + { + options.Address = new Uri(configuration["GrpcServers:CommentService"]); + }); + services.AddScoped(typeof(CommonIdentityClient)); - //services.AddScoped(typeof(ProfileClient)); + services.AddScoped(typeof(CommonProfileClient)); + + services.AddScoped(typeof(CommonPostClient)); + + services.AddScoped(typeof(CommonCommentClient)); + } } diff --git a/docker-compose.yml b/docker-compose.yml index bf1fa08..69a4fac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,8 +67,7 @@ services: - "5432:5432" volumes: - infinity-net-postgres-data:/var/lib/postgresql/data - - ./D:wq - ocker/postgres/postgres-init-db:/docker-entrypoint-initdb.d + - ./Docker/postgres/postgres-init-db:/docker-entrypoint-initdb.d:ro networks: - infinity-net-network restart: unless-stopped diff --git a/InfinityNetServer.sln b/net-server.sln similarity index 100% rename from InfinityNetServer.sln rename to net-server.sln