removed migration ,altered Guid to int

master
ceruIean 2022-02-22 17:14:10 +08:00
parent 166821a52e
commit e0115e0e07
48 changed files with 559 additions and 505 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>_2021_backend</RootNamespace>
<UserSecretsId>2023ab1c-9547-4989-a343-cd3428e085fe</UserSecretsId>
<StartupObject>_2021_backend.Program</StartupObject>
@ -19,21 +19,25 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="itext7" Version="7.1.16" />
<PackageReference Include="itext7" Version="7.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.2" />
<PackageReference Include="Nancy" Version="2.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
<PackageReference Include="NPOI" Version="2.5.4" />
<PackageReference Include="TencentCloudSDK" Version="3.0.362" />
<PackageReference Include="NPOI" Version="2.5.5" />
<PackageReference Include="TencentCloudSDK" Version="3.0.464" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View File

@ -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<Guid> { targetSession};
targetSession = s.Id;
s.Students.Add(stu.Id);
stu.Timelist = new List<int> { 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"));

View File

@ -19,15 +19,15 @@ namespace _2021_backend.Data
protected override void OnModelCreating(ModelBuilder mb)
{
mb.Entity<Submission>()
.HasKey(r => r.Guid);
.HasKey(r => r.Id);
mb.Entity<User>()
.HasKey(u => u.Guid);
.HasKey(u => u.Id);
mb.Entity<Comment>()
.HasKey(u => u.Guid);
.HasKey(u => u.Id);
mb.Entity<Session>()
.HasKey(u => u.Guid);
.HasKey(u => u.Id);
mb.Entity<SMS>()
.HasKey(u => u.Guid);
.HasKey(u => u.Id);
}
}
}

View File

@ -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>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("AddTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("Operator")
.HasColumnType("uuid");
b.Property<int>("Operator")
.HasColumnType("integer");
b.Property<Guid>("Student")
.HasColumnType("uuid");
b.Property<int>("Student")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("Comments");
});
modelBuilder.Entity("_2021_backend.Models.Session", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("BeginTime")
.HasColumnType("timestamp with time zone");
b.Property<int>("Capacity")
.HasColumnType("integer");
b.Property<List<int>>("Chiefs")
.HasColumnType("integer[]");
b.Property<DateTime>("Day")
.HasColumnType("timestamp with time zone");
b.Property<string>("Place")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("SendSMS")
.HasColumnType("boolean");
b.Property<List<int>>("Students")
.HasColumnType("integer[]");
b.HasKey("Id");
b.ToTable("Sessions");
});
modelBuilder.Entity("_2021_backend.Models.SMS", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<string>>("Data")
.HasColumnType("text[]");
b.Property<Guid>("Host")
.HasColumnType("uuid");
b.Property<int>("Host")
.HasColumnType("integer");
b.Property<DateTime>("SendTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Sender")
.HasColumnType("text");
@ -70,52 +112,21 @@ namespace _2021_backend.Migrations
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("SMS");
});
modelBuilder.Entity("_2021_backend.Models.Session", b =>
{
b.Property<Guid>("Guid")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BeginTime")
.HasColumnType("timestamp without time zone");
b.Property<int>("Capacity")
.HasColumnType("integer");
b.Property<List<Guid>>("Chiefs")
.HasColumnType("uuid[]");
b.Property<DateTime>("Day")
.HasColumnType("timestamp without time zone");
b.Property<string>("Place")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("SendSMS")
.HasColumnType("boolean");
b.Property<List<Guid>>("Students")
.HasColumnType("uuid[]");
b.HasKey("Guid");
b.ToTable("Sessions");
});
modelBuilder.Entity("_2021_backend.Models.Student", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
b.Property<List<Guid>>("Comments")
.HasColumnType("uuid[]");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<int>>("Comments")
.HasColumnType("integer[]");
b.Property<string>("Email")
.HasColumnType("text");
@ -126,23 +137,23 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade")
.HasColumnType("integer");
b.Property<Guid>("InterviewTime")
.HasColumnType("uuid");
b.Property<int>("InterviewTime")
.HasColumnType("integer");
b.Property<DateTime>("LastSubmission")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Major")
.HasColumnType("text");
b.Property<List<Guid>>("Messages")
.HasColumnType("uuid[]");
b.Property<List<int>>("Messages")
.HasColumnType("integer[]");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<DateTime>("RegisterTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<int>("Score")
.HasColumnType("integer");
@ -156,28 +167,30 @@ namespace _2021_backend.Migrations
b.Property<string>("Stuid")
.HasColumnType("text");
b.Property<List<Guid>>("Submissions")
.HasColumnType("uuid[]");
b.Property<List<int>>("Submissions")
.HasColumnType("integer[]");
b.Property<string>("Tel")
.HasColumnType("text");
b.Property<List<Guid>>("Timelist")
.HasColumnType("uuid[]");
b.Property<List<int>>("Timelist")
.HasColumnType("integer[]");
b.Property<int>("Yard")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("Students");
});
modelBuilder.Entity("_2021_backend.Models.Submission", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text");
@ -191,8 +204,8 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade")
.HasColumnType("integer");
b.Property<Guid>("Host")
.HasColumnType("uuid");
b.Property<int>("Host")
.HasColumnType("integer");
b.Property<string>("Major")
.HasColumnType("text");
@ -207,27 +220,29 @@ namespace _2021_backend.Migrations
.HasColumnType("text");
b.Property<DateTime>("SubmitTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Tel")
.HasColumnType("text");
b.Property<List<Guid>>("Timelist")
.HasColumnType("uuid[]");
b.Property<List<int>>("Timelist")
.HasColumnType("integer[]");
b.Property<int>("Yard")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("Submissions");
});
modelBuilder.Entity("_2021_backend.Models.User", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.HasColumnType("text");
@ -241,7 +256,7 @@ namespace _2021_backend.Migrations
b.Property<string>("stuID")
.HasColumnType("text");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("Users");
});

