From 819d974f99ed431202164bce72f20f6769fbe286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Thu, 16 Nov 2023 20:10:09 +0300 Subject: [PATCH] =?UTF-8?q?=D1=88=D0=B5=D0=B4=D0=B5=D0=B2=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B8=D1=88=D0=B0=D1=80=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/WeatherForecastController.cs | 20 +- Justice/Interactions/CitiesInteractions.cs | 6 +- ...20231116170623_Migrate16112006.Designer.cs | 319 ++++++++++++++++++ Migrations/20231116170623_Migrate16112006.cs | 31 ++ Migrations/AppDbContextModelSnapshot.cs | 3 + 5 files changed, 374 insertions(+), 5 deletions(-) create mode 100644 Migrations/20231116170623_Migrate16112006.Designer.cs create mode 100644 Migrations/20231116170623_Migrate16112006.cs diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs index 325f976..190b366 100644 --- a/Controllers/WeatherForecastController.cs +++ b/Controllers/WeatherForecastController.cs @@ -20,6 +20,22 @@ namespace DiscordApp.Controllers Startup.appDbContext.Redirects.Update(data); Startup.appDbContext.SaveChanges(); return Redirect(data.url); + }else if (data.RedirectType == Types.RedirectType.Redirected) + { + JsonNode jsonBodyContent = JsonNode.Parse(bodyContent); + string[] paymentData = jsonBodyContent["data"].ToString().Split(";"); + var channelId = paymentData[1].Split(":")[1]; + var channel = Startup.discordSocketClient.GetChannel(ulong.Parse(channelId)) as ITextChannel; + var message = channel.GetMessagesAsync().LastAsync().Result.Last() as IUserMessage; + message.ModifyAsync(func => + { + func.Content = "Успешно оплачено!"; + func.Components = new ComponentBuilder() + .WithButton("Создание заявки", "addBaseOnMapModalSender") + .Build(); + }).RunSynchronously(); + + return Redirect(message.GetJumpUrl()); } else { @@ -27,7 +43,7 @@ namespace DiscordApp.Controllers } } [HttpPost("/redirects/{uri}")] - public IActionResult Post(string uri, [FromBody] string bodyContent) + public IActionResult Post(string uri, [FromBody] string bodyContent) { JsonNode jsonBodyContent = JsonNode.Parse(bodyContent); string[] paymentData = jsonBodyContent["data"].ToString().Split(";"); @@ -42,7 +58,7 @@ namespace DiscordApp.Controllers .Build(); }).RunSynchronously(); - return Redirect(message.GetJumpUrl()); + return Ok(message.GetJumpUrl()); } } diff --git a/Justice/Interactions/CitiesInteractions.cs b/Justice/Interactions/CitiesInteractions.cs index 6b44505..bc587ae 100644 --- a/Justice/Interactions/CitiesInteractions.cs +++ b/Justice/Interactions/CitiesInteractions.cs @@ -11,16 +11,16 @@ namespace DiscordApp.Justice.Interactions [ComponentInteraction("addBaseOnMap")] public async Task addBaseInteraction() { + var redirectUri = Guid.NewGuid().ToString(); await DeferAsync(true); var paymentData = new spworlds.Types.PaymentData() { Amount = 16, Data = $"user:{Context.User.Id};channel:{Context.Channel.Id};", - RedirectUrl = Context.Interaction.GetOriginalResponseAsync().Result.GetJumpUrl(), - WebHookUrl = "https://discord.yawaflua.ru/addOnMap/" + RedirectUrl = $"https://discord.yawaflua.ru/redirects/{redirectUri}", + WebHookUrl = $"https://discord.yawaflua.ru/redirects/{redirectUri}" }; var uri = await Startup.sp.InitPayment(paymentData); - var redirectUri = Guid.NewGuid().ToString(); var redirectTable = new Redirects() { Id = redirectUri , url = uri}; Startup.appDbContext.Redirects.Add(redirectTable); Startup.appDbContext.SaveChanges(); diff --git a/Migrations/20231116170623_Migrate16112006.Designer.cs b/Migrations/20231116170623_Migrate16112006.Designer.cs new file mode 100644 index 0000000..5c1eecb --- /dev/null +++ b/Migrations/20231116170623_Migrate16112006.Designer.cs @@ -0,0 +1,319 @@ +п»ї// +using System; +using DiscordApp.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DiscordApp.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20231116170623_Migrate16112006")] + partial class Migrate16112006 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DiscordApp.Database.Tables.ArtsPatents", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Number") + .IsRequired() + .HasColumnType("integer[]"); + + b.Property("Size") + .IsRequired() + .HasColumnType("text"); + + b.Property("isAllowedToResell") + .HasColumnType("boolean"); + + b.Property("passportId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("passportId"); + + b.ToTable("ArtsPatent", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Autobranches", b => + { + b.Property("ChannelId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)"); + + b.Property("BranchName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ChannelId"); + + b.ToTable("Autobranches", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Bizness", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApplicantId") + .HasColumnType("integer"); + + b.Property("BiznessEmployes") + .IsRequired() + .HasColumnType("integer[]"); + + b.Property("BiznessName") + .IsRequired() + .HasColumnType("text"); + + b.Property("BiznessType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardNumber") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ApplicantId"); + + b.ToTable("Bizness", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.BooksPatents", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .IsRequired() + .HasColumnType("text"); + + b.Property("Janre") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("isAllowedToResell") + .HasColumnType("boolean"); + + b.Property("passportId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("passportId"); + + b.ToTable("BooksPatent", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Certificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Employee") + .IsRequired() + .HasColumnType("text"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text"); + + b.Property("passportId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("passportId"); + + b.ToTable("Certificate", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("bigint"); + + b.Property("Employee") + .HasColumnType("numeric(20,0)"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("RpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Support") + .HasColumnType("integer"); + + b.Property("birthDate") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Passport", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Redirects", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("RedirectType") + .HasColumnType("integer"); + + b.Property("url") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Redirects", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Reports", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Employee") + .IsRequired() + .HasColumnType("text"); + + b.Property("type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Reports", "public"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.ArtsPatents", b => + { + b.HasOne("DiscordApp.Database.Tables.Passport", "passport") + .WithMany() + .HasForeignKey("passportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("passport"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Bizness", b => + { + b.HasOne("DiscordApp.Database.Tables.Passport", "Applicant") + .WithMany() + .HasForeignKey("ApplicantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Applicant"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.BooksPatents", b => + { + b.HasOne("DiscordApp.Database.Tables.Passport", "passport") + .WithMany() + .HasForeignKey("passportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("passport"); + }); + + modelBuilder.Entity("DiscordApp.Database.Tables.Certificate", b => + { + b.HasOne("DiscordApp.Database.Tables.Passport", "passport") + .WithMany() + .HasForeignKey("passportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("passport"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20231116170623_Migrate16112006.cs b/Migrations/20231116170623_Migrate16112006.cs new file mode 100644 index 0000000..59ac53c --- /dev/null +++ b/Migrations/20231116170623_Migrate16112006.cs @@ -0,0 +1,31 @@ +п»їusing Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiscordApp.Migrations +{ + /// + public partial class Migrate16112006 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "RedirectType", + schema: "public", + table: "Redirects", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "RedirectType", + schema: "public", + table: "Redirects"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs index 59217a5..3066422 100644 --- a/Migrations/AppDbContextModelSnapshot.cs +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -235,6 +235,9 @@ namespace DiscordApp.Migrations b.Property("Id") .HasColumnType("text"); + b.Property("RedirectType") + .HasColumnType("integer"); + b.Property("url") .IsRequired() .HasColumnType("text");