From e0115e0e07cc7d4909aa869552901f893b477e3a Mon Sep 17 00:00:00 2001 From: ceruIean Date: Tue, 22 Feb 2022 17:14:10 +0800 Subject: [PATCH] removed migration ,altered Guid to int --- 2021-backend.csproj | 24 ++- Controllers/SubmissionController.cs | 20 +- Data/BackendContext.cs | 10 +- ....cs => 20220222090619_initial.Designer.cs} | 171 +++++++++-------- ...5_Initial.cs => 20220222090619_initial.cs} | 73 ++++---- Migrations/BackendContextModelSnapshot.cs | 177 ++++++++++-------- Models/Comment.cs | 23 +-- Models/SMS.cs | 22 ++- Models/Session.cs | 13 +- Models/Student.cs | 38 ++-- Models/Submission.cs | 33 ++-- Models/User.cs | 20 +- Pages/Account/Login.cshtml.cs | 2 +- Pages/Message/Index.cshtml.cs | 24 +-- Pages/Sessions/Create.cshtml.cs | 12 +- Pages/Sessions/Delete.cshtml | 2 +- Pages/Sessions/Delete.cshtml.cs | 14 +- Pages/Sessions/Details.cshtml | 2 +- Pages/Sessions/Details.cshtml.cs | 4 +- Pages/Sessions/Edit.cshtml | 18 +- Pages/Sessions/Edit.cshtml.cs | 66 +++---- Pages/Sessions/Index.cshtml | 6 +- Pages/Sessions/Index.cshtml.cs | 38 ++-- Pages/Students/Delete.cshtml | 2 +- Pages/Students/Delete.cshtml.cs | 6 +- Pages/Students/Details.cshtml | 18 +- Pages/Students/Details.cshtml.cs | 80 ++++---- Pages/Students/Edit.cshtml | 2 +- Pages/Students/Edit.cshtml.cs | 10 +- Pages/Students/Index.cshtml | 10 +- Pages/Submissions/Create.cshtml.cs | 4 +- Pages/Submissions/Delete.cshtml | 4 +- Pages/Submissions/Delete.cshtml.cs | 8 +- Pages/Submissions/Details.cshtml | 2 +- Pages/Submissions/Details.cshtml.cs | 4 +- Pages/Submissions/Edit.cshtml | 2 +- Pages/Submissions/Edit.cshtml.cs | 10 +- Pages/Submissions/Index.cshtml | 6 +- Pages/Users/Delete.cshtml | 2 +- Pages/Users/Delete.cshtml.cs | 8 +- Pages/Users/Details.cshtml | 2 +- Pages/Users/Details.cshtml.cs | 4 +- Pages/Users/Edit.cshtml | 2 +- Pages/Users/Edit.cshtml.cs | 16 +- Pages/Users/Index.cshtml | 6 +- Program.cs | 12 +- Utils/Arranger.cs | 22 +-- Utils/TencentSMS.cs | 10 +- 48 files changed, 559 insertions(+), 505 deletions(-) rename Migrations/{20211018220015_Initial.Designer.cs => 20220222090619_initial.Designer.cs} (62%) rename Migrations/{20211018220015_Initial.cs => 20220222090619_initial.cs} (63%) diff --git a/2021-backend.csproj b/2021-backend.csproj index a2f8c70..9194aa0 100644 --- a/2021-backend.csproj +++ b/2021-backend.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 _2021_backend 2023ab1c-9547-4989-a343-cd3428e085fe _2021_backend.Program @@ -19,21 +19,25 @@ - + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - - + + + + + + diff --git a/Controllers/SubmissionController.cs b/Controllers/SubmissionController.cs index 5402683..b5a24a5 100644 --- a/Controllers/SubmissionController.cs +++ b/Controllers/SubmissionController.cs @@ -33,7 +33,7 @@ namespace _2021_backend.Controllers { if(aDto.Timelist != null)if (aDto.Timelist.Any(it => it.Day.Day == tm.Day.Day && it.BeginTime.TimeOfDay == tm.BeginTime.TimeOfDay)) { - sub.Timelist.Add(tm.Guid); + sub.Timelist.Add(tm.Id); } } var q = Context.Students.Where(stu => (stu.Name == aDto.Name || stu.Stuid == aDto.Stuid)); @@ -49,7 +49,7 @@ namespace _2021_backend.Controllers stu = q.FirstOrDefault(); stu.Update(sub); } - sub.Host = stu.Guid; + sub.Host = stu.Id; Context.Submissions.Add(sub); Context.SaveChanges(); await TencentSMS.Send(Context, SMSType.Signed, stu, _2021_backend.Models.User.Bot.stuID); @@ -96,7 +96,7 @@ namespace _2021_backend.Controllers Student stu = Context.Students.FirstOrDefault(r => r.Stuid == stuid); if (stu == null) { - return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_GUID")); + return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_int")); } SessionDto time; try @@ -108,8 +108,8 @@ namespace _2021_backend.Controllers Console.WriteLine(ex); return StatusCode(400, ApiResponse.Error("MALFORMED_DATA")); }; - //get the selected session guids; - Guid targetSession = Guid.Empty; + //get the selected session ints; + int targetSession = 0; var sessions = Context.Sessions.ToList(); var s = sessions.Find((Session s) => { @@ -120,15 +120,15 @@ namespace _2021_backend.Controllers if (Context.Sessions.Find(stu.InterviewTime) != null) { var olds = Context.Sessions.Find(stu.InterviewTime); - olds.Students.Remove(stu.Guid); + olds.Students.Remove(stu.Id); Context.SaveChanges(); overwritten = true; } - targetSession = s.Guid; - s.Students.Add(stu.Guid); - stu.Timelist = new List { targetSession}; + targetSession = s.Id; + s.Students.Add(stu.Id); + stu.Timelist = new List { targetSession}; stu.Status = status.已选时间; - stu.InterviewTime = s.Guid; + stu.InterviewTime = s.Id; await TencentSMS.Send(Context, SMSType.TimeSet, stu, "smsbot"); Context.SaveChanges(); if (overwritten) return Ok(ApiResponse.Success("overwritten")); diff --git a/Data/BackendContext.cs b/Data/BackendContext.cs index fa8127f..f58711b 100644 --- a/Data/BackendContext.cs +++ b/Data/BackendContext.cs @@ -19,15 +19,15 @@ namespace _2021_backend.Data protected override void OnModelCreating(ModelBuilder mb) { mb.Entity() - .HasKey(r => r.Guid); + .HasKey(r => r.Id); mb.Entity() - .HasKey(u => u.Guid); + .HasKey(u => u.Id); mb.Entity() - .HasKey(u => u.Guid); + .HasKey(u => u.Id); mb.Entity() - .HasKey(u => u.Guid); + .HasKey(u => u.Id); mb.Entity() - .HasKey(u => u.Guid); + .HasKey(u => u.Id); } } } diff --git a/Migrations/20211018220015_Initial.Designer.cs b/Migrations/20220222090619_initial.Designer.cs similarity index 62% rename from Migrations/20211018220015_Initial.Designer.cs rename to Migrations/20220222090619_initial.Designer.cs index 325da57..d981e82 100644 --- a/Migrations/20211018220015_Initial.Designer.cs +++ b/Migrations/20220222090619_initial.Designer.cs @@ -8,58 +8,100 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using _2021_backend.Data; +#nullable disable + namespace _2021_backend.Migrations { [DbContext(typeof(BackendContext))] - [Migration("20211018220015_Initial")] - partial class Initial + [Migration("20220222090619_initial")] + partial class initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.9") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + .HasAnnotation("ProductVersion", "6.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("_2021_backend.Models.Comment", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AddTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Content") .IsRequired() .HasColumnType("text"); - b.Property("Operator") - .HasColumnType("uuid"); + b.Property("Operator") + .HasColumnType("integer"); - b.Property("Student") - .HasColumnType("uuid"); + b.Property("Student") + .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); b.ToTable("Comments"); }); + modelBuilder.Entity("_2021_backend.Models.Session", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property>("Chiefs") + .HasColumnType("integer[]"); + + b.Property("Day") + .HasColumnType("timestamp with time zone"); + + b.Property("Place") + .IsRequired() + .HasColumnType("text"); + + b.Property("SendSMS") + .HasColumnType("boolean"); + + b.Property>("Students") + .HasColumnType("integer[]"); + + b.HasKey("Id"); + + b.ToTable("Sessions"); + }); + modelBuilder.Entity("_2021_backend.Models.SMS", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property>("Data") .HasColumnType("text[]"); - b.Property("Host") - .HasColumnType("uuid"); + b.Property("Host") + .HasColumnType("integer"); b.Property("SendTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Sender") .HasColumnType("text"); @@ -70,52 +112,21 @@ namespace _2021_backend.Migrations b.Property("Type") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); b.ToTable("SMS"); }); - modelBuilder.Entity("_2021_backend.Models.Session", b => - { - b.Property("Guid") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BeginTime") - .HasColumnType("timestamp without time zone"); - - b.Property("Capacity") - .HasColumnType("integer"); - - b.Property>("Chiefs") - .HasColumnType("uuid[]"); - - b.Property("Day") - .HasColumnType("timestamp without time zone"); - - b.Property("Place") - .IsRequired() - .HasColumnType("text"); - - b.Property("SendSMS") - .HasColumnType("boolean"); - - b.Property>("Students") - .HasColumnType("uuid[]"); - - b.HasKey("Guid"); - - b.ToTable("Sessions"); - }); - modelBuilder.Entity("_2021_backend.Models.Student", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); - b.Property>("Comments") - .HasColumnType("uuid[]"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Comments") + .HasColumnType("integer[]"); b.Property("Email") .HasColumnType("text"); @@ -126,23 +137,23 @@ namespace _2021_backend.Migrations b.Property("Grade") .HasColumnType("integer"); - b.Property("InterviewTime") - .HasColumnType("uuid"); + b.Property("InterviewTime") + .HasColumnType("integer"); b.Property("LastSubmission") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Major") .HasColumnType("text"); - b.Property>("Messages") - .HasColumnType("uuid[]"); + b.Property>("Messages") + .HasColumnType("integer[]"); b.Property("Name") .HasColumnType("text"); b.Property("RegisterTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Score") .HasColumnType("integer"); @@ -156,28 +167,30 @@ namespace _2021_backend.Migrations b.Property("Stuid") .HasColumnType("text"); - b.Property>("Submissions") - .HasColumnType("uuid[]"); + b.Property>("Submissions") + .HasColumnType("integer[]"); b.Property("Tel") .HasColumnType("text"); - b.Property>("Timelist") - .HasColumnType("uuid[]"); + b.Property>("Timelist") + .HasColumnType("integer[]"); b.Property("Yard") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); b.ToTable("Students"); }); modelBuilder.Entity("_2021_backend.Models.Submission", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Address") .HasColumnType("text"); @@ -191,8 +204,8 @@ namespace _2021_backend.Migrations b.Property("Grade") .HasColumnType("integer"); - b.Property("Host") - .HasColumnType("uuid"); + b.Property("Host") + .HasColumnType("integer"); b.Property("Major") .HasColumnType("text"); @@ -207,27 +220,29 @@ namespace _2021_backend.Migrations .HasColumnType("text"); b.Property("SubmitTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Tel") .HasColumnType("text"); - b.Property>("Timelist") - .HasColumnType("uuid[]"); + b.Property>("Timelist") + .HasColumnType("integer[]"); b.Property("Yard") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); b.ToTable("Submissions"); }); modelBuilder.Entity("_2021_backend.Models.User", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .HasColumnType("text"); @@ -241,7 +256,7 @@ namespace _2021_backend.Migrations b.Property("stuID") .HasColumnType("text"); - b.HasKey("Guid"); + b.HasKey("Id"); b.ToTable("Users"); }); diff --git a/Migrations/20211018220015_Initial.cs b/Migrations/20220222090619_initial.cs similarity index 63% rename from Migrations/20211018220015_Initial.cs rename to Migrations/20220222090619_initial.cs index a21aa59..f14fefb 100644 --- a/Migrations/20211018220015_Initial.cs +++ b/Migrations/20220222090619_initial.cs @@ -1,10 +1,13 @@ using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable namespace _2021_backend.Migrations { - public partial class Initial : Migration + public partial class initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -12,57 +15,61 @@ namespace _2021_backend.Migrations name: "Comments", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), - Operator = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Operator = table.Column(type: "integer", nullable: false), Content = table.Column(type: "text", nullable: false), - AddTime = table.Column(type: "timestamp without time zone", nullable: false), - Student = table.Column(type: "uuid", nullable: false) + AddTime = table.Column(type: "timestamp with time zone", nullable: false), + Student = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Comments", x => x.Guid); + table.PrimaryKey("PK_Comments", x => x.Id); }); migrationBuilder.CreateTable( name: "Sessions", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), - Day = table.Column(type: "timestamp without time zone", nullable: false), - BeginTime = table.Column(type: "timestamp without time zone", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Day = table.Column(type: "timestamp with time zone", nullable: false), + BeginTime = table.Column(type: "timestamp with time zone", nullable: false), Place = table.Column(type: "text", nullable: false), - Chiefs = table.Column>(type: "uuid[]", nullable: true), + Chiefs = table.Column>(type: "integer[]", nullable: true), Capacity = table.Column(type: "integer", nullable: false), SendSMS = table.Column(type: "boolean", nullable: false), - Students = table.Column>(type: "uuid[]", nullable: true) + Students = table.Column>(type: "integer[]", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Sessions", x => x.Guid); + table.PrimaryKey("PK_Sessions", x => x.Id); }); migrationBuilder.CreateTable( name: "SMS", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), - Host = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Host = table.Column(type: "integer", nullable: false), Tel = table.Column(type: "text", nullable: true), Data = table.Column>(type: "text[]", nullable: true), Type = table.Column(type: "integer", nullable: false), Sender = table.Column(type: "text", nullable: true), - SendTime = table.Column(type: "timestamp without time zone", nullable: false) + SendTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_SMS", x => x.Guid); + table.PrimaryKey("PK_SMS", x => x.Id); }); migrationBuilder.CreateTable( name: "Students", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: true), Stuid = table.Column(type: "text", nullable: true), Sex = table.Column(type: "integer", nullable: false), @@ -72,27 +79,28 @@ namespace _2021_backend.Migrations Email = table.Column(type: "text", nullable: true), Tel = table.Column(type: "text", nullable: true), Exp = table.Column(type: "integer", nullable: false), - InterviewTime = table.Column(type: "uuid", nullable: false), - Submissions = table.Column>(type: "uuid[]", nullable: true), - Messages = table.Column>(type: "uuid[]", nullable: true), - Timelist = table.Column>(type: "uuid[]", nullable: true), - Comments = table.Column>(type: "uuid[]", nullable: true), + InterviewTime = table.Column(type: "integer", nullable: false), + Submissions = table.Column>(type: "integer[]", nullable: true), + Messages = table.Column>(type: "integer[]", nullable: true), + Timelist = table.Column>(type: "integer[]", nullable: true), + Comments = table.Column>(type: "integer[]", nullable: true), Score = table.Column(type: "integer", nullable: false), Status = table.Column(type: "integer", nullable: false), - LastSubmission = table.Column(type: "timestamp without time zone", nullable: false), - RegisterTime = table.Column(type: "timestamp without time zone", nullable: false) + LastSubmission = table.Column(type: "timestamp with time zone", nullable: false), + RegisterTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Students", x => x.Guid); + table.PrimaryKey("PK_Students", x => x.Id); }); migrationBuilder.CreateTable( name: "Submissions", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), - Host = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Host = table.Column(type: "integer", nullable: false), Name = table.Column(type: "text", nullable: true), Stuid = table.Column(type: "text", nullable: true), Sex = table.Column(type: "integer", nullable: false), @@ -102,20 +110,21 @@ namespace _2021_backend.Migrations Email = table.Column(type: "text", nullable: true), Tel = table.Column(type: "text", nullable: true), Exp = table.Column(type: "integer", nullable: false), - Timelist = table.Column>(type: "uuid[]", nullable: true), + Timelist = table.Column>(type: "integer[]", nullable: true), Address = table.Column(type: "text", nullable: true), - SubmitTime = table.Column(type: "timestamp without time zone", nullable: false) + SubmitTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Submissions", x => x.Guid); + table.PrimaryKey("PK_Submissions", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { - Guid = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), stuID = table.Column(type: "text", nullable: true), Name = table.Column(type: "text", nullable: true), Secret = table.Column(type: "text", nullable: true), @@ -123,7 +132,7 @@ namespace _2021_backend.Migrations }, constraints: table => { - table.PrimaryKey("PK_Users", x => x.Guid); + table.PrimaryKey("PK_Users", x => x.Id); }); } diff --git a/Migrations/BackendContextModelSnapshot.cs b/Migrations/BackendContextModelSnapshot.cs index 9d6cb10..1bef7f3 100644 --- a/Migrations/BackendContextModelSnapshot.cs +++ b/Migrations/BackendContextModelSnapshot.cs @@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using _2021_backend.Data; +#nullable disable + namespace _2021_backend.Migrations { [DbContext(typeof(BackendContext))] @@ -16,48 +18,88 @@ namespace _2021_backend.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.9") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + .HasAnnotation("ProductVersion", "6.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("_2021_backend.Models.Comment", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AddTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Content") .IsRequired() .HasColumnType("text"); - b.Property("Operator") - .HasColumnType("uuid"); + b.Property("Operator") + .HasColumnType("integer"); - b.Property("Student") - .HasColumnType("uuid"); + b.Property("Student") + .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); - b.ToTable("Comments"); + b.ToTable("Comments", (string)null); + }); + + modelBuilder.Entity("_2021_backend.Models.Session", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property>("Chiefs") + .HasColumnType("integer[]"); + + b.Property("Day") + .HasColumnType("timestamp with time zone"); + + b.Property("Place") + .IsRequired() + .HasColumnType("text"); + + b.Property("SendSMS") + .HasColumnType("boolean"); + + b.Property>("Students") + .HasColumnType("integer[]"); + + b.HasKey("Id"); + + b.ToTable("Sessions", (string)null); }); modelBuilder.Entity("_2021_backend.Models.SMS", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property>("Data") .HasColumnType("text[]"); - b.Property("Host") - .HasColumnType("uuid"); + b.Property("Host") + .HasColumnType("integer"); b.Property("SendTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Sender") .HasColumnType("text"); @@ -68,52 +110,21 @@ namespace _2021_backend.Migrations b.Property("Type") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); - b.ToTable("SMS"); - }); - - modelBuilder.Entity("_2021_backend.Models.Session", b => - { - b.Property("Guid") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BeginTime") - .HasColumnType("timestamp without time zone"); - - b.Property("Capacity") - .HasColumnType("integer"); - - b.Property>("Chiefs") - .HasColumnType("uuid[]"); - - b.Property("Day") - .HasColumnType("timestamp without time zone"); - - b.Property("Place") - .IsRequired() - .HasColumnType("text"); - - b.Property("SendSMS") - .HasColumnType("boolean"); - - b.Property>("Students") - .HasColumnType("uuid[]"); - - b.HasKey("Guid"); - - b.ToTable("Sessions"); + b.ToTable("SMS", (string)null); }); modelBuilder.Entity("_2021_backend.Models.Student", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); - b.Property>("Comments") - .HasColumnType("uuid[]"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Comments") + .HasColumnType("integer[]"); b.Property("Email") .HasColumnType("text"); @@ -124,23 +135,23 @@ namespace _2021_backend.Migrations b.Property("Grade") .HasColumnType("integer"); - b.Property("InterviewTime") - .HasColumnType("uuid"); + b.Property("InterviewTime") + .HasColumnType("integer"); b.Property("LastSubmission") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Major") .HasColumnType("text"); - b.Property>("Messages") - .HasColumnType("uuid[]"); + b.Property>("Messages") + .HasColumnType("integer[]"); b.Property("Name") .HasColumnType("text"); b.Property("RegisterTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Score") .HasColumnType("integer"); @@ -154,28 +165,30 @@ namespace _2021_backend.Migrations b.Property("Stuid") .HasColumnType("text"); - b.Property>("Submissions") - .HasColumnType("uuid[]"); + b.Property>("Submissions") + .HasColumnType("integer[]"); b.Property("Tel") .HasColumnType("text"); - b.Property>("Timelist") - .HasColumnType("uuid[]"); + b.Property>("Timelist") + .HasColumnType("integer[]"); b.Property("Yard") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); - b.ToTable("Students"); + b.ToTable("Students", (string)null); }); modelBuilder.Entity("_2021_backend.Models.Submission", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Address") .HasColumnType("text"); @@ -189,8 +202,8 @@ namespace _2021_backend.Migrations b.Property("Grade") .HasColumnType("integer"); - b.Property("Host") - .HasColumnType("uuid"); + b.Property("Host") + .HasColumnType("integer"); b.Property("Major") .HasColumnType("text"); @@ -205,27 +218,29 @@ namespace _2021_backend.Migrations .HasColumnType("text"); b.Property("SubmitTime") - .HasColumnType("timestamp without time zone"); + .HasColumnType("timestamp with time zone"); b.Property("Tel") .HasColumnType("text"); - b.Property>("Timelist") - .HasColumnType("uuid[]"); + b.Property>("Timelist") + .HasColumnType("integer[]"); b.Property("Yard") .HasColumnType("integer"); - b.HasKey("Guid"); + b.HasKey("Id"); - b.ToTable("Submissions"); + b.ToTable("Submissions", (string)null); }); modelBuilder.Entity("_2021_backend.Models.User", b => { - b.Property("Guid") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .HasColumnType("text"); @@ -239,9 +254,9 @@ namespace _2021_backend.Migrations b.Property("stuID") .HasColumnType("text"); - b.HasKey("Guid"); + b.HasKey("Id"); - b.ToTable("Users"); + b.ToTable("Users", (string)null); }); #pragma warning restore 612, 618 } diff --git a/Models/Comment.cs b/Models/Comment.cs index cc843d8..61c6f0b 100644 --- a/Models/Comment.cs +++ b/Models/Comment.cs @@ -11,30 +11,31 @@ namespace _2021_backend.Models { public Comment() { - Guid = Guid.NewGuid(); - AddTime = DateTime.Now; + Id = 0; + AddTime = DateTime.Now; } [Key] - public Guid Guid { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } [Required()] - [Display(Name ="评论者")] - public Guid Operator { get; set; } + [Display(Name = "评论者")] + public int Operator { get; set; } [Required()] - [Display(Name ="内容")] + [Display(Name = "内容")] public string Content { get; set; } [Display(Name = "评论时间")] [DataType(DataType.DateTime)] public DateTime AddTime { get; set; } - [Display(Name ="被评论者")] - public Guid Student { get; set; } - public Comment(Guid opid,string content, Guid stuguid) + [Display(Name = "被评论者")] + public int Student { get; set; } + public Comment(int opid, string content, int stuint) { - Guid = Guid.NewGuid(); + Id = 0; Operator = opid; Content = content; - Student = stuguid; + Student = stuint; AddTime = DateTime.Now; } diff --git a/Models/SMS.cs b/Models/SMS.cs index 7b0e2c9..98177f9 100644 --- a/Models/SMS.cs +++ b/Models/SMS.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations.Schema; namespace _2021_backend.Models { @@ -18,16 +19,16 @@ namespace _2021_backend.Models { public SMS() { - Guid = Guid.NewGuid(); + Id = 0; Tel = ""; Data = new List { }; Type = SMSType.Accept; Sender = ""; SendTime = DateTime.Now; } - public SMS(SMSPartialDto dto, Guid host) + public SMS(SMSPartialDto dto, int host) { - Guid = Guid.NewGuid(); + Id = 0; Tel = dto.SubscriberNumber; Host = host; Sender = dto.SubscriberNumber.ToString(); @@ -37,17 +38,18 @@ namespace _2021_backend.Models SendTime = tm; } [Key] - public Guid Guid { get; set; } - [Display(Name ="Host")] - public Guid Host { get; set; } - [Display(Name ="电话号码")] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + [Display(Name = "Host")] + public int Host { get; set; } + [Display(Name = "电话号码")] public string Tel { get; set; } - [Display(Name ="短信内容")] + [Display(Name = "短信内容")] public List Data { get; set; } - [Display(Name ="短信类型")] + [Display(Name = "短信类型")] public SMSType Type { get; set; } - [Display(Name ="发送者")] + [Display(Name = "发送者")] public string Sender { get; set; } [Display(Name = "发送时间")] [DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)] diff --git a/Models/Session.cs b/Models/Session.cs index 16c9f2a..c459cb9 100644 --- a/Models/Session.cs +++ b/Models/Session.cs @@ -14,12 +14,13 @@ namespace _2021_backend.Models public Session() { - Guid = Guid.NewGuid(); + Id = 0; } [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Required()] - [Display(Name = "场次GUID")] - public Guid Guid { get; set; } + [Display(Name = "场次int")] + public int Id { get; set; } [Required()] [Display(Name = "活动日期")] [DataType(DataType.Date)] @@ -35,7 +36,7 @@ namespace _2021_backend.Models [Required()] public string Place { get; set; } [Display(Name = "主活动官")] - public List Chiefs { get; set; } + public List Chiefs { get; set; } [Display(Name = "可容纳人数")] public int Capacity { get; set; } @@ -43,7 +44,7 @@ namespace _2021_backend.Models [Display(Name = "短信通知")] public bool SendSMS { get; set; } [Display(Name = "活动的人")] - public List Students { get; set; } + public List Students { get; set; } } public class SessionDto @@ -57,7 +58,7 @@ namespace _2021_backend.Models public class SessionDtoComparer : IEqualityComparer { #region IEqualityComparer Members - public bool Equals(SessionDto a,SessionDto b) + public bool Equals(SessionDto a, SessionDto b) { return a.Day == b.Day && a.BeginTime == b.BeginTime; } diff --git a/Models/Student.cs b/Models/Student.cs index 51fea32..ee7ef3f 100644 --- a/Models/Student.cs +++ b/Models/Student.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Threading.Tasks; @@ -64,22 +65,22 @@ namespace _2021_backend.Models Major = sub.Major; Yard = sub.Yard; Exp = sub.Exp; - Timelist = sub.Timelist; - Submissions.Add(sub.Guid); + Timelist = sub.Timelist; + Submissions.Add(sub.Id); } public Student() { - Guid = Guid.NewGuid(); - Comments = new List(); - Messages = new List(); - Submissions = new List(); - Timelist = new List(); + Id = 0; + Comments = new List(); + Messages = new List(); + Submissions = new List(); + Timelist = new List(); } public static Student create(Submission sub) { Student student = new Student(); - student.Guid = Guid.NewGuid(); + student.Id = 0; student.Name = sub.Name; student.Email = sub.Email; student.Tel = sub.Tel; @@ -90,13 +91,14 @@ namespace _2021_backend.Models student.Yard = sub.Yard; student.Exp = sub.Exp; student.Timelist = sub.Timelist; - student.Submissions.Add(sub.Guid); + student.Submissions.Add(sub.Id); student.RegisterTime = sub.SubmitTime; return student; } [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Display(Name = "ID")] - public Guid Guid { get; set; } + public int Id { get; set; } [Display(Name = "姓名")] public string Name { get; set; } [Display(Name = "学号")] @@ -107,7 +109,7 @@ namespace _2021_backend.Models public grade Grade { get; set; } [Display(Name = "学园")] - public yard Yard { get; set; } + public yard Yard { get; set; } [Display(Name = "专业")] public string Major { get; set; } [Display(Name = "电子邮件")] @@ -116,20 +118,20 @@ namespace _2021_backend.Models public string Tel { get; set; } [Display(Name = "经验程度")] - public experience Exp { get; set; } + public experience Exp { get; set; } [Display(Name = "最终场次")] - public Guid InterviewTime { get; set; } + public int InterviewTime { get; set; } [Display(Name = "提交记录")] - public List Submissions { get; set; } + public List Submissions { get; set; } [Display(Name = "短信记录")] - public List Messages { get; set; } + public List Messages { get; set; } [Display(Name = "可选场次")] - public List Timelist { get; set; } + public List Timelist { get; set; } [Display(Name = "评论")] - public List Comments { get; set; } + public List Comments { get; set; } [Display(Name = "打分")] - public int Score { get; set; } + public int Score { get; set; } [Display(Name = "状态")] public status Status { get; set; } diff --git a/Models/Submission.cs b/Models/Submission.cs index 3618874..55efc65 100644 --- a/Models/Submission.cs +++ b/Models/Submission.cs @@ -3,6 +3,7 @@ using Org.BouncyCastle.Asn1.Cms; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -11,8 +12,9 @@ namespace _2021_backend.Models { public class Submission { - public Submission() { - Guid = Guid.NewGuid(); + public Submission() + { + Id = 0; SubmitTime = DateTime.Now; } public Submission(SubmissionDto Dto, string ip) @@ -26,16 +28,17 @@ namespace _2021_backend.Models Tel = Dto.Tel; Exp = (experience)Dto.Exp; Yard = (yard)Dto.Yard; - Timelist = new List(); - Guid = System.Guid.NewGuid(); + Timelist = new List(); + Id = 0; SubmitTime = DateTime.Now; Address = ip; } [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Display(Name = "ID")] - public Guid Guid { get; set; } - [Display(Name ="Host")] - public Guid Host { get; set; } + public int Id { get; set; } + [Display(Name = "Host")] + public int Host { get; set; } [Display(Name = "姓名")] public string Name { get; set; } [Display(Name = "学号")] @@ -58,9 +61,9 @@ namespace _2021_backend.Models public experience Exp { get; set; } [Display(Name = "时间列表")] - public List Timelist { get; set; } - [Display(Name ="Ip Address")] - public string Address { get; set; } + public List Timelist { get; set; } + [Display(Name = "Ip Address")] + public string Address { get; set; } [Display(Name = "提交时间")] [DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)] public DateTime SubmitTime { get; set; } @@ -69,8 +72,8 @@ namespace _2021_backend.Models } public class TimeSpec { - public DateTime Day { get; set; } - public DateTime BeginTime { get; set; } + public DateTime Day { get; set; } + public DateTime BeginTime { get; set; } } public class SubmissionDto @@ -91,12 +94,12 @@ namespace _2021_backend.Models public string Email { get; set; } [Required()] public string Tel { get; set; } - + [Required()] public int Exp { get; set; } [Required()] - public List Timelist { get; set; } + public List Timelist { get; set; } public static Regex r = new Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"); @@ -118,7 +121,7 @@ namespace _2021_backend.Models if (Major.Length > 20) return false; if (Yard >= 6 && Yard <= 0) return false; - if(Exp >= 5 && Exp <= 0) return false; + if (Exp >= 5 && Exp <= 0) return false; if (!r.IsMatch(Email)) { return false; diff --git a/Models/User.cs b/Models/User.cs index 9f95d05..db1a3ac 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -10,37 +10,37 @@ using Microsoft.EntityFrameworkCore.Internal; namespace _2021_backend.Models { - + public class User { public User() { - Guid = Guid.NewGuid(); + Id = 0; } public static User Bot; [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Display(Name ="ID")] - public Guid Guid { get; set; } + [Display(Name = "ID")] + public int Id { get; set; } [Display(Name = "学号")] public string stuID { get; set; } - [Display(Name ="姓名")] + [Display(Name = "姓名")] public string Name { get; set; } - [Display(Name ="密码")] + [Display(Name = "密码")] public string Secret { get; set; } - [Display(Name ="是否管理员")] + [Display(Name = "是否管理员")] public bool isManager { get; set; } } public class Login { - private readonly string[] Manager = { "3200102610", "3190104611", "3190104698", "3190103719", "3190104143", "3190100494", "3190103301", "3190102034", "3190100151", "3190103577", "3190105399", "3190100133" }; + private readonly string[] Manager = { "3200102610", "3190104611", "3190104698", "3190103719", "3190104143", "3190100494", "3190103301", "3190102034", "3190100151", "3190103577", "3190105399", "3190100133" }; [JsonProperty("username")] public string id_student { get; set; } [JsonProperty("password")] public string Password { get; set; } - public Login(string name,string pwd) + public Login(string name, string pwd) { id_student = name; Password = pwd; @@ -48,7 +48,7 @@ namespace _2021_backend.Models public string GetSHASecret() => _2021_backend.Utils.EvaCryptoHelper.Password2Secret(Password); public bool isManager() { - if (Array.IndexOf(Manager,id_student) != -1) + if (Array.IndexOf(Manager, id_student) != -1) return true; return false; } diff --git a/Pages/Account/Login.cshtml.cs b/Pages/Account/Login.cshtml.cs index 7a7f1b0..cd1be3f 100644 --- a/Pages/Account/Login.cshtml.cs +++ b/Pages/Account/Login.cshtml.cs @@ -85,7 +85,7 @@ namespace _2021_backend.Pages.Account { var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role); identity.AddClaim(new Claim(ClaimTypes.Name, user.Name)); - identity.AddClaim(new Claim(ClaimTypes.Sid, user.Guid.ToString())); + identity.AddClaim(new Claim(ClaimTypes.Sid, user.Id.ToString())); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, username)); if (user.isManager) { diff --git a/Pages/Message/Index.cshtml.cs b/Pages/Message/Index.cshtml.cs index d6f8579..7c141d3 100644 --- a/Pages/Message/Index.cshtml.cs +++ b/Pages/Message/Index.cshtml.cs @@ -42,10 +42,10 @@ namespace _2021_backend.Pages.Message public IActionResult Construct(int PageId) { - List stus; - IQueryable q; - if (!String.IsNullOrEmpty(SearchString)) q = from e in Context.Students where e.Name.Contains(SearchString) select e.Guid; - else q = from e in Context.Students select e.Guid; + List stus; + IQueryable q; + if (!String.IsNullOrEmpty(SearchString)) q = from e in Context.Students where e.Name.Contains(SearchString) select e.Id; + else q = from e in Context.Students select e.Id; stus = q.ToList(); var q2 = from e in Context.SMS where stus.Contains(e.Host) select e; if (showReceive && !showSend) q2 = from e in q2 where e.Type == SMSType.Reply select e; @@ -94,7 +94,7 @@ namespace _2021_backend.Pages.Message foreach (var e in stu) { if (e.Status == status.刚报名) - await Utils.TencentSMS.Send(Context, SMSType.Signed, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + await Utils.TencentSMS.Send(Context, SMSType.Signed, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); } return Construct(PageId); @@ -107,8 +107,8 @@ namespace _2021_backend.Pages.Message { if (e.Status == status.不通过) { - if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Reject)) - await Utils.TencentSMS.Send(Context, SMSType.Reject, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + if (!Context.SMS.Any(it => it.Host == e.Id && it.Type == SMSType.Reject)) + await Utils.TencentSMS.Send(Context, SMSType.Reject, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); } } return Construct(PageId); @@ -121,7 +121,7 @@ namespace _2021_backend.Pages.Message { if (e.Status != status.不通过 && e.Status != status.已选时间) { - await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); } } Context.SaveChanges(); @@ -135,8 +135,8 @@ namespace _2021_backend.Pages.Message { if (e.Status == status.通过) { - if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Accept)) - await Utils.TencentSMS.Send(Context, SMSType.Accept, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + if (!Context.SMS.Any(it => it.Host == e.Id && it.Type == SMSType.Accept)) + await Utils.TencentSMS.Send(Context, SMSType.Accept, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); } } @@ -149,9 +149,9 @@ namespace _2021_backend.Pages.Message foreach(var e in stu) { var t = Context.Sessions.Find(e.InterviewTime); - if(t != null && t.Students.Find(s => s==e.Guid)!= Guid.Empty && e.Status == status.已选时间) + if(t != null && t.Students.Find(s => s==e.Id)!= 0 && e.Status == status.已选时间) { - await Utils.TencentSMS.Send(Context, SMSType.TimeSet, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + await Utils.TencentSMS.Send(Context, SMSType.TimeSet, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); e.Status = status.已确认时间; } } diff --git a/Pages/Sessions/Create.cshtml.cs b/Pages/Sessions/Create.cshtml.cs index b0f67c4..ae44721 100644 --- a/Pages/Sessions/Create.cshtml.cs +++ b/Pages/Sessions/Create.cshtml.cs @@ -22,7 +22,7 @@ namespace _2021_backend.Pages.Sessions [BindProperty] [Display(Name = "活动官")] - public string ChiefGuid { get; set; } + public string Chiefint { get; set; } public List ChiefList { get; set; } @@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions public async Task OnGet() { - var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false }); + var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false }); var lst = qlst.ToList().Distinct().ToList(); ChiefList = lst; return Page(); @@ -48,8 +48,8 @@ namespace _2021_backend.Pages.Sessions { return Page(); } - InterviewTime.Students = new List(); - InterviewTime.Chiefs = new List(); + InterviewTime.Students = new List(); + InterviewTime.Chiefs = new List(); Session interviewTimeSecond = new Session(); if (CreateTwo) { @@ -62,9 +62,9 @@ namespace _2021_backend.Pages.Sessions Day = InterviewTime.Day, BeginTime = InterviewTime.BeginTime, Place = anotherPlace, - Chiefs = new List(), + Chiefs = new List(), SendSMS = InterviewTime.SendSMS, - Students = new List(), + Students = new List(), Capacity = InterviewTime.Capacity }; Context.Add(interviewTimeSecond); diff --git a/Pages/Sessions/Delete.cshtml b/Pages/Sessions/Delete.cshtml index eef49d6..3559b8f 100644 --- a/Pages/Sessions/Delete.cshtml +++ b/Pages/Sessions/Delete.cshtml @@ -34,7 +34,7 @@
- + | Back to List
diff --git a/Pages/Sessions/Delete.cshtml.cs b/Pages/Sessions/Delete.cshtml.cs index 332c3ae..fb782ba 100644 --- a/Pages/Sessions/Delete.cshtml.cs +++ b/Pages/Sessions/Delete.cshtml.cs @@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Sessions public async Task OnGetAsync(string? id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - InterviewTime = Context.Sessions.Find(guid); + InterviewTime = Context.Sessions.Find(idx); if (InterviewTime == null) { @@ -41,12 +41,12 @@ namespace _2021_backend.Pages.Sessions public async Task OnPostAsync(string? id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - InterviewTime = await Context.Sessions.FindAsync(guid); + InterviewTime = await Context.Sessions.FindAsync(idx); if (InterviewTime != null) { @@ -57,15 +57,15 @@ namespace _2021_backend.Pages.Sessions Student stu = Context.Students.Find(x); if (stu != null) { - stu.InterviewTime = Guid.Empty; - stu.Timelist.RemoveAll(it => it == guid); + stu.InterviewTime = 0; + stu.Timelist.RemoveAll(it => it == idx); } Context.SaveChanges(); } } foreach(var x in Context.Students) { - x.Timelist.RemoveAll(it => it == guid); + x.Timelist.RemoveAll(it => it == idx); } Context.Sessions.Remove(InterviewTime); Context.SaveChanges(); diff --git a/Pages/Sessions/Details.cshtml b/Pages/Sessions/Details.cshtml index 8775c58..52fa02c 100644 --- a/Pages/Sessions/Details.cshtml +++ b/Pages/Sessions/Details.cshtml @@ -64,6 +64,6 @@ diff --git a/Pages/Sessions/Details.cshtml.cs b/Pages/Sessions/Details.cshtml.cs index 2814685..011519c 100644 --- a/Pages/Sessions/Details.cshtml.cs +++ b/Pages/Sessions/Details.cshtml.cs @@ -23,12 +23,12 @@ namespace _2021_backend.Pages.Sessions public async Task OnGetAsync(string? id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - CurSession = Context.Sessions.Find(guid); + CurSession = Context.Sessions.Find(idx); if (CurSession == null) { return NotFound(); diff --git a/Pages/Sessions/Edit.cshtml b/Pages/Sessions/Edit.cshtml index bb44783..e906ad2 100644 --- a/Pages/Sessions/Edit.cshtml +++ b/Pages/Sessions/Edit.cshtml @@ -13,8 +13,8 @@
- - + +
@@ -51,7 +51,7 @@ - +
@@ -76,11 +76,11 @@ @Html.DisplayFor(model=>stu.Name) - 详细信息 + 详细信息
- - + +
@@ -98,7 +98,7 @@
- +

@@ -121,8 +121,8 @@
- - + +
diff --git a/Pages/Sessions/Edit.cshtml.cs b/Pages/Sessions/Edit.cshtml.cs index 1fcb158..fccc5af 100644 --- a/Pages/Sessions/Edit.cshtml.cs +++ b/Pages/Sessions/Edit.cshtml.cs @@ -24,7 +24,7 @@ namespace _2021_backend.Pages.Sessions public Session CurSession { get; set; } [BindProperty] - public string CurGuid { get; set; } + public string Curint { get; set; } [BindProperty] public string ChiefSearch { get; set; } @@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions public List Stulist { get; set; } [BindProperty] - public Guid addedChief { get; set; } + public int addedChief { get; set; } [BindProperty] public string addedStu { get; set; } @@ -71,13 +71,13 @@ namespace _2021_backend.Pages.Sessions public IActionResult Construct(string id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - CurGuid = id; - CurSession = Context.Sessions.Find(guid); + Curint = id; + CurSession = Context.Sessions.Find(idx); newDay = CurSession.Day; newTime = CurSession.BeginTime; @@ -86,10 +86,10 @@ namespace _2021_backend.Pages.Sessions newPlace = CurSession.Place; if (CurSession == null) return RedirectToPage("./Index", new { errmsg = "未找到该活动场次" }); - var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false }); + var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false }); ChiefList = qlst.ToList().Distinct().ToList(); - var slst = from e in Context.Students where e.InterviewTime == Guid.Empty select new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false }; + var slst = from e in Context.Students where e.InterviewTime == 0 select new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false }; Stulist = slst.ToList().Distinct().ToList(); return Page(); } @@ -103,7 +103,7 @@ namespace _2021_backend.Pages.Sessions // more details, see https://aka.ms/RazorPagesCRUD. public async Task OnPostAsync() { - var ssn = Context.Sessions.Find(Guid.Parse(CurGuid)); + var ssn = Context.Sessions.Find(int.Parse(Curint)); ssn.SendSMS = sendSMS; ssn.Day = newDay; ssn.BeginTime = newTime; @@ -116,73 +116,73 @@ namespace _2021_backend.Pages.Sessions public async Task OnPostDeleteAsync(string id) { - CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); - var guid = Guid.Parse(id); + CurSession = Context.Sessions.Find(int.Parse(Curint)); + var idx = int.Parse(id); if (!string.IsNullOrEmpty(id)) { - if (Context.Students.Any(it => it.Guid == guid)) + if (Context.Students.Any(it => it.Id == idx)) { - Context.Students.Find(guid).InterviewTime = Guid.Empty; - CurSession.Students.RemoveAll(it => it == guid); + Context.Students.Find(idx).InterviewTime = 0; + CurSession.Students.RemoveAll(it => it == idx); } Context.SaveChanges(); } - return Construct(CurGuid); + return Construct(Curint); } public async Task OnPostAddAsync() { - CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); - var guid = Guid.Parse(addedStu); + CurSession = Context.Sessions.Find(int.Parse(Curint)); + var idx = int.Parse(addedStu); if (!string.IsNullOrEmpty(addedStu)) { - if (Context.Students.Any(it => it.Guid == guid)) + if (Context.Students.Any(it => it.Id == idx)) { - var stu = Context.Students.Find(guid); - if(stu.InterviewTime != Guid.Empty) + var stu = Context.Students.Find(idx); + if(stu.InterviewTime != 0) { var oldtime = Context.Sessions.Find(stu.InterviewTime); if(oldtime != null) { - oldtime.Students.RemoveAll(s => s == stu.Guid); + oldtime.Students.RemoveAll(s => s == stu.Id); Context.SaveChanges(); } } - stu.InterviewTime = CurSession.Guid; + stu.InterviewTime = CurSession.Id; stu.Status = status.已选时间; - CurSession.Students.Add(guid); + CurSession.Students.Add(idx); } Context.SaveChanges(); } - return Construct(CurGuid); + return Construct(Curint); } public async Task OnPostAddChiefAsync() { - CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); - if (Context.Users.Any(it => it.Guid == addedChief)) + CurSession = Context.Sessions.Find(int.Parse(Curint)); + if (Context.Users.Any(it => it.Id == addedChief)) { CurSession.Chiefs.Add(addedChief); } Context.SaveChanges(); - return Construct(CurGuid); + return Construct(Curint); } public async Task OnPostDeleteChiefAsync(string id) { - var guid = Guid.Parse(id); - CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); - if (CurSession.Chiefs.Contains(guid)) + var idx = int.Parse(id); + CurSession = Context.Sessions.Find(int.Parse(Curint)); + if (CurSession.Chiefs.Contains(idx)) { - CurSession.Chiefs.Remove(guid); + CurSession.Chiefs.Remove(idx); } Context.SaveChanges(); - return Construct(CurGuid); + return Construct(Curint); } - private bool InterviewTimeExists(Guid id) + private bool InterviewTimeExists(int id) { - return Context.Sessions.Any(e => e.Guid == id); + return Context.Sessions.Any(e => e.Id == id); } } } diff --git a/Pages/Sessions/Index.cshtml b/Pages/Sessions/Index.cshtml index 57b772d..366d9d6 100644 --- a/Pages/Sessions/Index.cshtml +++ b/Pages/Sessions/Index.cshtml @@ -157,9 +157,9 @@ } - 编辑 | - 删除 | - 重置 + 编辑 | + 删除 | + 重置 } diff --git a/Pages/Sessions/Index.cshtml.cs b/Pages/Sessions/Index.cshtml.cs index 4ec7210..a40466a 100644 --- a/Pages/Sessions/Index.cshtml.cs +++ b/Pages/Sessions/Index.cshtml.cs @@ -89,16 +89,16 @@ namespace _2021_backend.Pages.Sessions return Construct(errmsg); } - public async Task OnGetResetAsync(Guid id) + public async Task OnGetResetAsync(int id) { - if(Context.Sessions.Any(it => it.Guid == id)) + if(Context.Sessions.Any(it => it.Id == id)) { var s = Context.Sessions.Find(id); foreach(var st in s.Students) { var e = Context.Students.Find(st); e.Status = status.需调整时间; - e.InterviewTime = Guid.Empty; + e.InterviewTime = 0; } s.Students.Clear(); } @@ -132,7 +132,7 @@ namespace _2021_backend.Pages.Sessions { foreach(var s in Context.Students) { - s.InterviewTime = Guid.Empty; + s.InterviewTime = 0; s.Status = status.需调整时间; s.Timelist.Clear(); } @@ -152,9 +152,9 @@ namespace _2021_backend.Pages.Sessions { if(s.Status == status.已选时间) { - s.InterviewTime = Guid.Empty; - s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it)); - s.Timelist.Sort((Guid a, Guid b) => + s.InterviewTime = 0; + s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it)); + s.Timelist.Sort((int a, int b) => { var x = Context.Sessions.Find(a); var y = Context.Sessions.Find(b); @@ -193,7 +193,7 @@ namespace _2021_backend.Pages.Sessions var ntm = new List(); foreach(var j in tm) { - var k = sess.Find(it => it.Guid == j); + var k = sess.Find(it => it.Id == j); ntm.Add(k); } ntm.Sort((Session a,Session b) => @@ -202,17 +202,17 @@ namespace _2021_backend.Pages.Sessions var y = a.BeginTime.CompareTo(b.BeginTime); return x != 0 ? x : y; }); - List nl = new List(); + List nl = new List(); foreach(var j in ntm) { if(i.Status != status.不通过 && i.Status != status.通过 && i.Status != status.已确认时间) { - if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k ==i.Guid) )) continue; - nl.Add(j.Guid); + if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k ==i.Id) )) continue; + nl.Add(j.Id); } else { - nl.Add(j.Guid); + nl.Add(j.Id); } } @@ -236,9 +236,9 @@ namespace _2021_backend.Pages.Sessions { if (s.Status == status.已选时间) { - s.InterviewTime = Guid.Empty; - s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it)); - s.Timelist.Sort((Guid a, Guid b) => + s.InterviewTime = 0; + s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it)); + s.Timelist.Sort((int a, int b) => { var x = Context.Sessions.Find(a); var y = Context.Sessions.Find(b); @@ -256,7 +256,7 @@ namespace _2021_backend.Pages.Sessions Context.SaveChanges(); foreach(var item in loads) { - Session s = Context.Sessions.Find(item.Guid); + Session s = Context.Sessions.Find(item.Id); if(s != null) { s.BeginTime = item.BeginTime; @@ -264,12 +264,12 @@ namespace _2021_backend.Pages.Sessions s.Capacity = item.Capacity; s.SendSMS = item.SendSMS; s.Chiefs = item.Chiefs; - s.Students = new List(); + s.Students = new List(); foreach(var s2 in item.Students) { - if (Context.Students.Any(k => k.Guid == s2)) + if (Context.Students.Any(k => k.Id == s2)) { - Context.Students.Find(s2).InterviewTime = item.Guid; + Context.Students.Find(s2).InterviewTime = item.Id; s.Students.Add(s2); } } diff --git a/Pages/Students/Delete.cshtml b/Pages/Students/Delete.cshtml index f9b1d11..df05644 100644 --- a/Pages/Students/Delete.cshtml +++ b/Pages/Students/Delete.cshtml @@ -75,7 +75,7 @@
- + | 返回列表
diff --git a/Pages/Students/Delete.cshtml.cs b/Pages/Students/Delete.cshtml.cs index b669257..79925e6 100644 --- a/Pages/Students/Delete.cshtml.cs +++ b/Pages/Students/Delete.cshtml.cs @@ -28,9 +28,9 @@ namespace _2021_backend.Pages.Students { return NotFound(); } - Guid id = Guid.Parse(idstr); + int id = int.Parse(idstr); - Student = await Context.Students.FirstOrDefaultAsync(m => m.Guid == id); + Student = await Context.Students.FirstOrDefaultAsync(m => m.Id == id); if (Student == null) { @@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students { return NotFound(); } - Guid id = Guid.Parse(idstr); + int id = int.Parse(idstr); Student = await Context.Students.FindAsync(id); diff --git a/Pages/Students/Details.cshtml b/Pages/Students/Details.cshtml index 429bbc9..9c9dd2d 100644 --- a/Pages/Students/Details.cshtml +++ b/Pages/Students/Details.cshtml @@ -70,7 +70,7 @@
此人的最终得分 : @Html.DisplayFor(model => model.Student.Score)
- +
操作
@@ -131,7 +131,7 @@
- +
@@ -175,7 +175,7 @@ { var it = Model.Student.Timelist[i]; var dt = Model.Context.Sessions.Find(it); - if (dt.Capacity > dt.Students.Count || dt.Students.Contains(Model.Student.Guid)) + if (dt.Capacity > dt.Students.Count || dt.Students.Contains(Model.Student.Id)) { @@ -211,9 +211,9 @@
- + 场次详情 - +
@@ -225,7 +225,7 @@ Ta的短信
- + @@ -355,8 +355,8 @@ @Html.DisplayFor(modelItem => sub.SubmitTime) - Edit | - Details + Edit | + Details } @@ -366,6 +366,6 @@ diff --git a/Pages/Students/Details.cshtml.cs b/Pages/Students/Details.cshtml.cs index 3f5bd31..ea01242 100644 --- a/Pages/Students/Details.cshtml.cs +++ b/Pages/Students/Details.cshtml.cs @@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students { return NotFound(); } - Guid id = Guid.Parse(idstr); + int id = int.Parse(idstr); Student = Context.Students.Find(id); if (Student == null) { @@ -62,7 +62,7 @@ namespace _2021_backend.Pages.Students Sessions.Add(tm); } Messages = Context.SMS.Where(it => it.Host == id).ToList(); - CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList(); + CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList(); Sessions.Sort((Session a, Session b) => { var x = a.Day.CompareTo(b.Day); var y = a.BeginTime.CompareTo(b.BeginTime); @@ -84,60 +84,60 @@ namespace _2021_backend.Pages.Students if (!string.IsNullOrWhiteSpace(NewComment)) { var cmt = new Comment(); - cmt.Student = Student.Guid; + cmt.Student = Student.Id; cmt.Content = NewComment; - cmt.Operator = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value); - var stu = Context.Students.Find(Student.Guid); - stu.Comments.Add(cmt.Guid); + cmt.Operator = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value); + var stu = Context.Students.Find(Student.Id); + stu.Comments.Add(cmt.Id); Context.Comments.Add(cmt); Context.SaveChanges(); } - Construct(Student.Guid.ToString()); - return RedirectToPage(new { idstr = Student.Guid.ToString() }); + Construct(Student.Id.ToString()); + return RedirectToPage(new { idstr = Student.Id.ToString() }); } public async Task OnPostAcceptAsync() { - Student = Context.Students.Find(Student.Guid); + Student = Context.Students.Find(Student.Id); Student.Status = status.通过; Context.SaveChanges(); - CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList(); - Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList(); - Construct(Student.Guid.ToString()); - return RedirectToPage(new { idstr = Student.Guid.ToString() }); + CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList(); + Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList(); + Construct(Student.Id.ToString()); + return RedirectToPage(new { idstr = Student.Id.ToString() }); } public async Task OnPostRejectAsync() { - Student = Context.Students.Find(Student.Guid); + Student = Context.Students.Find(Student.Id); Student.Status = status.不通过; Context.SaveChanges(); Student.Score = 0; - CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList(); - Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList(); - Construct(Student.Guid.ToString()); - return RedirectToPage(new { idstr = Student.Guid.ToString() }); + CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList(); + Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList(); + Construct(Student.Id.ToString()); + return RedirectToPage(new { idstr = Student.Id.ToString() }); } - public async Task OnPostSelectAsync(Guid stu, Guid time) + public async Task OnPostSelectAsync(int stu, int time) { var st = Context.Students.Find(stu); if (st != null) { - if (Context.Sessions.Any(it => it.Guid == time)) + if (Context.Sessions.Any(it => it.Id == time)) { var tm = Context.Sessions.Find(time); if (tm.Students.Count < tm.Capacity) { - if (st.InterviewTime != Guid.Empty) + if (st.InterviewTime != 0) { var tmold = Context.Sessions.Find(st.InterviewTime); if (tmold != null) { - tmold.Students.RemoveAll(it => it == st.Guid); + tmold.Students.RemoveAll(it => it == st.Id); Context.SaveChanges(); } } @@ -148,58 +148,58 @@ namespace _2021_backend.Pages.Students } } } - return Construct(Student.Guid.ToString()); + return Construct(Student.Id.ToString()); } public async Task OnPostPullAsync() { - await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Guid), true); - return Construct(Student.Guid.ToString()); + await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Id), true); + return Construct(Student.Id.ToString()); } public async Task OnPostRankAsync() { - var s = Context.Students.Find(Student.Guid); + var s = Context.Students.Find(Student.Id); s.Score = score; s.Status = status.已评分; Context.SaveChanges(); - return Construct(Student.Guid.ToString()); + return Construct(Student.Id.ToString()); } public async Task OnPostResultAsync() { - var stu = Context.Students.Find(Student.Guid); + var stu = Context.Students.Find(Student.Id); if (stu.Status == status.通过) - await Utils.TencentSMS.Send(Context, SMSType.Accept, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + await Utils.TencentSMS.Send(Context, SMSType.Accept, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); else if (stu.Status == status.不通过) - await Utils.TencentSMS.Send(Context, SMSType.Reject, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); - return Construct(Student.Guid.ToString()); + await Utils.TencentSMS.Send(Context, SMSType.Reject, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + return Construct(Student.Id.ToString()); } public async Task OnPostSignAsync() { - var stu = Context.Students.Find(Student.Guid); - await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); - return Construct(Student.Guid.ToString()); + var stu = Context.Students.Find(Student.Id); + await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + return Construct(Student.Id.ToString()); } public async Task OnPostSelectTimeAsync() { - var stu = Context.Students.Find(Student.Guid); - await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + var stu = Context.Students.Find(Student.Id); + await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); stu.Status = status.需调整时间; Context.SaveChanges(); - return Construct(Student.Guid.ToString()); + return Construct(Student.Id.ToString()); } public async Task OnPostTimeAsync() { - var stu = Context.Students.Find(Student.Guid); - await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + var stu = Context.Students.Find(Student.Id); + await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); stu.Status = status.已确认时间; Context.SaveChanges(); - return Construct(Student.Guid.ToString()); + return Construct(Student.Id.ToString()); } } } diff --git a/Pages/Students/Edit.cshtml b/Pages/Students/Edit.cshtml index ed74e78..9219f9c 100644 --- a/Pages/Students/Edit.cshtml +++ b/Pages/Students/Edit.cshtml @@ -13,7 +13,7 @@
- +
diff --git a/Pages/Students/Edit.cshtml.cs b/Pages/Students/Edit.cshtml.cs index 49f85bb..5272c83 100644 --- a/Pages/Students/Edit.cshtml.cs +++ b/Pages/Students/Edit.cshtml.cs @@ -26,8 +26,8 @@ namespace _2021_backend.Pages.Students { return NotFound(); } - Guid id = Guid.Parse(idstr); - Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Guid == id); + int id = int.Parse(idstr); + Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Id == id); if (Student == null) { @@ -40,7 +40,7 @@ namespace _2021_backend.Pages.Students // For more details, see https://aka.ms/RazorPagesCRUD. public async Task OnPostAsync() { - var stu = Context.Students.Find(Student.Guid); + var stu = Context.Students.Find(Student.Id); stu.Status = Student.Status; stu.Email = Student.Email; stu.Name = Student.Name; @@ -53,9 +53,9 @@ namespace _2021_backend.Pages.Students return RedirectToPage("./Index"); } - private bool StudentExists(Guid id) + private bool StudentExists(int id) { - return Context.Students.Any(e => e.Guid == id); + return Context.Students.Any(e => e.Id == id); } } } diff --git a/Pages/Students/Index.cshtml b/Pages/Students/Index.cshtml index d1ec8db..0904a88 100644 --- a/Pages/Students/Index.cshtml +++ b/Pages/Students/Index.cshtml @@ -105,10 +105,10 @@ } - @Html.DisplayFor(modelItem => item.Name) + @Html.DisplayFor(modelItem => item.Name) - @Html.DisplayFor(modelItem => item.Stuid) + @Html.DisplayFor(modelItem => item.Stuid) @Html.DisplayFor(modelItem => item.Sex) @@ -135,9 +135,9 @@ @Html.DisplayFor(modelItem => item.RegisterTime) - 编辑资料 | - 审阅 | - 删除 + 编辑资料 | + 审阅 | + 删除 } diff --git a/Pages/Submissions/Create.cshtml.cs b/Pages/Submissions/Create.cshtml.cs index f53e03b..4b010a1 100644 --- a/Pages/Submissions/Create.cshtml.cs +++ b/Pages/Submissions/Create.cshtml.cs @@ -37,7 +37,7 @@ namespace _2021_backend.Pages.Submissions { stu = Student.create(Submission); stu.Status = status.刚报名; - var q2 = from e in Context.Sessions select e.Guid; + var q2 = from e in Context.Sessions select e.Id; var lst = q2.ToList(); stu.Timelist = lst; Context.Students.Add(stu); @@ -47,7 +47,7 @@ namespace _2021_backend.Pages.Submissions stu = q.FirstOrDefault(); stu.Update(Submission); } - Submission.Host = stu.Guid; + Submission.Host = stu.Id; Context.Submissions.Add(Submission); Context.SaveChanges(); diff --git a/Pages/Submissions/Delete.cshtml b/Pages/Submissions/Delete.cshtml index cb753f2..0f9a77c 100644 --- a/Pages/Submissions/Delete.cshtml +++ b/Pages/Submissions/Delete.cshtml @@ -69,8 +69,8 @@ - - | + + | 返回列表
diff --git a/Pages/Submissions/Delete.cshtml.cs b/Pages/Submissions/Delete.cshtml.cs index 27de9ec..f62b518 100644 --- a/Pages/Submissions/Delete.cshtml.cs +++ b/Pages/Submissions/Delete.cshtml.cs @@ -24,12 +24,12 @@ namespace _2021_backend.Pages.Submissions public async Task OnGetAsync(string? strid) { - Guid id = Guid.Parse(strid); + int id = int.Parse(strid); if (id == null) { return NotFound(); } - Submission = Context.Submissions.FirstOrDefault(m => m.Guid == id); + Submission = Context.Submissions.FirstOrDefault(m => m.Id == id); if (Submission == null) { @@ -38,7 +38,7 @@ namespace _2021_backend.Pages.Submissions return Page(); } - public async Task OnPostAsync(Guid? id) + public async Task OnPostAsync(int? id) { if (id == null) { @@ -51,7 +51,7 @@ namespace _2021_backend.Pages.Submissions var stu = Context.Students.Find(Submission.Host); if (stu != null) { - stu.Submissions.Remove(Submission.Guid); + stu.Submissions.Remove(Submission.Id); } Context.Submissions.Remove(Submission); Context.SaveChanges(); diff --git a/Pages/Submissions/Details.cshtml b/Pages/Submissions/Details.cshtml index 83f7bbd..fb0b873 100644 --- a/Pages/Submissions/Details.cshtml +++ b/Pages/Submissions/Details.cshtml @@ -74,6 +74,6 @@
diff --git a/Pages/Submissions/Details.cshtml.cs b/Pages/Submissions/Details.cshtml.cs index a4542c0..706b016 100644 --- a/Pages/Submissions/Details.cshtml.cs +++ b/Pages/Submissions/Details.cshtml.cs @@ -28,8 +28,8 @@ namespace _2021_backend.Pages.Submissions { return NotFound(); } - Guid id = Guid.Parse(strid); - Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Guid == id); + int id = int.Parse(strid); + Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Id == id); if (Submission == null) { diff --git a/Pages/Submissions/Edit.cshtml b/Pages/Submissions/Edit.cshtml index bf2b0b6..61a2a89 100644 --- a/Pages/Submissions/Edit.cshtml +++ b/Pages/Submissions/Edit.cshtml @@ -13,7 +13,7 @@
- +
diff --git a/Pages/Submissions/Edit.cshtml.cs b/Pages/Submissions/Edit.cshtml.cs index fb5fc6e..d497d99 100644 --- a/Pages/Submissions/Edit.cshtml.cs +++ b/Pages/Submissions/Edit.cshtml.cs @@ -25,13 +25,13 @@ namespace _2021_backend.Pages.Submissions public async Task OnGetAsync(string? strid) { - Guid id = Guid.Parse(strid); + int id = int.Parse(strid); if (id == null) { return NotFound(); } - Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Guid == id); + Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Id == id); if (Submission == null) { @@ -57,7 +57,7 @@ namespace _2021_backend.Pages.Submissions } catch (DbUpdateConcurrencyException) { - if (!SubmissionExists(Submission.Guid)) + if (!SubmissionExists(Submission.Id)) { return NotFound(); } @@ -70,9 +70,9 @@ namespace _2021_backend.Pages.Submissions return RedirectToPage("./Index"); } - private bool SubmissionExists(Guid id) + private bool SubmissionExists(int id) { - return Context.Submissions.Any(e => e.Guid == id); + return Context.Submissions.Any(e => e.Id == id); } } } diff --git a/Pages/Submissions/Index.cshtml b/Pages/Submissions/Index.cshtml index 10a4098..cfa8b7b 100644 --- a/Pages/Submissions/Index.cshtml +++ b/Pages/Submissions/Index.cshtml @@ -75,9 +75,9 @@ @Html.DisplayFor(modelItem => item.SubmitTime) - 编辑 | - 详细信息 | - 删除 + 编辑 | + 详细信息 | + 删除 } diff --git a/Pages/Users/Delete.cshtml b/Pages/Users/Delete.cshtml index d09d940..d452af3 100644 --- a/Pages/Users/Delete.cshtml +++ b/Pages/Users/Delete.cshtml @@ -34,7 +34,7 @@ - + | Back to List diff --git a/Pages/Users/Delete.cshtml.cs b/Pages/Users/Delete.cshtml.cs index 53784ef..963e68e 100644 --- a/Pages/Users/Delete.cshtml.cs +++ b/Pages/Users/Delete.cshtml.cs @@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Users public async Task OnGetAsync(string id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - User = _context.Users.Find(guid); + User = _context.Users.Find(idx); if (User == null) { @@ -41,13 +41,13 @@ namespace _2021_backend.Pages.Users public async Task OnPostAsync(string id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - User = _context.Users.Find(id); + User = _context.Users.Find(idx); if (User != null) { diff --git a/Pages/Users/Details.cshtml b/Pages/Users/Details.cshtml index 639c99d..10abdb1 100644 --- a/Pages/Users/Details.cshtml +++ b/Pages/Users/Details.cshtml @@ -38,6 +38,6 @@
diff --git a/Pages/Users/Details.cshtml.cs b/Pages/Users/Details.cshtml.cs index 7967d2b..54b2f17 100644 --- a/Pages/Users/Details.cshtml.cs +++ b/Pages/Users/Details.cshtml.cs @@ -23,13 +23,13 @@ namespace _2021_backend.Pages.Users public async Task OnGetAsync(string id) { - Guid guid = Guid.Parse(id); + int idx = int.Parse(id); if (id == null) { return NotFound(); } - User = _context.Users.Find(guid); + User = _context.Users.Find(idx); if (User == null) { diff --git a/Pages/Users/Edit.cshtml b/Pages/Users/Edit.cshtml index 873edec..eb2027f 100644 --- a/Pages/Users/Edit.cshtml +++ b/Pages/Users/Edit.cshtml @@ -13,7 +13,7 @@
- +
diff --git a/Pages/Users/Edit.cshtml.cs b/Pages/Users/Edit.cshtml.cs index 8bf2423..cf1fdbb 100644 --- a/Pages/Users/Edit.cshtml.cs +++ b/Pages/Users/Edit.cshtml.cs @@ -31,8 +31,8 @@ namespace _2021_backend.Pages.Users { return NotFound(); } - Guid guid = Guid.Parse(id); - USER = _context.Users.Find(guid); + int idx = int.Parse(id); + USER = _context.Users.Find(idx); if (USER == null) { @@ -52,12 +52,12 @@ namespace _2021_backend.Pages.Users return Page(); } if (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).CountAsync() > 0 - && (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).FirstOrDefaultAsync()).Guid != USER.Guid + && (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).FirstOrDefaultAsync()).Id != USER.Id ) return new ConflictResult(); if (USER.Secret == null || USER.Secret == String.Empty) { - var user = await _context.Users.AsNoTracking().Where(u => u.Guid == USER.Guid).FirstOrDefaultAsync(); + var user = await _context.Users.AsNoTracking().Where(u => u.Id == USER.Id).FirstOrDefaultAsync(); user.Name = USER.Name; user.stuID = USER.stuID; user.isManager = USER.isManager; @@ -65,7 +65,7 @@ namespace _2021_backend.Pages.Users } else { - var user = await _context.Users.AsNoTracking().Where(u => u.Guid == USER.Guid).FirstOrDefaultAsync(); + var user = await _context.Users.AsNoTracking().Where(u => u.Id == USER.Id).FirstOrDefaultAsync(); user.Name = USER.Name; user.stuID = USER.stuID; user.isManager = USER.isManager; @@ -80,7 +80,7 @@ namespace _2021_backend.Pages.Users } catch (DbUpdateConcurrencyException) { - if (!UserExists(USER.Guid)) + if (!UserExists(USER.Id)) { return NotFound(); } @@ -93,9 +93,9 @@ namespace _2021_backend.Pages.Users return RedirectToPage("./Index"); } - private bool UserExists(Guid id) + private bool UserExists(int id) { - return _context.Users.Any(e => e.Guid == id); + return _context.Users.Any(e => e.Id == id); } } } diff --git a/Pages/Users/Index.cshtml b/Pages/Users/Index.cshtml index 09063d7..d536283 100644 --- a/Pages/Users/Index.cshtml +++ b/Pages/Users/Index.cshtml @@ -40,9 +40,9 @@ @Html.DisplayFor(modelItem => item.isManager) - Edit | - Details | - Delete + Edit | + Details | + Delete } diff --git a/Program.cs b/Program.cs index 4882998..0ed0c14 100644 --- a/Program.cs +++ b/Program.cs @@ -16,6 +16,8 @@ namespace _2021_backend { public static void Main(string[] args) { + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { @@ -33,7 +35,7 @@ namespace _2021_backend { var botusr = new User(); botusr.Name = botname; - botusr.Guid = Guid.NewGuid(); + botusr.Id = 0; botusr.isManager = true; botusr.Secret = config["SMSBOT_SECRET"]; botusr.stuID = config["SMSBOT_STUID"]; @@ -45,19 +47,19 @@ namespace _2021_backend User.Bot = q.FirstOrDefault(); //do nothing cause I 've already got a bot } - var id = Guid.Parse("4c20c535-3661-40c7-b4db-ce479675bbd7"); - while (context.Users.Any(e => e.Guid == id)) + var id = int.Parse("4c20c535-3661-40c7-b4db-ce479675bbd7"); + while (context.Users.Any(e => e.Id == id)) { context.Users.Remove(context.Users.Find(id)); context.SaveChanges(); } var usr = new User(); - usr.Guid = id; + usr.Id = id; usr.Name = config["ADMIN_USERNAME"]; usr.isManager = true; usr.Secret = EvaCryptoHelper.Password2Secret(config["ADMIN_PASSWORD"]); usr.stuID = "zjueva"; - Console.WriteLine(usr.Guid.ToString()); + Console.WriteLine(usr.Id.ToString()); context.Users.Add(usr); context.SaveChanges(); } diff --git a/Utils/Arranger.cs b/Utils/Arranger.cs index 80bcff9..48ea55a 100644 --- a/Utils/Arranger.cs +++ b/Utils/Arranger.cs @@ -24,12 +24,12 @@ namespace _2021_backend.Utils var capb = 0; foreach (var tm in a.Timelist) { - var t = sessions.Find(x => x.Guid == tm); + var t = sessions.Find(x => x.Id == tm); capa += t.Capacity - t.Students.Count; } foreach (var tm in b.Timelist) { - var t = sessions.Find(x => x.Guid == tm); + var t = sessions.Find(x => x.Id == tm); capb += t.Capacity - t.Students.Count; } return capa - capb; @@ -43,7 +43,7 @@ namespace _2021_backend.Utils var tmstr = ""; foreach (var tm in st.Timelist) { - var t = sessions.Find(x => x.Guid == tm); + var t = sessions.Find(x => x.Id == tm); cap += t.Capacity - t.Students.Count; tmstr += t.Day.ToString("dd") + "-" + t.BeginTime.ToString("HH:mm-") + t.Place + " "; } @@ -61,7 +61,7 @@ namespace _2021_backend.Utils var lst = students[m].Timelist; var stu = students[m]; - if (stu.Timelist.Contains(stu.InterviewTime) || stu.Timelist.Count() == 0 || stu.InterviewTime != Guid.Empty || stu.Status != status.已选时间) + if (stu.Timelist.Contains(stu.InterviewTime) || stu.Timelist.Count() == 0 || stu.InterviewTime != 0 || stu.Status != status.已选时间) { return m >= students.Count - 1 ? true : DFS(m + 1); @@ -71,21 +71,21 @@ namespace _2021_backend.Utils var tm = Context.Sessions.Find(stu.InterviewTime); if (tm != null) { - tm.Students.RemoveAll(it => it == stu.Guid); + tm.Students.RemoveAll(it => it == stu.Id); } - stu.InterviewTime = Guid.Empty; + stu.InterviewTime = 0; } bool depth = false; foreach (var i in lst) { - var tm = sessions.Find(s => s.Guid == i); + var tm = sessions.Find(s => s.Id == i); if (tm.Students.Count < tm.Capacity && tm.Day.CompareTo(DateTime.Now.AddHours(-14)) > 0) { status prev = students[m].Status; - Guid prevs = students[m].InterviewTime; + int prevs = students[m].InterviewTime; students[m].Status = status.已选时间; - students[m].InterviewTime = tm.Guid; - tm.Students.Add(students[m].Guid); + students[m].InterviewTime = tm.Id; + tm.Students.Add(students[m].Id); if (m == students.Count - 1) { return true; @@ -97,7 +97,7 @@ namespace _2021_backend.Utils { students[m].Status = prev; students[m].InterviewTime = prevs; - tm.Students.Remove(students[m].Guid); + tm.Students.Remove(students[m].Id); continue; } else return true; diff --git a/Utils/TencentSMS.cs b/Utils/TencentSMS.cs index 5141908..4227641 100644 --- a/Utils/TencentSMS.cs +++ b/Utils/TencentSMS.cs @@ -80,9 +80,9 @@ namespace _2021_backend.Utils var lst = obj.PullSmsReplyStatusSet; foreach (var item in lst) { - var msg = new SMS(item, stu.Guid); + var msg = new SMS(item, stu.Id); Context.Add(msg); - stu.Messages.Add(msg.Guid); + stu.Messages.Add(msg.Id); } Context.SaveChanges(); return true; @@ -114,7 +114,7 @@ namespace _2021_backend.Utils req.PhoneNumberSet[0] = "+86" + stu.Tel; req.SmsSdkAppId = SMS_appid; req.SignName = "ZJUEVA"; - Guid index = stu.InterviewTime; + int index = stu.InterviewTime; SMS sms = new SMS(); switch (type) { @@ -135,7 +135,7 @@ namespace _2021_backend.Utils break; case SMSType.TimeSet: sms.Type = SMSType.TimeSet; - var q = from e in Context.Sessions where e.Guid == index select e; + var q = from e in Context.Sessions where e.Id == index select e; var time = await q.FirstOrDefaultAsync(); req.TemplateParamSet = new string[] { stu.Name, time.Day.ToString("dd") ,time.BeginTime.ToString("HH"),time.BeginTime.ToString("mm"), time.BeginTime.AddHours(1).ToString("HH") ,time.BeginTime.AddMinutes(30).ToString("mm")}; req.TemplateId = SMSID_timeSet; @@ -147,7 +147,7 @@ namespace _2021_backend.Utils break; } sms.Tel = stu.Tel; - sms.Host = stu.Guid; + sms.Host = stu.Id; var query = from e in Context.Users where e.stuID == sender select e; var usr = await query.FirstOrDefaultAsync(); sms.Sender = usr == null ? "null" : usr.Name;