View File

@ -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<Guid>(type: "uuid", nullable: false),
Operator = table.Column<Guid>(type: "uuid", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Operator = table.Column<int>(type: "integer", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
AddTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Student = table.Column<Guid>(type: "uuid", nullable: false)
AddTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Student = table.Column<int>(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<Guid>(type: "uuid", nullable: false),
Day = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
BeginTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Day = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
BeginTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Place = table.Column<string>(type: "text", nullable: false),
Chiefs = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
Chiefs = table.Column<List<int>>(type: "integer[]", nullable: true),
Capacity = table.Column<int>(type: "integer", nullable: false),
SendSMS = table.Column<bool>(type: "boolean", nullable: false),
Students = table.Column<List<Guid>>(type: "uuid[]", nullable: true)
Students = table.Column<List<int>>(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<Guid>(type: "uuid", nullable: false),
Host = table.Column<Guid>(type: "uuid", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Host = table.Column<int>(type: "integer", nullable: false),
Tel = table.Column<string>(type: "text", nullable: true),
Data = table.Column<List<string>>(type: "text[]", nullable: true),
Type = table.Column<int>(type: "integer", nullable: false),
Sender = table.Column<string>(type: "text", nullable: true),
SendTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
SendTime = table.Column<DateTime>(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<Guid>(type: "uuid", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: true),
Stuid = table.Column<string>(type: "text", nullable: true),
Sex = table.Column<int>(type: "integer", nullable: false),
@ -72,27 +79,28 @@ namespace _2021_backend.Migrations
Email = table.Column<string>(type: "text", nullable: true),
Tel = table.Column<string>(type: "text", nullable: true),
Exp = table.Column<int>(type: "integer", nullable: false),
InterviewTime = table.Column<Guid>(type: "uuid", nullable: false),
Submissions = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
Messages = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
Timelist = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
Comments = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
InterviewTime = table.Column<int>(type: "integer", nullable: false),
Submissions = table.Column<List<int>>(type: "integer[]", nullable: true),
Messages = table.Column<List<int>>(type: "integer[]", nullable: true),
Timelist = table.Column<List<int>>(type: "integer[]", nullable: true),
Comments = table.Column<List<int>>(type: "integer[]", nullable: true),
Score = table.Column<int>(type: "integer", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
LastSubmission = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
RegisterTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
LastSubmission = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
RegisterTime = table.Column<DateTime>(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<Guid>(type: "uuid", nullable: false),
Host = table.Column<Guid>(type: "uuid", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Host = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
Stuid = table.Column<string>(type: "text", nullable: true),
Sex = table.Column<int>(type: "integer", nullable: false),
@ -102,20 +110,21 @@ namespace _2021_backend.Migrations
Email = table.Column<string>(type: "text", nullable: true),
Tel = table.Column<string>(type: "text", nullable: true),
Exp = table.Column<int>(type: "integer", nullable: false),
Timelist = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
Timelist = table.Column<List<int>>(type: "integer[]", nullable: true),
Address = table.Column<string>(type: "text", nullable: true),
SubmitTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
SubmitTime = table.Column<DateTime>(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<Guid>(type: "uuid", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
stuID = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: true),
Secret = table.Column<string>(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);
});
}

View File

@ -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>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("AddTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("Operator")
.HasColumnType("uuid");
b.Property<int>("Operator")
.HasColumnType("integer");
b.Property<Guid>("Student")
.HasColumnType("uuid");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("BeginTime")
.HasColumnType("timestamp with time zone");
b.Property<int>("Capacity")
.HasColumnType("integer");
b.Property<List<int>>("Chiefs")
.HasColumnType("integer[]");
b.Property<DateTime>("Day")
.HasColumnType("timestamp with time zone");
b.Property<string>("Place")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("SendSMS")
.HasColumnType("boolean");
b.Property<List<int>>("Students")
.HasColumnType("integer[]");
b.HasKey("Id");
b.ToTable("Sessions", (string)null);
});
modelBuilder.Entity("_2021_backend.Models.SMS", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<string>>("Data")
.HasColumnType("text[]");
b.Property<Guid>("Host")
.HasColumnType("uuid");
b.Property<int>("Host")
.HasColumnType("integer");
b.Property<DateTime>("SendTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Sender")
.HasColumnType("text");
@ -68,52 +110,21 @@ namespace _2021_backend.Migrations
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("SMS");
});
modelBuilder.Entity("_2021_backend.Models.Session", b =>
{
b.Property<Guid>("Guid")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BeginTime")
.HasColumnType("timestamp without time zone");
b.Property<int>("Capacity")
.HasColumnType("integer");
b.Property<List<Guid>>("Chiefs")
.HasColumnType("uuid[]");
b.Property<DateTime>("Day")
.HasColumnType("timestamp without time zone");
b.Property<string>("Place")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("SendSMS")
.HasColumnType("boolean");
b.Property<List<Guid>>("Students")
.HasColumnType("uuid[]");
b.HasKey("Guid");
b.ToTable("Sessions");
b.ToTable("SMS", (string)null);
});
modelBuilder.Entity("_2021_backend.Models.Student", b =>
{
b.Property<Guid>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
b.Property<List<Guid>>("Comments")
.HasColumnType("uuid[]");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<int>>("Comments")
.HasColumnType("integer[]");
b.Property<string>("Email")
.HasColumnType("text");
@ -124,23 +135,23 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade")
.HasColumnType("integer");
b.Property<Guid>("InterviewTime")
.HasColumnType("uuid");
b.Property<int>("InterviewTime")
.HasColumnType("integer");
b.Property<DateTime>("LastSubmission")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Major")
.HasColumnType("text");
b.Property<List<Guid>>("Messages")
.HasColumnType("uuid[]");
b.Property<List<int>>("Messages")
.HasColumnType("integer[]");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<DateTime>("RegisterTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<int>("Score")
.HasColumnType("integer");
@ -154,28 +165,30 @@ namespace _2021_backend.Migrations
b.Property<string>("Stuid")
.HasColumnType("text");
b.Property<List<Guid>>("Submissions")
.HasColumnType("uuid[]");
b.Property<List<int>>("Submissions")
.HasColumnType("integer[]");
b.Property<string>("Tel")
.HasColumnType("text");
b.Property<List<Guid>>("Timelist")
.HasColumnType("uuid[]");
b.Property<List<int>>("Timelist")
.HasColumnType("integer[]");
b.Property<int>("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>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text");
@ -189,8 +202,8 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade")
.HasColumnType("integer");
b.Property<Guid>("Host")
.HasColumnType("uuid");
b.Property<int>("Host")
.HasColumnType("integer");
b.Property<string>("Major")
.HasColumnType("text");
@ -205,27 +218,29 @@ namespace _2021_backend.Migrations
.HasColumnType("text");
b.Property<DateTime>("SubmitTime")
.HasColumnType("timestamp without time zone");
.HasColumnType("timestamp with time zone");
b.Property<string>("Tel")
.HasColumnType("text");
b.Property<List<Guid>>("Timelist")
.HasColumnType("uuid[]");
b.Property<List<int>>("Timelist")
.HasColumnType("integer[]");
b.Property<int>("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>("Guid")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.HasColumnType("text");
@ -239,9 +254,9 @@ namespace _2021_backend.Migrations
b.Property<string>("stuID")
.HasColumnType("text");
b.HasKey("Guid");
b.HasKey("Id");
b.ToTable("Users");
b.ToTable("Users", (string)null);
});
#pragma warning restore 612, 618
}

View File

@ -11,30 +11,31 @@ namespace _2021_backend.Models
{
public Comment()
{
Guid = Guid.NewGuid();
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;
}

View File

@ -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<string> { };
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<string> 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)]

View File

@ -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<Guid> Chiefs { get; set; }
public List<int> 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<Guid> Students { get; set; }
public List<int> Students { get; set; }
}
public class SessionDto
@ -57,7 +58,7 @@ namespace _2021_backend.Models
public class SessionDtoComparer : IEqualityComparer<SessionDto>
{
#region IEqualityComparer<user> Members
public bool Equals(SessionDto a,SessionDto b)
public bool Equals(SessionDto a, SessionDto b)
{
return a.Day == b.Day && a.BeginTime == b.BeginTime;
}

View File

@ -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;
@ -65,21 +66,21 @@ namespace _2021_backend.Models
Yard = sub.Yard;
Exp = sub.Exp;
Timelist = sub.Timelist;
Submissions.Add(sub.Guid);
Submissions.Add(sub.Id);
}
public Student()
{
Guid = Guid.NewGuid();
Comments = new List<Guid>();
Messages = new List<Guid>();
Submissions = new List<Guid>();
Timelist = new List<Guid>();
Id = 0;
Comments = new List<int>();
Messages = new List<int>();
Submissions = new List<int>();
Timelist = new List<int>();
}
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 = "学号")]
@ -116,18 +118,18 @@ 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<Guid> Submissions { get; set; }
public List<int> Submissions { get; set; }
[Display(Name = "短信记录")]
public List<Guid> Messages { get; set; }
public List<int> Messages { get; set; }
[Display(Name = "可选场次")]
public List<Guid> Timelist { get; set; }
public List<int> Timelist { get; set; }
[Display(Name = "评论")]
public List<Guid> Comments { get; set; }
public List<int> Comments { get; set; }
[Display(Name = "打分")]
public int Score { get; set; }

View File

@ -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>();
Guid = System.Guid.NewGuid();
Timelist = new List<int>();
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<Guid> Timelist { get; set; }
[Display(Name ="Ip Address")]
public string Address { get; set; }
public List<int> 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,7 +72,7 @@ namespace _2021_backend.Models
}
public class TimeSpec
{
public DateTime Day { get; set; }
public DateTime Day { get; set; }
public DateTime BeginTime { get; set; }
}
@ -96,7 +99,7 @@ namespace _2021_backend.Models
[Required()]
public int Exp { get; set; }
[Required()]
public List<TimeSpec> Timelist { get; set; }
public List<TimeSpec> 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;

View File

@ -15,32 +15,32 @@ namespace _2021_backend.Models
{
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;
}

View File

@ -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)
{

View File

@ -42,10 +42,10 @@ namespace _2021_backend.Pages.Message
public IActionResult Construct(int PageId)
{
List<Guid> stus;
IQueryable<Guid> 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<int> stus;
IQueryable<int> 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.;
}
}

