cdn
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
using Google.Protobuf;
|
||||||
|
using VizhTalk.Grpc.Learning;
|
||||||
|
|
||||||
|
namespace VizhTalk.Gateway.Web.BFF.Mappers
|
||||||
|
{
|
||||||
|
public static class UploadMapper
|
||||||
|
{
|
||||||
|
public static async Task<UploadFile> AsFile(this IFile file)
|
||||||
|
{
|
||||||
|
MemoryStream stream = new MemoryStream();
|
||||||
|
await file.CopyToAsync(stream);
|
||||||
|
return new UploadFile()
|
||||||
|
{
|
||||||
|
ContentType = file.ContentType,
|
||||||
|
File = ByteString.FromStream(stream),
|
||||||
|
Name = file.Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace VizhTalk.Gateway.Web.BFF.Models;
|
||||||
|
|
||||||
|
public record IdRequest(string Value);
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
namespace VizhTalk.Gateway.Web.BFF.Models;
|
||||||
|
|
||||||
|
public record CreateLanguageRequest(string Title,IFile Icon);
|
||||||
|
public record UpdateLanguageRequest(IdRequest Id, string Title,IFile Icon);
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using VizhTalk.Grpc.Learning;
|
using VizhTalk.Gateway.Web.BFF.Mappers;
|
||||||
|
using VizhTalk.Gateway.Web.BFF.Models;
|
||||||
|
using VizhTalk.Grpc.Learning;
|
||||||
using VizhTalk.Grpc.Learning.Language;
|
using VizhTalk.Grpc.Learning.Language;
|
||||||
|
|
||||||
namespace VizhTalk.Gateway.Web.BFF.Mutations;
|
namespace VizhTalk.Gateway.Web.BFF.Mutations;
|
||||||
@@ -6,10 +8,23 @@ namespace VizhTalk.Gateway.Web.BFF.Mutations;
|
|||||||
public class LanguageMutation(LanguageGrpc.LanguageGrpcClient client)
|
public class LanguageMutation(LanguageGrpc.LanguageGrpcClient client)
|
||||||
{
|
{
|
||||||
[GraphQLName("CreateLanguage")]
|
[GraphQLName("CreateLanguage")]
|
||||||
public async Task<LanguageDTO> CreateLanguage(CreateLanguageCommand request)
|
public async Task<LanguageDTO> CreateLanguage(CreateLanguageRequest request)
|
||||||
=> await client.CreateAsync(request);
|
{
|
||||||
|
return await client.CreateAsync(new CreateLanguageCommand()
|
||||||
|
{
|
||||||
|
Title = request.Title,
|
||||||
|
Icon = await request.Icon.AsFile()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[GraphQLName("UpdateLanguage")]
|
[GraphQLName("UpdateLanguage")]
|
||||||
public async Task<LanguageDTO> UpdateLanguage(UpdateLanguageCommand request)
|
public async Task<LanguageDTO> UpdateLanguage(UpdateLanguageRequest request)
|
||||||
=> await client.UpdateAsync(request);
|
{
|
||||||
|
return await client.UpdateAsync(new UpdateLanguageCommand()
|
||||||
|
{
|
||||||
|
Id = new Id(request.Id.Value),
|
||||||
|
Title = request.Title,
|
||||||
|
Icon = await request.Icon.AsFile()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ namespace VizhTalk.Gateway.Web.BFF.Queries
|
|||||||
public class LanguageQuery(LanguageGrpc.LanguageGrpcClient client)
|
public class LanguageQuery(LanguageGrpc.LanguageGrpcClient client)
|
||||||
{
|
{
|
||||||
[GraphQLName("Languages")]
|
[GraphQLName("Languages")]
|
||||||
public async Task<GetAllLanguageDTO> GetAllLanguage()
|
public async Task<GetAllLanguageDTO> GetAllLanguage(GetAllLanguageQuery request)
|
||||||
=> await client.GetAllAsync(new GetAllLanguageQuery());
|
=> await client.GetAllAsync(request);
|
||||||
|
|
||||||
[GraphQLName("LanguageByTitle")]
|
[GraphQLName("LanguageByTitle")]
|
||||||
public async Task<LanguageDTO> GetLanguageByTitle(GetLanguageByTitleQuery request)
|
public async Task<LanguageDTO> GetLanguageByTitle(GetLanguageByTitleQuery request)
|
||||||
|
|||||||
@@ -15,4 +15,8 @@
|
|||||||
<ProjectReference Include="..\VizhTalk.Services.Grpc.Learning\VizhTalk.Grpc.Learning.csproj" />
|
<ProjectReference Include="..\VizhTalk.Services.Grpc.Learning\VizhTalk.Grpc.Learning.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Types\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package greet;
|
|||||||
import "DTOs.proto";
|
import "DTOs.proto";
|
||||||
|
|
||||||
message UploadFileCommand{
|
message UploadFileCommand{
|
||||||
bytes file = 1;
|
UploadFile file = 1;
|
||||||
Id mediaGroupId = 2;
|
Id mediaGroupId = 2;
|
||||||
string clientId = 3;
|
string clientId = 3;
|
||||||
string fileName = 4;
|
string fileName = 4;
|
||||||
@@ -17,3 +17,8 @@ message CreateMediaGroupCommand{
|
|||||||
bool isSecure = 2;
|
bool isSecure = 2;
|
||||||
string title = 3;
|
string title = 3;
|
||||||
}
|
}
|
||||||
|
message UploadFile{
|
||||||
|
bytes file=1;
|
||||||
|
string name = 2;
|
||||||
|
string contentType = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Google.Protobuf" Version="3.32.0" />
|
||||||
|
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
|
||||||
|
<PackageReference Include="Grpc.Tools" Version="2.58.0" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -41,7 +41,12 @@ public class CreateLanguageCommandHandler(IUnitOfWork unitOfWork,
|
|||||||
}
|
}
|
||||||
var upload = await cdnClient.UploadFileAsync(new UploadFileCommand()
|
var upload = await cdnClient.UploadFileAsync(new UploadFileCommand()
|
||||||
{
|
{
|
||||||
File = request.Icon,
|
File = new Grpc.CDN.UploadFile()
|
||||||
|
{
|
||||||
|
ContentType = request.Icon.ContentType,
|
||||||
|
File = request.Icon.File,
|
||||||
|
Name = request.Icon.Name,
|
||||||
|
},
|
||||||
FileName = title,
|
FileName = title,
|
||||||
MediaGroupId = fileGroup.MediaGroupId
|
MediaGroupId = fileGroup.MediaGroupId
|
||||||
}, cancellationToken: cancellationToken);
|
}, cancellationToken: cancellationToken);
|
||||||
@@ -77,7 +82,12 @@ public class UpdateLanguageCommandHandler(IUnitOfWork unitOfWork, CDNGrpc.CDNGrp
|
|||||||
|
|
||||||
var upload = await cdnClient.UploadFileAsync(new UploadFileCommand()
|
var upload = await cdnClient.UploadFileAsync(new UploadFileCommand()
|
||||||
{
|
{
|
||||||
File = request.Icon,
|
File = new Grpc.CDN.UploadFile()
|
||||||
|
{
|
||||||
|
ContentType = request.Icon.ContentType,
|
||||||
|
File = request.Icon.File,
|
||||||
|
Name = request.Icon.Name,
|
||||||
|
},
|
||||||
FileName = request.Title,
|
FileName = request.Title,
|
||||||
MediaGroupId = fileGroup.MediaGroupId
|
MediaGroupId = fileGroup.MediaGroupId
|
||||||
}, cancellationToken: cancellationToken);
|
}, cancellationToken: cancellationToken);
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ public class GetAllLanguageQueryHandler(IGenericDapper<LanguageDTO> languageDapp
|
|||||||
public async Task<GetAllLanguageDTO> Handle(GetAllLanguageQuery request, CancellationToken cancellationToken)
|
public async Task<GetAllLanguageDTO> Handle(GetAllLanguageQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = new GetAllLanguageDTO();
|
var result = new GetAllLanguageDTO();
|
||||||
var sql = $"select * from Learning.Languages";
|
var sql = $"select * from Learning.Languages " +
|
||||||
var language = await languageDapper.GetAllAsync(sql);
|
$"where @Search is null or {nameof(LanguageDTO.Title)} like N'%@Search%' " +
|
||||||
|
$"order by createOn OFFSET {request.Pagination.Skip()} ROWS FETCH NEXT {request.Pagination.Take()} ROWS ONLY;";
|
||||||
|
|
||||||
|
var language = await languageDapper.GetAllAsync(sql, new { request.Pagination.Search });
|
||||||
result.Languages.AddRange(language);
|
result.Languages.AddRange(language);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ public class Language : Entity<LanguageId>, IAggregateRoot
|
|||||||
public Course UpdateCourse(Course course)
|
public Course UpdateCourse(Course course)
|
||||||
{
|
{
|
||||||
var _course = _courses.FirstOrDefault(x => x.Id == course.Id) ?? throw new CourseNotFoundException(Title);
|
var _course = _courses.FirstOrDefault(x => x.Id == course.Id) ?? throw new CourseNotFoundException(Title);
|
||||||
throw new Exception();
|
if(course.Image != null)
|
||||||
|
_course.SetImage(course.Image);
|
||||||
|
_course.SetTitle(course.Title);
|
||||||
|
|
||||||
|
if(_course.Order != course.Order)
|
||||||
|
{
|
||||||
|
var orderCourses = _courses.Where(x => x.Id != course.Id)
|
||||||
|
.OrderBy(x => x.Order)
|
||||||
|
.ToList();
|
||||||
|
_course.SetOrder(_course.Order);
|
||||||
|
orderCourses.Insert(course.Order, _course);
|
||||||
|
}
|
||||||
|
return _course;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using VizhTalk.Learning.Domain.Entities;
|
||||||
|
|
||||||
|
namespace VizhTalk.Learning.Infrastructure.EF.Configurations
|
||||||
|
{
|
||||||
|
internal class CourseConfiguration : IEntityTypeConfiguration<Course>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Course> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(name: nameof(Course), Schema.Learning);
|
||||||
|
builder.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
builder.Property(x => x.Id)
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasConversion(x => x.Value, x => new Domain.TypeIds.CourseId(x));
|
||||||
|
|
||||||
|
builder.Property(x => x.Title)
|
||||||
|
.HasConversion(x => x.Value, x => new(x));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+245
@@ -0,0 +1,245 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using VizhTalk.Learning.Infrastructure.EF;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(LearningDbContext))]
|
||||||
|
[Migration("20250907192005_Course")]
|
||||||
|
partial class Course
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("Learning")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.19")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateOn")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ImageId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<short?>("LanguageId")
|
||||||
|
.HasColumnType("smallint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("Order")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ImageId");
|
||||||
|
|
||||||
|
b.HasIndex("LanguageId");
|
||||||
|
|
||||||
|
b.ToTable("Courses", "Learning");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateOn")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsSecure")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(150)
|
||||||
|
.HasColumnType("nvarchar(150)")
|
||||||
|
.HasColumnName("Key");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<long>("MediaGroupId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)")
|
||||||
|
.HasColumnName("Title");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("FileGroups", "Attachment");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||||
|
{
|
||||||
|
b.Property<short>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("smallint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateOn")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("IconId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(60)
|
||||||
|
.HasColumnType("nvarchar(60)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IconId");
|
||||||
|
|
||||||
|
b.ToTable("Languages", "Learning");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("ContentType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateOn")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(150)
|
||||||
|
.HasColumnType("nvarchar(150)");
|
||||||
|
|
||||||
|
b.Property<int>("Size")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Medias", "Learning");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Image")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ImageId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Language", null)
|
||||||
|
.WithMany("Courses")
|
||||||
|
.HasForeignKey("LanguageId");
|
||||||
|
|
||||||
|
b.Navigation("Image");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("IconId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Icon");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||||
|
{
|
||||||
|
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<Guid>("MediaId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b1.Property<string>("EntityId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)")
|
||||||
|
.HasColumnName("EntityId");
|
||||||
|
|
||||||
|
b1.Property<int>("Type")
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasColumnName("EntityType");
|
||||||
|
|
||||||
|
b1.HasKey("MediaId");
|
||||||
|
|
||||||
|
b1.ToTable("Medias", "Learning");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("MediaId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("EntityType")
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Courses");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Course : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Courses",
|
||||||
|
schema: "Learning",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
ImageId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||||
|
Order = table.Column<int>(type: "int", nullable: false),
|
||||||
|
LanguageId = table.Column<short>(type: "smallint", nullable: true),
|
||||||
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Courses", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Courses_Languages_LanguageId",
|
||||||
|
column: x => x.LanguageId,
|
||||||
|
principalSchema: "Learning",
|
||||||
|
principalTable: "Languages",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Courses_Medias_ImageId",
|
||||||
|
column: x => x.ImageId,
|
||||||
|
principalSchema: "Learning",
|
||||||
|
principalTable: "Medias",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Courses_ImageId",
|
||||||
|
schema: "Learning",
|
||||||
|
table: "Courses",
|
||||||
|
column: "ImageId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Courses_LanguageId",
|
||||||
|
schema: "Learning",
|
||||||
|
table: "Courses",
|
||||||
|
column: "LanguageId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Courses",
|
||||||
|
schema: "Learning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,48 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
|||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreateOn")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ImageId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<short?>("LanguageId")
|
||||||
|
.HasColumnType("smallint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastUpdate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("Order")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ImageId");
|
||||||
|
|
||||||
|
b.HasIndex("LanguageId");
|
||||||
|
|
||||||
|
b.ToTable("Courses", "Learning");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
@@ -134,6 +176,21 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
|||||||
b.ToTable("Medias", "Learning");
|
b.ToTable("Medias", "Learning");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Image")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ImageId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Language", null)
|
||||||
|
.WithMany("Courses")
|
||||||
|
.HasForeignKey("LanguageId");
|
||||||
|
|
||||||
|
b.Navigation("Image");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
|
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
|
||||||
@@ -174,6 +231,11 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
|||||||
b.Navigation("EntityType")
|
b.Navigation("EntityType")
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Courses");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VizhTalk.Grpc.Learning
|
||||||
|
{
|
||||||
|
public sealed partial class Pagination
|
||||||
|
{
|
||||||
|
public int Skip()
|
||||||
|
=> PageNumber * (PageSize == 0 ? 10 : PageSize);
|
||||||
|
public int Take()
|
||||||
|
=> PageNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
syntax="proto3";
|
||||||
|
|
||||||
|
option csharp_namespace="VizhTalk.Grpc.Learning.Course";
|
||||||
|
|
||||||
|
package greet;
|
||||||
|
import "Proto/Shared.proto";
|
||||||
|
|
||||||
|
|
||||||
|
message CreateCourseCommand{
|
||||||
|
string title = 1;
|
||||||
|
bytes icon = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UpdateCourseCommand{
|
||||||
|
Id Id = 1;
|
||||||
|
string title = 2;
|
||||||
|
optional bytes icon = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
syntax="proto3";
|
||||||
|
|
||||||
|
option csharp_namespace="VizhTalk.Grpc.Learning.Course";
|
||||||
|
|
||||||
|
package greet;
|
||||||
|
import "Proto/Shared.proto";
|
||||||
|
|
||||||
|
message CourseDTO {
|
||||||
|
Id Id = 1;
|
||||||
|
string title = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GetAllCourseDTO{
|
||||||
|
repeated CourseDTO Courses =1;
|
||||||
|
int32 totalData = 2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
syntax="proto3";
|
||||||
|
|
||||||
|
option csharp_namespace="VizhTalk.Grpc.Learning.Course";
|
||||||
|
|
||||||
|
package greet;
|
||||||
|
|
||||||
|
import "Proto/Shared.proto";
|
||||||
|
|
||||||
|
message GetAllCourseQuery{
|
||||||
|
Pagination pagination = 1;
|
||||||
|
}
|
||||||
|
message GetCourseByTitleQuery{
|
||||||
|
string title = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetCourseByIdQuery{
|
||||||
|
Id id=1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
syntax="proto3";
|
||||||
|
|
||||||
|
option csharp_namespace="VizhTalk.Grpc.Learning.Course";
|
||||||
|
|
||||||
|
package greet;
|
||||||
|
|
||||||
|
import "Proto/Courses/DTOs.proto";
|
||||||
|
import "Proto/Courses/Queries.proto";
|
||||||
|
import "Proto/Courses/Commands.proto";
|
||||||
|
import "Proto/Shared.proto";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
service CourseGrpc {
|
||||||
|
rpc Create (CreateCourseCommand) returns (CourseDTO);
|
||||||
|
rpc Update (UpdateCourseCommand) returns (CourseDTO);
|
||||||
|
rpc GetAll (GetAllCourseQuery) returns (GetAllCourseDTO);
|
||||||
|
rpc GetByTitle (GetCourseByTitleQuery) returns (CourseDTO);
|
||||||
|
rpc GetById (GetCourseByIdQuery) returns (CourseDTO);
|
||||||
|
}
|
||||||
@@ -8,11 +8,11 @@ import "Proto/Shared.proto";
|
|||||||
|
|
||||||
message CreateLanguageCommand{
|
message CreateLanguageCommand{
|
||||||
string title = 1;
|
string title = 1;
|
||||||
bytes icon = 2;
|
UploadFile icon = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateLanguageCommand{
|
message UpdateLanguageCommand{
|
||||||
Id Id = 1;
|
Id Id = 1;
|
||||||
string title = 2;
|
string title = 2;
|
||||||
optional bytes icon = 3;
|
optional UploadFile icon = 3;
|
||||||
}
|
}
|
||||||
@@ -13,4 +13,5 @@ message LanguageDTO {
|
|||||||
|
|
||||||
message GetAllLanguageDTO{
|
message GetAllLanguageDTO{
|
||||||
repeated LanguageDTO languages =1;
|
repeated LanguageDTO languages =1;
|
||||||
|
int32 totalData = 2;
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ package greet;
|
|||||||
import "Proto/Shared.proto";
|
import "Proto/Shared.proto";
|
||||||
|
|
||||||
message GetAllLanguageQuery{
|
message GetAllLanguageQuery{
|
||||||
|
Pagination pagination = 1;
|
||||||
}
|
}
|
||||||
message GetLanguageByTitleQuery{
|
message GetLanguageByTitleQuery{
|
||||||
string title = 1;
|
string title = 1;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
syntax="proto3";
|
syntax="proto3";
|
||||||
|
|
||||||
option csharp_namespace="VizhTalk.Grpc.Learning";
|
option csharp_namespace="VizhTalk.Grpc.Learning";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
|
||||||
package greet;
|
package greet;
|
||||||
|
|
||||||
@@ -10,3 +11,13 @@ message Empty{
|
|||||||
message Id{
|
message Id{
|
||||||
string value = 1;
|
string value = 1;
|
||||||
}
|
}
|
||||||
|
message Pagination{
|
||||||
|
int32 pageSize = 1;
|
||||||
|
int32 pageNumber = 2;
|
||||||
|
google.protobuf.StringValue search = 3;
|
||||||
|
}
|
||||||
|
message UploadFile{
|
||||||
|
bytes file=1;
|
||||||
|
string name = 2;
|
||||||
|
string contentType = 3;
|
||||||
|
}
|
||||||
@@ -5,6 +5,13 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Proto\Courses\Commands.proto" />
|
||||||
|
<None Remove="Proto\Courses\DTOs.proto" />
|
||||||
|
<None Remove="Proto\Courses\Queries.proto" />
|
||||||
|
<None Remove="Proto\Courses\Services.proto" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.32.0" />
|
<PackageReference Include="Google.Protobuf" Version="3.32.0" />
|
||||||
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
|
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
|
||||||
@@ -14,6 +21,10 @@
|
|||||||
<ProjectReference Include="..\VizhTalk.BuildingBlocks.Domain\VizhTalk.BuildingBlocks.Domain.csproj" />
|
<ProjectReference Include="..\VizhTalk.BuildingBlocks.Domain\VizhTalk.BuildingBlocks.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Protobuf Include="Proto\Courses\Commands.proto" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Proto\Courses\DTOs.proto" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Proto\Courses\Queries.proto" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Proto\Courses\Services.proto" GrpcServices="Both" />
|
||||||
<Protobuf Include="Proto\Languages\Services.proto" GrpcServices="Both" />
|
<Protobuf Include="Proto\Languages\Services.proto" GrpcServices="Both" />
|
||||||
<Protobuf Include="Proto\Languages\DTOs.proto" GrpcServices="Both" />
|
<Protobuf Include="Proto\Languages\DTOs.proto" GrpcServices="Both" />
|
||||||
<Protobuf Include="Proto\Languages\Queries.proto" GrpcServices="Both" />
|
<Protobuf Include="Proto\Languages\Queries.proto" GrpcServices="Both" />
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VizhTalk.Gateway.Web.BFF",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vizhtalk.CDN.Presentation", "Vizhtalk.CDN.Presentation\Vizhtalk.CDN.Presentation.csproj", "{F6FDEF63-77D7-47AC-A5F5-2EB59D230158}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vizhtalk.CDN.Presentation", "Vizhtalk.CDN.Presentation\Vizhtalk.CDN.Presentation.csproj", "{F6FDEF63-77D7-47AC-A5F5-2EB59D230158}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VizhTalk.Grpc.CDN", "VizhTalk.Grpc.CDN\VizhTalk.Grpc.CDN.csproj", "{312291A0-6180-4F89-97C5-8D327BE5DE09}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VizhTalk.Grpc.CDN", "VizhTalk.Grpc.CDN\VizhTalk.Grpc.CDN.csproj", "{312291A0-6180-4F89-97C5-8D327BE5DE09}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
Reference in New Issue
Block a user