Skip to content

Commit

Permalink
chore: fix docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
LeDuyNhan1201 committed Oct 18, 2024
1 parent ca2952b commit 8b751f6
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 4 deletions.
24 changes: 24 additions & 0 deletions Tag.Domain/Entities/CommentTag.cs
Original file line number Diff line number Diff line change
@@ -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.
}

}
24 changes: 24 additions & 0 deletions Tag.Domain/Entities/PostTag.cs
Original file line number Diff line number Diff line change
@@ -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.
}

}
13 changes: 13 additions & 0 deletions Tag.Domain/Repositories/ICommentTagRepository.cs
Original file line number Diff line number Diff line change
@@ -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<CommentTag, Guid>
{



}
}
13 changes: 13 additions & 0 deletions Tag.Domain/Repositories/IPostTagRepository.cs
Original file line number Diff line number Diff line change
@@ -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<PostTag, Guid>
{



}
}
9 changes: 9 additions & 0 deletions Tag.Infrastructure/Data/TagDbContext.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -8,7 +9,9 @@ namespace InfinityNetServer.Services.Tag.Infrastructure.Data
public class TagDbContext : PostreSqlDbContext<TagDbContext>
{

DbSet<PostTag> PostTags { get; set; }

DbSet<CommentTag> CommentTags { get; set; }

public TagDbContext(
DbContextOptions<TagDbContext> options,
Expand All @@ -20,7 +23,13 @@ public TagDbContext(

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PostTag>()
.HasIndex(pt => new { pt.PostId, pt.TaggedProfileId })
.IsUnique();

modelBuilder.Entity<CommentTag>()
.HasIndex(ct => new { ct.CommentId, ct.TaggedProfileId })
.IsUnique();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<IPageProfileRepository, PageProfileRepository>();
services.AddScoped<IPostTagRepository, PostTagRepository>();
services.AddScoped<ICommentTagRepository, CommentTagRepository>();
}

}
16 changes: 16 additions & 0 deletions Tag.Infrastructure/Repositories/CommentTagRepository.cs
Original file line number Diff line number Diff line change
@@ -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<CommentTag, Guid>, ICommentTagRepository
{
public CommentTagRepository(DbContext context) : base(context) { }



}
}
16 changes: 16 additions & 0 deletions Tag.Infrastructure/Repositories/PostTagRepository.cs
Original file line number Diff line number Diff line change
@@ -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<PostTag, Guid>, IPostTagRepository
{
public PostTagRepository(DbContext context) : base(context) { }



}
}
17 changes: 16 additions & 1 deletion Tag.Presentation/Configurations/GrpcExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,24 @@ public static void AddGrpcClients(this IServiceCollection services, IConfigurati
options.Address = new Uri(configuration["GrpcServers:ProfileService"]);
});

services.AddGrpcClient<PostService.PostServiceClient>(options =>
{
options.Address = new Uri(configuration["GrpcServers:PostService"]);
});

services.AddGrpcClient<CommentService.CommentServiceClient>(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));

}

}
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.

0 comments on commit 8b751f6

Please sign in to comment.