View File

@ -22,7 +22,7 @@ namespace _2021_backend.Pages.Sessions
[BindProperty]
[Display(Name = "活动官")]
public string ChiefGuid { get; set; }
public string Chiefint { get; set; }
public List<SelectListItem> ChiefList { get; set; }
@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> 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<Guid>();
InterviewTime.Chiefs = new List<Guid>();
InterviewTime.Students = new List<int>();
InterviewTime.Chiefs = new List<int>();
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<Guid>(),
Chiefs = new List<int>(),
SendSMS = InterviewTime.SendSMS,
Students = new List<Guid>(),
Students = new List<int>(),
Capacity = InterviewTime.Capacity
};
Context.Add(interviewTimeSecond);

View File

@ -34,7 +34,7 @@
</dl>
<form method="post">
<input type="hidden" asp-for="InterviewTime.Guid" />
<input type="hidden" asp-for="InterviewTime.Id" />
<input type="submit" value="确定删除" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>

View File

@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> 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<IActionResult> 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();

View File

@ -64,6 +64,6 @@
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Guid">Edit</a> |
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -23,12 +23,12 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> 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();

View File

@ -13,8 +13,8 @@
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="CurSession.Guid" />
<input type="hidden" asp-for="CurGuid">
<input type="hidden" asp-for="CurSession.Id" />
<input type="hidden" asp-for="Curint">
<div class="form-group">
<label asp-for="newDay" class="control-label"></label>
<input asp-for="newDay" class="form-control" />
@ -51,7 +51,7 @@
<form method="post">
<label class="col-sm-2">添加一个</label>
<select asp-items=Model.Stulist id="stuselect" asp-for="addedStu" class="col-sm-2"></select>
<input type="hidden" asp-for="CurGuid" />
<input type="hidden" asp-for="Curint" />
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="Add" />
</form>
<br />
@ -76,11 +76,11 @@
<td>@Html.DisplayFor(model=>stu.Name)</td>
<td>
<a asp-page="/Students/Details" asp-route-idstr=@stu.Guid.ToString() class="btn btn-primary">详细信息</a>
<a asp-page="/Students/Details" asp-route-idstr=@stu.Id.ToString() class="btn btn-primary">详细信息</a>
<div style="float:left">
<form method="post">
<input type="hidden" asp-for="CurGuid">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Guid.ToString() />
<input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Id.ToString() />
</form>
</div>
@ -98,7 +98,7 @@
<form method="post">
<label class="col-sm-2">添加一个</label>
<select id="chiefselect"asp-items=Model.ChiefList asp-for="addedChief" class="col-sm-2"></select>
<input type="hidden" asp-for="CurGuid" />
<input type="hidden" asp-for="Curint" />
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="AddChief" />
</form>
<br />
@ -121,8 +121,8 @@
<td>
<div style="float:left">
<form method="post">
<input type="hidden" asp-for="CurGuid">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Guid.ToString() />
<input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Id.ToString() />
</form>
</div>
</td>

View File

@ -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<SelectListItem> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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);
}
}
}

View File

@ -157,9 +157,9 @@
}
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Guid">编辑</a> |
<a asp-page="./Delete" asp-route-id="@item.Guid">删除</a> |
<a asp-page-handler="Reset" asp-route-id="@item.Guid">重置</a>
<a asp-page="./Edit" asp-route-id="@item.Id">编辑</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">删除</a> |
<a asp-page-handler="Reset" asp-route-id="@item.Id">重置</a>
</td>
</tr>
}

View File

@ -89,16 +89,16 @@ namespace _2021_backend.Pages.Sessions
return Construct(errmsg);
}
public async Task<IActionResult> OnGetResetAsync(Guid id)
public async Task<IActionResult> 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<Session>();
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<Guid> nl = new List<Guid>();
List<int> nl = new List<int>();
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<Guid>();
s.Students = new List<int>();
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);
}
}

View File

@ -75,7 +75,7 @@
</dl>
<form method="post">
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<input type="submit" value="删除" class="btn btn-danger" /> |
<a asp-page="./Index">返回列表</a>
</form>

View File

@ -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);

View File

@ -70,7 +70,7 @@
<h5>此人的最终得分 @Html.DisplayFor(model => model.Student.Score)</h5>
<form method="post" class="form-inline m-2">
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<div class="mb-2">
操作
</div>
@ -131,7 +131,7 @@
<span asp-validation-for="NewComment" class="text-danger"></span>
</div>
<div class="form-group">
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<input type="submit" value="→" class="btn btn-primary btn-sm" />
</div>
</form>
@ -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))
{
<tr>
<td>
@ -211,9 +211,9 @@
</td>
<td>
<form method="post" class="form-inline">
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<a asp-page="/Sessions/Edit" asp-route-id="@it.ToString()" class="btn btn-sm btn-primary">场次详情</a>
<input type="submit" asp-page-handler="Select" asp-route-stu="@Model.Student.Guid" asp-route-time="@it.ToString()" class="btn btn-sm btn-warning" value="选择这个" />
<input type="submit" asp-page-handler="Select" asp-route-stu="@Model.Student.Id" asp-route-time="@it.ToString()" class="btn btn-sm btn-warning" value="选择这个" />
</form>
</td>
</tr>
@ -225,7 +225,7 @@
Ta的短信
</h4>
<form method="post">
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<input type="submit" value="拉取5天内的回复短信" class="btn btn-primary" asp-page-handler="Pull" />
<input type="submit" value="发送报名确认短信" class="btn btn-primary" asp-page-handler="Sign" />
<input type="submit" value="发送活动场次确认短信" class="btn btn-primary" asp-page-handler="Time" />
@ -355,8 +355,8 @@
@Html.DisplayFor(modelItem => sub.SubmitTime)
</td>
<td>
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Guid">Edit</a> |
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Guid">Details</a>
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Id">Edit</a> |
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Id">Details</a>
</td>
</tr>
}
@ -366,6 +366,6 @@
<div>
<a asp-page="./Edit" asp-route-idstr="@Model.Student.Guid">编辑信息</a> |
<a asp-page="./Edit" asp-route-idstr="@Model.Student.Id">编辑信息</a> |
<a asp-page="./Index">返回列表</a>
</div>

View File

@ -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<IActionResult> 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<IActionResult> 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<IActionResult> OnPostSelectAsync(Guid stu, Guid time)
public async Task<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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());
}
}
}

View File

@ -13,7 +13,7 @@
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Student.Guid" />
<input type="hidden" asp-for="Student.Id" />
<div class="form-group">
<label asp-for="Student.Name" class="control-label"></label>
<input asp-for="Student.Name" class="form-control" />

View File

@ -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<IActionResult> 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);
}
}
}

View File

@ -105,10 +105,10 @@
}
</td>
<td>
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Name)</a>
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()"> @Html.DisplayFor(modelItem => item.Name)</a>
</td>
<td>
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Stuid)</a>
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()"> @Html.DisplayFor(modelItem => item.Stuid)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Sex)
@ -135,9 +135,9 @@
@Html.DisplayFor(modelItem => item.RegisterTime)
</th>
<td>
<a asp-page="./Edit" asp-route-idstr="@item.Guid.ToString()">编辑资料</a> |
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()">审阅</a> |
<a asp-page="./Delete" asp-route-idstr="@item.Guid.ToString()">删除</a>
<a asp-page="./Edit" asp-route-idstr="@item.Id.ToString()">编辑资料</a> |
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()">审阅</a> |
<a asp-page="./Delete" asp-route-idstr="@item.Id.ToString()">删除</a>
</td>
</tr>
}

View File

@ -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();

View File

@ -69,8 +69,8 @@
</dl>
<form method="post">
<input type="hidden" asp-for="Submission.Guid" />
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Guid.ToString()"/> |
<input type="hidden" asp-for="Submission.Id" />
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Id.ToString()"/> |
<a asp-page="./Index">返回列表</a>
</form>
</div>

View File

@ -24,12 +24,12 @@ namespace _2021_backend.Pages.Submissions
public async Task<IActionResult> 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<IActionResult> OnPostAsync(Guid? id)
public async Task<IActionResult> 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();

View File

@ -74,6 +74,6 @@
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.Submission.Guid">Edit</a> |
<a asp-page="./Edit" asp-route-id="@Model.Submission.Id">Edit</a> |
<a asp-page="./Index">返回列表</a>
</div>

View File

@ -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)
{

View File

@ -13,7 +13,7 @@
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Submission.Guid" />
<input type="hidden" asp-for="Submission.Id" />
<div class="form-group">
<label asp-for="Submission.Name" class="control-label"></label>
<input asp-for="Submission.Name" class="form-control" />

View File

@ -25,13 +25,13 @@ namespace _2021_backend.Pages.Submissions
public async Task<IActionResult> 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);
}
}
}

View File

@ -75,9 +75,9 @@
@Html.DisplayFor(modelItem => item.SubmitTime)
</td>
<td>
<a asp-page="./Edit" asp-route-strid="@item.Guid.ToString()">编辑</a> |
<a asp-page="./Details" asp-route-strid="@item.Guid.ToString()">详细信息</a> |
<a asp-page="./Delete" asp-route-strid="@item.Guid.ToString()">删除</a>
<a asp-page="./Edit" asp-route-strid="@item.Id.ToString()">编辑</a> |
<a asp-page="./Details" asp-route-strid="@item.Id.ToString()">详细信息</a> |
<a asp-page="./Delete" asp-route-strid="@item.Id.ToString()">删除</a>
</td>
</tr>
}

View File

@ -34,7 +34,7 @@
</dl>
<form method="post">
<input type="hidden" asp-for="User.Guid" />
<input type="hidden" asp-for="User.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>

View File

@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Users
public async Task<IActionResult> 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<IActionResult> 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)
{

View File

@ -38,6 +38,6 @@
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.User.Guid">Edit</a> |
<a asp-page="./Edit" asp-route-id="@Model.User.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -23,13 +23,13 @@ namespace _2021_backend.Pages.Users
public async Task<IActionResult> 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)
{

View File

@ -13,7 +13,7 @@
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="USER.Guid" />
<input type="hidden" asp-for="USER.Id" />
<div class="form-group">
<label asp-for="USER.stuID" class="control-label"></label>
<input asp-for="USER.stuID" class="form-control" />

View File

@ -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);
}
}
}

View File

@ -40,9 +40,9 @@
@Html.DisplayFor(modelItem => item.isManager)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Guid">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Guid">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Guid">Delete</a>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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<SMS>(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;