Compare commits

..
17 Commits
Author SHA1 Message Date
ZhangJunyu 5530eb1bcf add command timeout
continuous-integration/drone/push Build is passing
2022-03-19 17:18:06 +08:00
ZhangJunyu 2077407958 timezone change
continuous-integration/drone/push Build is passing
2022-02-25 05:06:12 +08:00
ZhangJunyu c69d3e6a6c timezone fix
continuous-integration/drone/push Build is passing
2022-02-25 02:46:01 +08:00
ZhangJunyu 1210245660 change timezone
continuous-integration/drone/push Build is passing
2022-02-25 02:21:00 +08:00
ZhangJunyu 1cf453948b debug
continuous-integration/drone/push Build is passing
2022-02-25 02:13:29 +08:00
ZhangJunyu 10cbc27fd7 change message ID
continuous-integration/drone/push Build is passing
2022-02-24 22:04:07 +08:00
ZhangJunyu d509a43474 add admin account
continuous-integration/drone/push Build is passing
2022-02-23 17:48:19 +08:00
ZhangJunyu e847be3369 change title
continuous-integration/drone/push Build is passing
2022-02-23 17:26:33 +08:00
ZhangJunyu 8467200774 migrate into net6.0
continuous-integration/drone/push Build is passing
2022-02-23 17:20:32 +08:00
ZhangJunyu 772525a9b6 2022 jphd-3dprint
continuous-integration/drone/push Build is failing
2022-02-23 17:19:19 +08:00
ZhangJunyu e0115e0e07 removed migration ,altered Guid to int 2022-02-22 17:14:10 +08:00
ZhangJunyu 166821a52e change time duration to 1.5 hr
continuous-integration/drone/push Build is passing
2021-12-09 14:32:26 +08:00
ZhangJunyu a0975cf083 changed into single selection
continuous-integration/drone/push Build is passing
2021-12-09 14:23:20 +08:00
ZhangJunyu e6def6d600 change message
continuous-integration/drone/push Build is passing
2021-12-09 11:49:28 +08:00
ZhangJunyu b0f6b1b6c9 fix small bug
continuous-integration/drone/push Build is passing
2021-12-08 17:00:27 +08:00
ZhangJunyu 3dd8cc1a92 change message id
continuous-integration/drone/push Build is passing
2021-12-08 16:53:59 +08:00
ZhangJunyu a8717cd429 add final time information 2021-11-24 17:53:53 +08:00
56 changed files with 1289 additions and 709 deletions
+14 -10
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<RootNamespace>_2021_backend</RootNamespace> <RootNamespace>_2021_backend</RootNamespace>
<UserSecretsId>2023ab1c-9547-4989-a343-cd3428e085fe</UserSecretsId> <UserSecretsId>2023ab1c-9547-4989-a343-cd3428e085fe</UserSecretsId>
<StartupObject>_2021_backend.Program</StartupObject> <StartupObject>_2021_backend.Program</StartupObject>
@@ -19,21 +19,25 @@
</ItemGroup> </ItemGroup>
<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.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.9" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </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="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="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
<PackageReference Include="NPOI" Version="2.5.4" /> <PackageReference Include="NPOI" Version="2.5.5" />
<PackageReference Include="TencentCloudSDK" Version="3.0.362" /> <PackageReference Include="TencentCloudSDK" Version="3.0.464" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+147 -47
View File
@@ -7,20 +7,52 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Security.Cryptography;
namespace _2021_backend.Controllers namespace _2021_backend.Controllers
{ {
[Route("api/submit")]
[Route("api")]
public class SubmissionController : Controller public class SubmissionController : Controller
{ {
public BackendContext Context;
public BackendContext context;
public SubmissionController(BackendContext context) public SubmissionController(BackendContext context)
{ {
Context = context; this.context = context;
} }
[HttpPost]
public async Task<IActionResult> Post([FromForm] string dto) [HttpPost("checkCaptcha")]
public async Task<IActionResult> CheckCaptcha([FromQuery] string stuid, [FromQuery] string captcha)
{
var stu = context.Students.FirstOrDefault(e => e.Stuid == stuid);
if (stu == null) return Ok(ApiResponse.Error("INVALID_STUID"));
else if (captcha == stu.LastCaptcha)
{
if (DateTime.Now - stu.LastCaptchaTime > TimeSpan.FromMinutes(15)) return Ok(ApiResponse.Error("CAPTCHA_TIMEOUT"));
return Ok(ApiResponse.Success("success"));
}
else return Ok(ApiResponse.Error("INVALID_CAPTCHA"));
}
[HttpPost("getCaptcha")]
public async Task<IActionResult> GetCaptcha([FromQuery] string stuid)
{
var stu = context.Students.FirstOrDefault(e => e.Stuid == stuid);
if (stu == null) return Ok(ApiResponse.Error("INVALID_STUID"));
else if (DateTime.Now - stu.LastCaptchaTime < TimeSpan.FromMinutes(1)) return Ok(ApiResponse.Error($"ALREADY_SENT"));
var result = await TencentSMS.Send(context, SMSType.Captcha, stu, "smsbot");
if (!result) return Ok(ApiResponse.Error("SEND_ERROR"));
return Ok(ApiResponse.Success("success"));
}
[HttpPost("submit")]
public async Task<IActionResult> PostSubmit([FromForm] string dto)
{ {
var aDto = JsonSerializer.Deserialize<SubmissionDto>(dto); var aDto = JsonSerializer.Deserialize<SubmissionDto>(dto);
string ip = Request.Headers["X-Real-IP"].FirstOrDefault(); string ip = Request.Headers["X-Real-IP"].FirstOrDefault();
@@ -29,48 +61,47 @@ namespace _2021_backend.Controllers
if (aDto.Check() == false) if (aDto.Check() == false)
return StatusCode(400, ApiResponse.Error("TICKET_NOT_LEGEAL")); return StatusCode(400, ApiResponse.Error("TICKET_NOT_LEGEAL"));
Submission sub = new Submission(aDto, ip); Submission sub = new Submission(aDto, ip);
foreach (var tm in Context.Sessions) foreach (var tm in context.Sessions)
{ {
if(aDto.Timelist != null)if (aDto.Timelist.Any(it => it.Day.Day == tm.Day.Day && it.BeginTime.TimeOfDay == tm.BeginTime.TimeOfDay)) 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)); var q = context.Students.Where(stu => (stu.Name == aDto.Name || stu.Stuid == aDto.Stuid));
Student stu; Student stu;
if (q.Count() == 0) if (q.Count() == 0)
{ {
stu = Student.create(sub); stu = Student.create(sub);
stu.Status = status.刚报名; stu.Status = status.刚报名;
Context.Students.Add(stu); context.Students.Add(stu);
context.SaveChanges();
sub.Host = stu.Id;
context.Submissions.Add(sub);
context.SaveChanges();
stu.Submissions.Add(sub.Id);
context.SaveChanges();
} }
else else
{ {
stu = q.FirstOrDefault(); stu = q.FirstOrDefault();
sub.Host = stu.Id;
context.Submissions.Add(sub);
context.SaveChanges();
stu.Update(sub); stu.Update(sub);
context.SaveChanges();
} }
sub.Host = stu.Guid;
Context.Submissions.Add(sub); await TencentSMS.Send(context, SMSType.Signed, stu, _2021_backend.Models.User.Bot.stuID);
Context.SaveChanges();
await TencentSMS.Send(Context, SMSType.Signed, stu, _2021_backend.Models.User.Bot.stuID);
return Ok(ApiResponse.Success("success")); return Ok(ApiResponse.Success("success"));
} }
}
[ApiController]
[Route("api/sessionlist")]
public class SessionlistContoller : Controller
{
private readonly BackendContext _context;
public SessionlistContoller(BackendContext context)
{
_context = context;
}
[HttpGet]
[HttpGet("sessionlist")]
public IActionResult GetSessions() public IActionResult GetSessions()
{ {
var query = _context.Sessions.OrderBy(r => r.Day).ThenBy(r => r.BeginTime).ThenBy(r => r.Place).Where(e => e.Capacity > e.Students.Count + 1).Select(r => new SessionDto var query = context.Sessions.OrderBy(r => r.Day).ThenBy(r => r.BeginTime).ThenBy(r => r.Place).Where(e => e.Capacity > e.Students.Count).Select(r => new SessionDto
{ {
BeginTime = r.BeginTime, BeginTime = r.BeginTime,
Day = r.Day, Day = r.Day,
@@ -78,49 +109,118 @@ namespace _2021_backend.Controllers
return Ok(ApiResponse.Success(query.ToList().FindAll(it => it.Day.Add(it.BeginTime.TimeOfDay).CompareTo(DateTime.Now) > 0).Distinct(new SessionDtoComparer()).ToList())); return Ok(ApiResponse.Success(query.ToList().FindAll(it => it.Day.Add(it.BeginTime.TimeOfDay).CompareTo(DateTime.Now) > 0).Distinct(new SessionDtoComparer()).ToList()));
//return Ok(ApiResponse.Success("报名结束了")); //return Ok(ApiResponse.Success("报名结束了"));
} }
}
[ApiController]
[Route("api/postsession")]
public class PostsessionController : Controller [HttpGet("fileinfo")]
{ public async Task<IActionResult> GetInfo([FromQuery] string? stuid)
private readonly BackendContext Context;
public PostsessionController(BackendContext context)
{ {
Context = context; if (stuid == null || (!context.Students.Any(e => e.Stuid == stuid)))
} {
[HttpPost] return Ok(ApiResponse.Error("INVALID_STUID"));
}
else
{
var student = context.Students.FirstOrDefault(e => e.Stuid == stuid.ToString());
if (student.Uploads == null)
{
student.Uploads = new List<int> { };
context.SaveChangesAsync();
return Ok(ApiResponse.Error("NO_FILES"));
}
var fileIdx = student.Uploads.Last();
var file = context.FileDesc.Find(fileIdx);
var oldNameSplit = file.Name.Split(".");
var oldName = "";
var oldNameExtension = oldNameSplit.LastOrDefault();
for (int i = 0; i < oldNameSplit.Count() - 1; i++)
{
oldName += oldNameSplit[i];
}
file.Path = "***.***.****";
if (oldName.Count() >= 2)
{
file.Name = $"{oldName[0]}***{oldName}.{oldNameExtension}";
}
else
{
file.Name = $"**.{oldNameExtension}";
}
return Ok(ApiResponse.Success(file));
}
}
[HttpPost("upload")]
public async Task<IActionResult> UploadFile([FromQuery] string? stuid,[FromQuery]string filename, [FromQuery] string filepath, [FromQuery] float fileSizeInKB)
{
var filedesc = new FileDesc { Name = filename, Path = $"jphd-3dprint-2022.oss-cn-hangzhou.aliyuncs.com/uploads/{stuid}/{filename}", Size = Convert.ToInt32(fileSizeInKB), UploadTime = DateTime.Now };
if (!context.Students.Any(e => e.Stuid == stuid)) return Ok(ApiResponse.Error("INVALID_STUID"));
else
{
var s = context.Students.First(e => e.Stuid == stuid);
filedesc.OwnerId = s.Id;
if (s.Uploads == null) s.Uploads = new List<int> { };
context.FileDesc.Add(filedesc);
await context.SaveChangesAsync();
s.Uploads.Add(filedesc.Id);
s.Status = status.已提交;
await context.SaveChangesAsync();
return Ok(ApiResponse.Success("success"));
}
}
[HttpPost("postsession")]
public async Task<IActionResult> Post([FromQuery] string stuid, [FromQuery] string selection) public async Task<IActionResult> Post([FromQuery] string stuid, [FromQuery] string selection)
{ {
Student stu = Context.Students.FirstOrDefault(r => r.Stuid == stuid); Student stu = context.Students.FirstOrDefault(r => r.Stuid == stuid);
if (stu == null) if (stu == null)
{ {
return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_GUID")); return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_int"));
} }
List<SessionDto> timelist; SessionDto time;
try try
{ {
timelist = JsonSerializer.Deserialize<List<SessionDto>>(selection); time = JsonSerializer.Deserialize<SessionDto>(selection);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex);
return StatusCode(400, ApiResponse.Error("MALFORMED_DATA")); return StatusCode(400, ApiResponse.Error("MALFORMED_DATA"));
}; };
//get the selected session guids; //get the selected session ints;
List<Guid> targetSessions; int targetSession = 0;
var sessions = Context.Sessions.ToList(); var sessions = context.Sessions.ToList();
targetSessions = sessions.FindAll((Session s) => var s = sessions.Find((Session s) =>
{ {
return timelist.Any(it => it.Day == s.Day && it.BeginTime == s.BeginTime); return time.Day == s.Day && time.BeginTime == s.BeginTime;
}).Select(it => it.Guid).ToList(); });
stu.Timelist = targetSessions; var overwritten = false;
if (s.Students.Count >= s.Capacity) return Ok(ApiResponse.Error("OUT_OF_CAPACITY"));
if (context.Sessions.Find(stu.InterviewTime) != null)
{
var olds = context.Sessions.Find(stu.InterviewTime);
olds.Students.Remove(stu.Id);
context.SaveChanges();
overwritten = true;
}
targetSession = s.Id;
s.Students.Add(stu.Id);
stu.Timelist = new List<int> { targetSession };
stu.Status = status.已选时间; stu.Status = status.已选时间;
await Context.SaveChangesAsync(); stu.InterviewTime = s.Id;
await TencentSMS.Send(context, SMSType.TimeSet, stu, "smsbot");
context.SaveChanges();
if (overwritten) return Ok(ApiResponse.Success("overwritten"));
return Ok(ApiResponse.Success("success")); return Ok(ApiResponse.Success("success"));
//return Ok(ApiResponse.Success("报名结束了")); //return Ok(ApiResponse.Success("报名结束了"));
} }
} }
} }
+8 -5
View File
@@ -16,18 +16,21 @@ namespace _2021_backend.Data
public DbSet<Student> Students { get; set; } public DbSet<Student> Students { get; set; }
public DbSet<SMS> SMS { get; set; } public DbSet<SMS> SMS { get; set; }
public DbSet<FileDesc> FileDesc { get; set; }
protected override void OnModelCreating(ModelBuilder mb) protected override void OnModelCreating(ModelBuilder mb)
{ {
mb.Entity<Submission>() mb.Entity<Submission>()
.HasKey(r => r.Guid); .HasKey(r => r.Id);
mb.Entity<User>() mb.Entity<User>()
.HasKey(u => u.Guid); .HasKey(u => u.Id);
mb.Entity<Comment>() mb.Entity<Comment>()
.HasKey(u => u.Guid); .HasKey(u => u.Id);
mb.Entity<Session>() mb.Entity<Session>()
.HasKey(u => u.Guid); .HasKey(u => u.Id);
mb.Entity<SMS>() mb.Entity<SMS>()
.HasKey(u => u.Guid); .HasKey(u => u.Id);
mb.Entity<FileDesc>().HasKey(u => u.Id);
} }
} }
} }
+2 -2
View File
@@ -1,11 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
EXPOSE 443 EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src WORKDIR /src
COPY ["2021-backend.csproj", ""] COPY ["2021-backend.csproj", ""]
RUN dotnet restore "./2021-backend.csproj" RUN dotnet restore "./2021-backend.csproj"
@@ -8,58 +8,128 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using _2021_backend.Data; using _2021_backend.Data;
#nullable disable
namespace _2021_backend.Migrations namespace _2021_backend.Migrations
{ {
[DbContext(typeof(BackendContext))] [DbContext(typeof(BackendContext))]
[Migration("20211018220015_Initial")] [Migration("20220223070103_initial")]
partial class Initial partial class initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 63) .HasAnnotation("ProductVersion", "6.0.2")
.HasAnnotation("ProductVersion", "5.0.9") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("_2021_backend.Models.Comment", b => modelBuilder.Entity("_2021_backend.Models.Comment", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("AddTime") b.Property<DateTime>("AddTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Content") b.Property<string>("Content")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<Guid>("Operator") b.Property<int>("Operator")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<Guid>("Student") b.Property<int>("Student")
.HasColumnType("uuid"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Comments"); b.ToTable("Comments");
}); });
modelBuilder.Entity("_2021_backend.Models.FileDesc", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("OwnerId")
.HasColumnType("integer");
b.Property<string>("Path")
.HasColumnType("text");
b.Property<int>("Size")
.HasColumnType("integer");
b.Property<DateTime>("UploadTime")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("FileDesc");
});
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 => modelBuilder.Entity("_2021_backend.Models.SMS", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<string>>("Data") b.Property<List<string>>("Data")
.HasColumnType("text[]"); .HasColumnType("text[]");
b.Property<Guid>("Host") b.Property<int>("Host")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<DateTime>("SendTime") b.Property<DateTime>("SendTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Sender") b.Property<string>("Sender")
.HasColumnType("text"); .HasColumnType("text");
@@ -70,52 +140,21 @@ namespace _2021_backend.Migrations
b.Property<int>("Type") b.Property<int>("Type")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("SMS"); 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 => modelBuilder.Entity("_2021_backend.Models.Student", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<List<Guid>>("Comments") NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid[]");
b.Property<List<int>>("Comments")
.HasColumnType("integer[]");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("text"); .HasColumnType("text");
@@ -126,23 +165,29 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade") b.Property<int>("Grade")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<Guid>("InterviewTime") b.Property<int>("InterviewTime")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<string>("LastCaptcha")
.HasColumnType("text");
b.Property<DateTime>("LastCaptchaTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("LastSubmission") b.Property<DateTime>("LastSubmission")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Major") b.Property<string>("Major")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Messages") b.Property<List<int>>("Messages")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RegisterTime") b.Property<DateTime>("RegisterTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<int>("Score") b.Property<int>("Score")
.HasColumnType("integer"); .HasColumnType("integer");
@@ -156,28 +201,33 @@ namespace _2021_backend.Migrations
b.Property<string>("Stuid") b.Property<string>("Stuid")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Submissions") b.Property<List<int>>("Submissions")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<string>("Tel") b.Property<string>("Tel")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Timelist") b.Property<List<int>>("Timelist")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<List<int>>("Uploads")
.HasColumnType("integer[]");
b.Property<int>("Yard") b.Property<int>("Yard")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Students"); b.ToTable("Students");
}); });
modelBuilder.Entity("_2021_backend.Models.Submission", b => modelBuilder.Entity("_2021_backend.Models.Submission", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address") b.Property<string>("Address")
.HasColumnType("text"); .HasColumnType("text");
@@ -191,8 +241,8 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade") b.Property<int>("Grade")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<Guid>("Host") b.Property<int>("Host")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<string>("Major") b.Property<string>("Major")
.HasColumnType("text"); .HasColumnType("text");
@@ -207,27 +257,29 @@ namespace _2021_backend.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("SubmitTime") b.Property<DateTime>("SubmitTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Tel") b.Property<string>("Tel")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Timelist") b.Property<List<int>>("Timelist")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<int>("Yard") b.Property<int>("Yard")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Submissions"); b.ToTable("Submissions");
}); });
modelBuilder.Entity("_2021_backend.Models.User", b => modelBuilder.Entity("_2021_backend.Models.User", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("text"); .HasColumnType("text");
@@ -241,7 +293,7 @@ namespace _2021_backend.Migrations
b.Property<string>("stuID") b.Property<string>("stuID")
.HasColumnType("text"); .HasColumnType("text");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
@@ -1,10 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace _2021_backend.Migrations namespace _2021_backend.Migrations
{ {
public partial class Initial : Migration public partial class initial : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
@@ -12,57 +15,78 @@ namespace _2021_backend.Migrations
name: "Comments", name: "Comments",
columns: table => new columns: table => new
{ {
Guid = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<int>(type: "integer", nullable: false)
Operator = table.Column<Guid>(type: "uuid", nullable: false), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Operator = table.Column<int>(type: "integer", nullable: false),
Content = table.Column<string>(type: "text", nullable: false), Content = table.Column<string>(type: "text", nullable: false),
AddTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), AddTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Student = table.Column<Guid>(type: "uuid", nullable: false) Student = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Comments", x => x.Guid); table.PrimaryKey("PK_Comments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "FileDesc",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OwnerId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
Size = table.Column<int>(type: "integer", nullable: false),
Path = table.Column<string>(type: "text", nullable: true),
UploadTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FileDesc", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Sessions", name: "Sessions",
columns: table => new columns: table => new
{ {
Guid = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<int>(type: "integer", nullable: false)
Day = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BeginTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), 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), 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), Capacity = table.Column<int>(type: "integer", nullable: false),
SendSMS = table.Column<bool>(type: "boolean", 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 => constraints: table =>
{ {
table.PrimaryKey("PK_Sessions", x => x.Guid); table.PrimaryKey("PK_Sessions", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "SMS", name: "SMS",
columns: table => new columns: table => new
{ {
Guid = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<int>(type: "integer", nullable: false)
Host = table.Column<Guid>(type: "uuid", nullable: false), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Host = table.Column<int>(type: "integer", nullable: false),
Tel = table.Column<string>(type: "text", nullable: true), Tel = table.Column<string>(type: "text", nullable: true),
Data = table.Column<List<string>>(type: "text[]", nullable: true), Data = table.Column<List<string>>(type: "text[]", nullable: true),
Type = table.Column<int>(type: "integer", nullable: false), Type = table.Column<int>(type: "integer", nullable: false),
Sender = table.Column<string>(type: "text", nullable: true), 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 => constraints: table =>
{ {
table.PrimaryKey("PK_SMS", x => x.Guid); table.PrimaryKey("PK_SMS", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Students", name: "Students",
columns: table => new 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), Name = table.Column<string>(type: "text", nullable: true),
Stuid = table.Column<string>(type: "text", nullable: true), Stuid = table.Column<string>(type: "text", nullable: true),
Sex = table.Column<int>(type: "integer", nullable: false), Sex = table.Column<int>(type: "integer", nullable: false),
@@ -72,27 +96,31 @@ namespace _2021_backend.Migrations
Email = table.Column<string>(type: "text", nullable: true), Email = table.Column<string>(type: "text", nullable: true),
Tel = table.Column<string>(type: "text", nullable: true), Tel = table.Column<string>(type: "text", nullable: true),
Exp = table.Column<int>(type: "integer", nullable: false), Exp = table.Column<int>(type: "integer", nullable: false),
InterviewTime = table.Column<Guid>(type: "uuid", nullable: false), InterviewTime = table.Column<int>(type: "integer", nullable: false),
Submissions = table.Column<List<Guid>>(type: "uuid[]", nullable: true), Submissions = table.Column<List<int>>(type: "integer[]", nullable: true),
Messages = table.Column<List<Guid>>(type: "uuid[]", nullable: true), Uploads = table.Column<List<int>>(type: "integer[]", nullable: true),
Timelist = table.Column<List<Guid>>(type: "uuid[]", nullable: true), Messages = table.Column<List<int>>(type: "integer[]", nullable: true),
Comments = table.Column<List<Guid>>(type: "uuid[]", 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), Score = table.Column<int>(type: "integer", nullable: false),
Status = 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), LastSubmission = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
RegisterTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false) RegisterTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastCaptcha = table.Column<string>(type: "text", nullable: true),
LastCaptchaTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Students", x => x.Guid); table.PrimaryKey("PK_Students", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Submissions", name: "Submissions",
columns: table => new columns: table => new
{ {
Guid = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<int>(type: "integer", nullable: false)
Host = table.Column<Guid>(type: "uuid", nullable: false), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Host = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: true), Name = table.Column<string>(type: "text", nullable: true),
Stuid = table.Column<string>(type: "text", nullable: true), Stuid = table.Column<string>(type: "text", nullable: true),
Sex = table.Column<int>(type: "integer", nullable: false), Sex = table.Column<int>(type: "integer", nullable: false),
@@ -102,20 +130,21 @@ namespace _2021_backend.Migrations
Email = table.Column<string>(type: "text", nullable: true), Email = table.Column<string>(type: "text", nullable: true),
Tel = table.Column<string>(type: "text", nullable: true), Tel = table.Column<string>(type: "text", nullable: true),
Exp = table.Column<int>(type: "integer", nullable: false), 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), 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 => constraints: table =>
{ {
table.PrimaryKey("PK_Submissions", x => x.Guid); table.PrimaryKey("PK_Submissions", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Users", name: "Users",
columns: table => new 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), stuID = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: true), Name = table.Column<string>(type: "text", nullable: true),
Secret = table.Column<string>(type: "text", nullable: true), Secret = table.Column<string>(type: "text", nullable: true),
@@ -123,7 +152,7 @@ namespace _2021_backend.Migrations
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Users", x => x.Guid); table.PrimaryKey("PK_Users", x => x.Id);
}); });
} }
@@ -132,6 +161,9 @@ namespace _2021_backend.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Comments"); name: "Comments");
migrationBuilder.DropTable(
name: "FileDesc");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Sessions"); name: "Sessions");
+128 -76
View File
@@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using _2021_backend.Data; using _2021_backend.Data;
#nullable disable
namespace _2021_backend.Migrations namespace _2021_backend.Migrations
{ {
[DbContext(typeof(BackendContext))] [DbContext(typeof(BackendContext))]
@@ -16,48 +18,116 @@ namespace _2021_backend.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 63) .HasAnnotation("ProductVersion", "6.0.2")
.HasAnnotation("ProductVersion", "5.0.9") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("_2021_backend.Models.Comment", b => modelBuilder.Entity("_2021_backend.Models.Comment", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("AddTime") b.Property<DateTime>("AddTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Content") b.Property<string>("Content")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<Guid>("Operator") b.Property<int>("Operator")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<Guid>("Student") b.Property<int>("Student")
.HasColumnType("uuid"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Comments"); b.ToTable("Comments");
}); });
modelBuilder.Entity("_2021_backend.Models.FileDesc", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("OwnerId")
.HasColumnType("integer");
b.Property<string>("Path")
.HasColumnType("text");
b.Property<int>("Size")
.HasColumnType("integer");
b.Property<DateTime>("UploadTime")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("FileDesc");
});
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 => modelBuilder.Entity("_2021_backend.Models.SMS", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<string>>("Data") b.Property<List<string>>("Data")
.HasColumnType("text[]"); .HasColumnType("text[]");
b.Property<Guid>("Host") b.Property<int>("Host")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<DateTime>("SendTime") b.Property<DateTime>("SendTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Sender") b.Property<string>("Sender")
.HasColumnType("text"); .HasColumnType("text");
@@ -68,52 +138,21 @@ namespace _2021_backend.Migrations
b.Property<int>("Type") b.Property<int>("Type")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("SMS"); 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 => modelBuilder.Entity("_2021_backend.Models.Student", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<List<Guid>>("Comments") NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid[]");
b.Property<List<int>>("Comments")
.HasColumnType("integer[]");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("text"); .HasColumnType("text");
@@ -124,23 +163,29 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade") b.Property<int>("Grade")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<Guid>("InterviewTime") b.Property<int>("InterviewTime")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<string>("LastCaptcha")
.HasColumnType("text");
b.Property<DateTime>("LastCaptchaTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("LastSubmission") b.Property<DateTime>("LastSubmission")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Major") b.Property<string>("Major")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Messages") b.Property<List<int>>("Messages")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RegisterTime") b.Property<DateTime>("RegisterTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<int>("Score") b.Property<int>("Score")
.HasColumnType("integer"); .HasColumnType("integer");
@@ -154,28 +199,33 @@ namespace _2021_backend.Migrations
b.Property<string>("Stuid") b.Property<string>("Stuid")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Submissions") b.Property<List<int>>("Submissions")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<string>("Tel") b.Property<string>("Tel")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Timelist") b.Property<List<int>>("Timelist")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<List<int>>("Uploads")
.HasColumnType("integer[]");
b.Property<int>("Yard") b.Property<int>("Yard")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Students"); b.ToTable("Students");
}); });
modelBuilder.Entity("_2021_backend.Models.Submission", b => modelBuilder.Entity("_2021_backend.Models.Submission", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address") b.Property<string>("Address")
.HasColumnType("text"); .HasColumnType("text");
@@ -189,8 +239,8 @@ namespace _2021_backend.Migrations
b.Property<int>("Grade") b.Property<int>("Grade")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<Guid>("Host") b.Property<int>("Host")
.HasColumnType("uuid"); .HasColumnType("integer");
b.Property<string>("Major") b.Property<string>("Major")
.HasColumnType("text"); .HasColumnType("text");
@@ -205,27 +255,29 @@ namespace _2021_backend.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("SubmitTime") b.Property<DateTime>("SubmitTime")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Tel") b.Property<string>("Tel")
.HasColumnType("text"); .HasColumnType("text");
b.Property<List<Guid>>("Timelist") b.Property<List<int>>("Timelist")
.HasColumnType("uuid[]"); .HasColumnType("integer[]");
b.Property<int>("Yard") b.Property<int>("Yard")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Submissions"); b.ToTable("Submissions");
}); });
modelBuilder.Entity("_2021_backend.Models.User", b => modelBuilder.Entity("_2021_backend.Models.User", b =>
{ {
b.Property<Guid>("Guid") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("text"); .HasColumnType("text");
@@ -239,7 +291,7 @@ namespace _2021_backend.Migrations
b.Property<string>("stuID") b.Property<string>("stuID")
.HasColumnType("text"); .HasColumnType("text");
b.HasKey("Guid"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
+12 -11
View File
@@ -11,30 +11,31 @@ namespace _2021_backend.Models
{ {
public Comment() public Comment()
{ {
Guid = Guid.NewGuid(); Id = 0;
AddTime = DateTime.Now; AddTime = DateTime.Now;
} }
[Key] [Key]
public Guid Guid { get; set; } [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required()] [Required()]
[Display(Name ="评论者")] [Display(Name = "评论者")]
public Guid Operator { get; set; } public int Operator { get; set; }
[Required()] [Required()]
[Display(Name ="内容")] [Display(Name = "内容")]
public string Content { get; set; } public string Content { get; set; }
[Display(Name = "评论时间")] [Display(Name = "评论时间")]
[DataType(DataType.DateTime)] [DataType(DataType.DateTime)]
public DateTime AddTime { get; set; } public DateTime AddTime { get; set; }
[Display(Name ="被评论者")] [Display(Name = "被评论者")]
public Guid Student { get; set; } public int Student { get; set; }
public Comment(Guid opid,string content, Guid stuguid) public Comment(int opid, string content, int stuint)
{ {
Guid = Guid.NewGuid(); Id = 0;
Operator = opid; Operator = opid;
Content = content; Content = content;
Student = stuguid; Student = stuint;
AddTime = DateTime.Now; AddTime = DateTime.Now;
} }
+14 -11
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.ComponentModel.DataAnnotations.Schema;
namespace _2021_backend.Models namespace _2021_backend.Models
{ {
@@ -12,22 +13,23 @@ namespace _2021_backend.Models
TimeSelect, TimeSelect,
TimeSet, TimeSet,
Signed, Signed,
Reply Reply,
Captcha,
} }
public class SMS public class SMS
{ {
public SMS() public SMS()
{ {
Guid = Guid.NewGuid(); Id = 0;
Tel = ""; Tel = "";
Data = new List<string> { }; Data = new List<string> { };
Type = SMSType.Accept; Type = SMSType.Accept;
Sender = ""; Sender = "";
SendTime = DateTime.Now; SendTime = DateTime.Now;
} }
public SMS(SMSPartialDto dto, Guid host) public SMS(SMSPartialDto dto, int host)
{ {
Guid = Guid.NewGuid(); Id = 0;
Tel = dto.SubscriberNumber; Tel = dto.SubscriberNumber;
Host = host; Host = host;
Sender = dto.SubscriberNumber.ToString(); Sender = dto.SubscriberNumber.ToString();
@@ -37,17 +39,18 @@ namespace _2021_backend.Models
SendTime = tm; SendTime = tm;
} }
[Key] [Key]
public Guid Guid { get; set; } [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name ="Host")] public int Id { get; set; }
public Guid Host { get; set; } [Display(Name = "Host")]
[Display(Name ="电话号码")] public int Host { get; set; }
[Display(Name = "电话号码")]
public string Tel { get; set; } public string Tel { get; set; }
[Display(Name ="短信内容")] [Display(Name = "短信内容")]
public List<string> Data { get; set; } public List<string> Data { get; set; }
[Display(Name ="短信类型")] [Display(Name = "短信类型")]
public SMSType Type { get; set; } public SMSType Type { get; set; }
[Display(Name ="发送者")] [Display(Name = "发送者")]
public string Sender { get; set; } public string Sender { get; set; }
[Display(Name = "发送时间")] [Display(Name = "发送时间")]
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)] [DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
+7 -6
View File
@@ -14,12 +14,13 @@ namespace _2021_backend.Models
public Session() public Session()
{ {
Guid = Guid.NewGuid(); Id = 0;
} }
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required()] [Required()]
[Display(Name = "场次GUID")] [Display(Name = "场次int")]
public Guid Guid { get; set; } public int Id { get; set; }
[Required()] [Required()]
[Display(Name = "活动日期")] [Display(Name = "活动日期")]
[DataType(DataType.Date)] [DataType(DataType.Date)]
@@ -35,7 +36,7 @@ namespace _2021_backend.Models
[Required()] [Required()]
public string Place { get; set; } public string Place { get; set; }
[Display(Name = "主活动官")] [Display(Name = "主活动官")]
public List<Guid> Chiefs { get; set; } public List<int> Chiefs { get; set; }
[Display(Name = "可容纳人数")] [Display(Name = "可容纳人数")]
public int Capacity { get; set; } public int Capacity { get; set; }
@@ -43,7 +44,7 @@ namespace _2021_backend.Models
[Display(Name = "短信通知")] [Display(Name = "短信通知")]
public bool SendSMS { get; set; } public bool SendSMS { get; set; }
[Display(Name = "活动的人")] [Display(Name = "活动的人")]
public List<Guid> Students { get; set; } public List<int> Students { get; set; }
} }
public class SessionDto public class SessionDto
@@ -57,7 +58,7 @@ namespace _2021_backend.Models
public class SessionDtoComparer : IEqualityComparer<SessionDto> public class SessionDtoComparer : IEqualityComparer<SessionDto>
{ {
#region IEqualityComparer<user> Members #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; return a.Day == b.Day && a.BeginTime == b.BeginTime;
} }
+44 -21
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -14,6 +15,7 @@ namespace _2021_backend.Models
需调整时间, 需调整时间,
已确认时间, 已确认时间,
不通过, 不通过,
已提交,
已评分, 已评分,
暂缺 暂缺
} }
@@ -47,8 +49,21 @@ namespace _2021_backend.Models
暂缺 = 0, 暂缺 = 0,
萌新 = 1, 萌新 = 1,
略有了解 = 2, 略有了解 = 2,
了解较多 = 3, 轻车熟路 = 3,
轻车熟路 = 4 }
public class FileDesc
{
[Key]
public int Id { get; set; }
public int OwnerId { get; set; }
public string Name { get; set; }
public int Size { get; set; }
public string Path { get; set; }
public DateTime UploadTime { get; set; }
} }
public class Student public class Student
@@ -64,22 +79,22 @@ namespace _2021_backend.Models
Major = sub.Major; Major = sub.Major;
Yard = sub.Yard; Yard = sub.Yard;
Exp = sub.Exp; Exp = sub.Exp;
Timelist = sub.Timelist; Timelist = sub.Timelist;
Submissions.Add(sub.Guid); Submissions.Add(sub.Id);
} }
public Student() public Student()
{ {
Guid = Guid.NewGuid(); Id = 0;
Comments = new List<Guid>(); Comments = new List<int>();
Messages = new List<Guid>(); Messages = new List<int>();
Submissions = new List<Guid>(); Submissions = new List<int>();
Timelist = new List<Guid>(); Timelist = new List<int>();
} }
public static Student create(Submission sub) public static Student create(Submission sub)
{ {
Student student = new Student(); Student student = new Student();
student.Guid = Guid.NewGuid(); student.Id = 0;
student.Name = sub.Name; student.Name = sub.Name;
student.Email = sub.Email; student.Email = sub.Email;
student.Tel = sub.Tel; student.Tel = sub.Tel;
@@ -90,13 +105,13 @@ namespace _2021_backend.Models
student.Yard = sub.Yard; student.Yard = sub.Yard;
student.Exp = sub.Exp; student.Exp = sub.Exp;
student.Timelist = sub.Timelist; student.Timelist = sub.Timelist;
student.Submissions.Add(sub.Guid);
student.RegisterTime = sub.SubmitTime; student.RegisterTime = sub.SubmitTime;
return student; return student;
} }
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name = "ID")] [Display(Name = "ID")]
public Guid Guid { get; set; } public int Id { get; set; }
[Display(Name = "姓名")] [Display(Name = "姓名")]
public string Name { get; set; } public string Name { get; set; }
[Display(Name = "学号")] [Display(Name = "学号")]
@@ -107,7 +122,7 @@ namespace _2021_backend.Models
public grade Grade { get; set; } public grade Grade { get; set; }
[Display(Name = "学园")] [Display(Name = "学园")]
public yard Yard { get; set; } public yard Yard { get; set; }
[Display(Name = "专业")] [Display(Name = "专业")]
public string Major { get; set; } public string Major { get; set; }
[Display(Name = "电子邮件")] [Display(Name = "电子邮件")]
@@ -116,20 +131,24 @@ namespace _2021_backend.Models
public string Tel { get; set; } public string Tel { get; set; }
[Display(Name = "经验程度")] [Display(Name = "经验程度")]
public experience Exp { get; set; } public experience Exp { get; set; }
[Display(Name = "最终场次")] [Display(Name = "最终场次")]
public Guid InterviewTime { get; set; } public int InterviewTime { get; set; }
[Display(Name = "提交记录")] [Display(Name = "报名记录")]
public List<Guid> Submissions { get; set; } public List<int> Submissions { get; set; }
[Display(Name = "提交的文件")]
public List<int> Uploads { get; set; }
[Display(Name = "短信记录")] [Display(Name = "短信记录")]
public List<Guid> Messages { get; set; } public List<int> Messages { get; set; }
[Display(Name = "可选场次")] [Display(Name = "可选场次")]
public List<Guid> Timelist { get; set; } public List<int> Timelist { get; set; }
[Display(Name = "评论")] [Display(Name = "评论")]
public List<Guid> Comments { get; set; } public List<int> Comments { get; set; }
[Display(Name = "打分")] [Display(Name = "打分")]
public int Score { get; set; } public int Score { get; set; }
[Display(Name = "状态")] [Display(Name = "状态")]
public status Status { get; set; } public status Status { get; set; }
@@ -141,5 +160,9 @@ namespace _2021_backend.Models
[Display(Name = "报名时间")] [Display(Name = "报名时间")]
[DataType(DataType.DateTime)] [DataType(DataType.DateTime)]
public DateTime RegisterTime { get; set; } public DateTime RegisterTime { get; set; }
public string LastCaptcha { get; set; }
public DateTime LastCaptchaTime { get; set; }
} }
} }
+18 -15
View File
@@ -3,6 +3,7 @@ using Org.BouncyCastle.Asn1.Cms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -11,8 +12,9 @@ namespace _2021_backend.Models
{ {
public class Submission public class Submission
{ {
public Submission() { public Submission()
Guid = Guid.NewGuid(); {
Id = 0;
SubmitTime = DateTime.Now; SubmitTime = DateTime.Now;
} }
public Submission(SubmissionDto Dto, string ip) public Submission(SubmissionDto Dto, string ip)
@@ -26,16 +28,17 @@ namespace _2021_backend.Models
Tel = Dto.Tel; Tel = Dto.Tel;
Exp = (experience)Dto.Exp; Exp = (experience)Dto.Exp;
Yard = (yard)Dto.Yard; Yard = (yard)Dto.Yard;
Timelist = new List<Guid>(); Timelist = new List<int>();
Guid = System.Guid.NewGuid(); Id = 0;
SubmitTime = DateTime.Now; SubmitTime = DateTime.Now;
Address = ip; Address = ip;
} }
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name = "ID")] [Display(Name = "ID")]
public Guid Guid { get; set; } public int Id { get; set; }
[Display(Name ="Host")] [Display(Name = "Host")]
public Guid Host { get; set; } public int Host { get; set; }
[Display(Name = "姓名")] [Display(Name = "姓名")]
public string Name { get; set; } public string Name { get; set; }
[Display(Name = "学号")] [Display(Name = "学号")]
@@ -58,9 +61,9 @@ namespace _2021_backend.Models
public experience Exp { get; set; } public experience Exp { get; set; }
[Display(Name = "时间列表")] [Display(Name = "时间列表")]
public List<Guid> Timelist { get; set; } public List<int> Timelist { get; set; }
[Display(Name ="Ip Address")] [Display(Name = "Ip Address")]
public string Address { get; set; } public string Address { get; set; }
[Display(Name = "提交时间")] [Display(Name = "提交时间")]
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)] [DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
public DateTime SubmitTime { get; set; } public DateTime SubmitTime { get; set; }
@@ -69,8 +72,8 @@ namespace _2021_backend.Models
} }
public class TimeSpec public class TimeSpec
{ {
public DateTime Day { get; set; } public DateTime Day { get; set; }
public DateTime BeginTime { get; set; } public DateTime BeginTime { get; set; }
} }
public class SubmissionDto public class SubmissionDto
@@ -91,12 +94,12 @@ namespace _2021_backend.Models
public string Email { get; set; } public string Email { get; set; }
[Required()] [Required()]
public string Tel { get; set; } public string Tel { get; set; }
[Required()] [Required()]
public int Exp { get; set; } public int Exp { get; set; }
[Required()] [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+)*$"); public static Regex r = new Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
@@ -118,7 +121,7 @@ namespace _2021_backend.Models
if (Major.Length > 20) if (Major.Length > 20)
return false; return false;
if (Yard >= 6 && Yard <= 0) return false; if (Yard >= 6 && Yard <= 0) return false;
if(Exp >= 5 && Exp <= 0) return false; if (Exp >= 3 && Exp <= 0) return false;
if (!r.IsMatch(Email)) if (!r.IsMatch(Email))
{ {
return false; return false;
+10 -10
View File
@@ -10,37 +10,37 @@ using Microsoft.EntityFrameworkCore.Internal;
namespace _2021_backend.Models namespace _2021_backend.Models
{ {
public class User public class User
{ {
public User() public User()
{ {
Guid = Guid.NewGuid(); Id = 0;
} }
public static User Bot; public static User Bot;
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name ="ID")] [Display(Name = "ID")]
public Guid Guid { get; set; } public int Id { get; set; }
[Display(Name = "学号")] [Display(Name = "学号")]
public string stuID { get; set; } public string stuID { get; set; }
[Display(Name ="姓名")] [Display(Name = "姓名")]
public string Name { get; set; } public string Name { get; set; }
[Display(Name ="密码")] [Display(Name = "密码")]
public string Secret { get; set; } public string Secret { get; set; }
[Display(Name ="是否管理员")] [Display(Name = "是否管理员")]
public bool isManager { get; set; } public bool isManager { get; set; }
} }
public class Login 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")] [JsonProperty("username")]
public string id_student { get; set; } public string id_student { get; set; }
[JsonProperty("password")] [JsonProperty("password")]
public string Password { get; set; } public string Password { get; set; }
public Login(string name,string pwd) public Login(string name, string pwd)
{ {
id_student = name; id_student = name;
Password = pwd; Password = pwd;
@@ -48,7 +48,7 @@ namespace _2021_backend.Models
public string GetSHASecret() => _2021_backend.Utils.EvaCryptoHelper.Password2Secret(Password); public string GetSHASecret() => _2021_backend.Utils.EvaCryptoHelper.Password2Secret(Password);
public bool isManager() public bool isManager()
{ {
if (Array.IndexOf(Manager,id_student) != -1) if (Array.IndexOf(Manager, id_student) != -1)
return true; return true;
return false; return false;
} }
+1 -1
View File
@@ -85,7 +85,7 @@ namespace _2021_backend.Pages.Account
{ {
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role); var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);
identity.AddClaim(new Claim(ClaimTypes.Name, user.Name)); 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)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, username));
if (user.isManager) if (user.isManager)
{ {
+2
View File
@@ -9,12 +9,14 @@
<strong>@Html.DisplayFor(model => Model.Errmsg)</strong> <strong>@Html.DisplayFor(model => Model.Errmsg)</strong>
</h5> </h5>
<h3><strong>发送短信</strong></h3> <h3><strong>发送短信</strong></h3>
<form method="post"> <form method="post">
<input type="hidden" asp-for="pageid" /> <input type="hidden" asp-for="pageid" />
<input type="submit" value="拉取5天内的回复短信" class="btn btn-primary" asp-page-handler="Pull" /> <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="Sign" />
<input type="submit" value="发送确认短信" class="btn btn-primary" asp-page-handler="ResultAccept" /> <input type="submit" value="发送确认短信" class="btn btn-primary" asp-page-handler="ResultAccept" />
<input type="submit" value="发送时间选择短信" class="btn btn-primary" asp-page-handler="TimeSelect" /> <input type="submit" value="发送时间选择短信" class="btn btn-primary" asp-page-handler="TimeSelect" />
<input type="submit" value="发送时间确认短信" class="btn btn-primary" asp-page-handler="TimeSet" />
<input type="submit" value="发送拒绝短信" class="btn btn-primary" asp-page-handler="ResultReject" /> <input type="submit" value="发送拒绝短信" class="btn btn-primary" asp-page-handler="ResultReject" />
</form> </form>
<br /> <br />
+103 -40
View File
@@ -40,12 +40,12 @@ namespace _2021_backend.Pages.Message
Context = context; Context = context;
} }
public IActionResult Construct(int PageId) public IActionResult Construct(int PageId, string emsg)
{ {
List<Guid> stus; List<int> stus;
IQueryable<Guid> q; IQueryable<int> q;
if (!String.IsNullOrEmpty(SearchString)) q = from e in Context.Students where e.Name.Contains(SearchString) select e.Guid; 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.Guid; else q = from e in Context.Students select e.Id;
stus = q.ToList(); stus = q.ToList();
var q2 = from e in Context.SMS where stus.Contains(e.Host) select e; 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; if (showReceive && !showSend) q2 = from e in q2 where e.Type == SMSType.Reply select e;
@@ -62,87 +62,150 @@ namespace _2021_backend.Pages.Message
int count = (PageId + 1) * pageSize > cnt ? (cnt - PageId * pageSize) : pageSize; int count = (PageId + 1) * pageSize > cnt ? (cnt - PageId * pageSize) : pageSize;
Messages = Messages.GetRange(PageId * pageSize, count); Messages = Messages.GetRange(PageId * pageSize, count);
Errmsg = emsg;
return Page(); return Page();
} }
public async Task<IActionResult> OnGetAsync(int PageId) public async Task<IActionResult> OnGetAsync(int PageId)
{ {
return Construct(PageId); return Construct(PageId, "");
} }
public async Task<IActionResult> OnPostAsync(int PageId) public async Task<IActionResult> OnPostAsync(int PageId)
{ {
return Construct(PageId); return Construct(PageId, "");
} }
public async void OnPostPullAsync(int PageId) public async void OnPostPullAsync(int PageId)
{ {
if (HttpContext.User.HasClaim((c) =>
var stu = Context.Students.ToList();
foreach (var e in stu)
{ {
await Utils.TencentSMS.Pull(Context, e, true); return c.Type == ClaimTypes.Role && (
} c.Value == "admin" || c.Value == "manager");
}))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{
await Utils.TencentSMS.Pull(Context, e, true);
}
Construct(PageId); Construct(PageId, "");
}
else Construct(PageId, "您无权进行此操作");
} }
public async Task<IActionResult> OnPostSignAsync(int PageId) public async Task<IActionResult> OnPostSignAsync(int PageId)
{ {
if (HttpContext.User.HasClaim((c) =>
var stu = Context.Students.ToList();
foreach (var e in stu)
{ {
if (e.Status == status.刚报名) return c.Type == ClaimTypes.Role && (
await Utils.TencentSMS.Send(Context, SMSType.Signed, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); c.Value == "admin" || c.Value == "manager");
} }))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{
if (e.Status == status.刚报名)
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); return Construct(PageId, "");
}
else return Construct(PageId, "您无权进行此操作");
} }
public async Task<IActionResult> OnPostResultRejectAsync(int PageId) public async Task<IActionResult> OnPostResultRejectAsync(int PageId)
{ {
var stu = Context.Students.ToList(); if (HttpContext.User.HasClaim((c) =>
foreach (var e in stu)
{ {
if (e.Status == status.不通过) return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{ {
if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Reject)) if (e.Status == status.不通过)
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, "");
} }
return Construct(PageId); else return Construct(PageId, "您无权进行此操作");
} }
public async Task<IActionResult> OnPostTimeSelectAsync(int PageId) public async Task<IActionResult> OnPostTimeSelectAsync(int PageId)
{ {
var stu = Context.Students.ToList(); if (HttpContext.User.HasClaim((c) =>
foreach (var e in stu)
{ {
if (e.Status != status.不通过 && e.Status != status.已选时间) return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{ {
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); if (e.Status != status.不通过 && e.Status != status.已选时间)
{
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();
return Construct(PageId, "");
} }
Context.SaveChanges(); else return Construct(PageId, "您无权进行此操作");
return Construct(PageId);
} }
public async Task<IActionResult> OnPostResultAccpetAsync(int PageId) public async Task<IActionResult> OnPostResultAcceptAsync(int PageId)
{ {
var stu = Context.Students.ToList(); if (HttpContext.User.HasClaim((c) =>
foreach (var e in stu)
{ {
if (e.Status == status.通过) return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{ {
if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Accept)) if (e.Status == status.通过)
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);
}
}
return Construct(PageId, "");
} }
return Construct(PageId); else return Construct(PageId, "您无权进行此操作");
} }
public async Task<IActionResult> OnPostTimeSetAsync(int PageId)
{
if (HttpContext.User.HasClaim((c) =>
{
return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var stu = Context.Students.ToList();
foreach (var e in stu)
{
var t = Context.Sessions.Find(e.InterviewTime);
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(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
e.Status = status.已确认时间;
}
}
Context.SaveChanges();
return Construct(PageId, "");
}
else return Construct(PageId, "您无权进行此操作");
}
} }
} }
+6 -6
View File
@@ -22,7 +22,7 @@ namespace _2021_backend.Pages.Sessions
[BindProperty] [BindProperty]
[Display(Name = "活动官")] [Display(Name = "活动官")]
public string ChiefGuid { get; set; } public string Chiefint { get; set; }
public List<SelectListItem> ChiefList { get; set; } public List<SelectListItem> ChiefList { get; set; }
@@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGet() 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(); var lst = qlst.ToList().Distinct().ToList();
ChiefList = lst; ChiefList = lst;
return Page(); return Page();
@@ -48,8 +48,8 @@ namespace _2021_backend.Pages.Sessions
{ {
return Page(); return Page();
} }
InterviewTime.Students = new List<Guid>(); InterviewTime.Students = new List<int>();
InterviewTime.Chiefs = new List<Guid>(); InterviewTime.Chiefs = new List<int>();
Session interviewTimeSecond = new Session(); Session interviewTimeSecond = new Session();
if (CreateTwo) if (CreateTwo)
{ {
@@ -62,9 +62,9 @@ namespace _2021_backend.Pages.Sessions
Day = InterviewTime.Day, Day = InterviewTime.Day,
BeginTime = InterviewTime.BeginTime, BeginTime = InterviewTime.BeginTime,
Place = anotherPlace, Place = anotherPlace,
Chiefs = new List<Guid>(), Chiefs = new List<int>(),
SendSMS = InterviewTime.SendSMS, SendSMS = InterviewTime.SendSMS,
Students = new List<Guid>(), Students = new List<int>(),
Capacity = InterviewTime.Capacity Capacity = InterviewTime.Capacity
}; };
Context.Add(interviewTimeSecond); Context.Add(interviewTimeSecond);
+1 -1
View File
@@ -34,7 +34,7 @@
</dl> </dl>
<form method="post"> <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" /> | <input type="submit" value="确定删除" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a> <a asp-page="./Index">Back to List</a>
</form> </form>
+7 -7
View File
@@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGetAsync(string? id) public async Task<IActionResult> OnGetAsync(string? id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
InterviewTime = Context.Sessions.Find(guid); InterviewTime = Context.Sessions.Find(idx);
if (InterviewTime == null) if (InterviewTime == null)
{ {
@@ -41,12 +41,12 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnPostAsync(string? id) public async Task<IActionResult> OnPostAsync(string? id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
InterviewTime = await Context.Sessions.FindAsync(guid); InterviewTime = await Context.Sessions.FindAsync(idx);
if (InterviewTime != null) if (InterviewTime != null)
{ {
@@ -57,15 +57,15 @@ namespace _2021_backend.Pages.Sessions
Student stu = Context.Students.Find(x); Student stu = Context.Students.Find(x);
if (stu != null) if (stu != null)
{ {
stu.InterviewTime = Guid.Empty; stu.InterviewTime = 0;
stu.Timelist.RemoveAll(it => it == guid); stu.Timelist.RemoveAll(it => it == idx);
} }
Context.SaveChanges(); Context.SaveChanges();
} }
} }
foreach(var x in Context.Students) foreach(var x in Context.Students)
{ {
x.Timelist.RemoveAll(it => it == guid); x.Timelist.RemoveAll(it => it == idx);
} }
Context.Sessions.Remove(InterviewTime); Context.Sessions.Remove(InterviewTime);
Context.SaveChanges(); Context.SaveChanges();
+1 -1
View File
@@ -64,6 +64,6 @@
</dl> </dl>
</div> </div>
<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> <a asp-page="./Index">Back to List</a>
</div> </div>
+2 -2
View File
@@ -23,12 +23,12 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGetAsync(string? id) public async Task<IActionResult> OnGetAsync(string? id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
CurSession = Context.Sessions.Find(guid); CurSession = Context.Sessions.Find(idx);
if (CurSession == null) if (CurSession == null)
{ {
return NotFound(); return NotFound();
+9 -9
View File
@@ -13,8 +13,8 @@
<div class="col-md-4"> <div class="col-md-4">
<form method="post"> <form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="CurSession.Guid" /> <input type="hidden" asp-for="CurSession.Id" />
<input type="hidden" asp-for="CurGuid"> <input type="hidden" asp-for="Curint">
<div class="form-group"> <div class="form-group">
<label asp-for="newDay" class="control-label"></label> <label asp-for="newDay" class="control-label"></label>
<input asp-for="newDay" class="form-control" /> <input asp-for="newDay" class="form-control" />
@@ -51,7 +51,7 @@
<form method="post"> <form method="post">
<label class="col-sm-2">添加一个</label> <label class="col-sm-2">添加一个</label>
<select asp-items=Model.Stulist id="stuselect" asp-for="addedStu" class="col-sm-2"></select> <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" /> <input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="Add" />
</form> </form>
<br /> <br />
@@ -76,11 +76,11 @@
<td>@Html.DisplayFor(model=>stu.Name)</td> <td>@Html.DisplayFor(model=>stu.Name)</td>
<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"> <div style="float:left">
<form method="post"> <form method="post">
<input type="hidden" asp-for="CurGuid"> <input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Guid.ToString() /> <input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Id.ToString() />
</form> </form>
</div> </div>
@@ -98,7 +98,7 @@
<form method="post"> <form method="post">
<label class="col-sm-2">添加一个</label> <label class="col-sm-2">添加一个</label>
<select id="chiefselect"asp-items=Model.ChiefList asp-for="addedChief" class="col-sm-2"></select> <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" /> <input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="AddChief" />
</form> </form>
<br /> <br />
@@ -121,8 +121,8 @@
<td> <td>
<div style="float:left"> <div style="float:left">
<form method="post"> <form method="post">
<input type="hidden" asp-for="CurGuid"> <input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Guid.ToString() /> <input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Id.ToString() />
</form> </form>
</div> </div>
</td> </td>
+33 -33
View File
@@ -24,7 +24,7 @@ namespace _2021_backend.Pages.Sessions
public Session CurSession { get; set; } public Session CurSession { get; set; }
[BindProperty] [BindProperty]
public string CurGuid { get; set; } public string Curint { get; set; }
[BindProperty] [BindProperty]
public string ChiefSearch { get; set; } public string ChiefSearch { get; set; }
@@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
public List<SelectListItem> Stulist { get; set; } public List<SelectListItem> Stulist { get; set; }
[BindProperty] [BindProperty]
public Guid addedChief { get; set; } public int addedChief { get; set; }
[BindProperty] [BindProperty]
public string addedStu { get; set; } public string addedStu { get; set; }
@@ -71,13 +71,13 @@ namespace _2021_backend.Pages.Sessions
public IActionResult Construct(string id) public IActionResult Construct(string id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
CurGuid = id; Curint = id;
CurSession = Context.Sessions.Find(guid); CurSession = Context.Sessions.Find(idx);
newDay = CurSession.Day; newDay = CurSession.Day;
newTime = CurSession.BeginTime; newTime = CurSession.BeginTime;
@@ -86,10 +86,10 @@ namespace _2021_backend.Pages.Sessions
newPlace = CurSession.Place; newPlace = CurSession.Place;
if (CurSession == null) return RedirectToPage("./Index", new { errmsg = "未找到该活动场次" }); 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(); 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(); Stulist = slst.ToList().Distinct().ToList();
return Page(); return Page();
} }
@@ -103,7 +103,7 @@ namespace _2021_backend.Pages.Sessions
// more details, see https://aka.ms/RazorPagesCRUD. // more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync() 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.SendSMS = sendSMS;
ssn.Day = newDay; ssn.Day = newDay;
ssn.BeginTime = newTime; ssn.BeginTime = newTime;
@@ -116,73 +116,73 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnPostDeleteAsync(string id) public async Task<IActionResult> OnPostDeleteAsync(string id)
{ {
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); CurSession = Context.Sessions.Find(int.Parse(Curint));
var guid = Guid.Parse(id); var idx = int.Parse(id);
if (!string.IsNullOrEmpty(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; Context.Students.Find(idx).InterviewTime = 0;
CurSession.Students.RemoveAll(it => it == guid); CurSession.Students.RemoveAll(it => it == idx);
} }
Context.SaveChanges(); Context.SaveChanges();
} }
return Construct(CurGuid); return Construct(Curint);
} }
public async Task<IActionResult> OnPostAddAsync() public async Task<IActionResult> OnPostAddAsync()
{ {
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); CurSession = Context.Sessions.Find(int.Parse(Curint));
var guid = Guid.Parse(addedStu); var idx = int.Parse(addedStu);
if (!string.IsNullOrEmpty(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); var stu = Context.Students.Find(idx);
if(stu.InterviewTime != Guid.Empty) if(stu.InterviewTime != 0)
{ {
var oldtime = Context.Sessions.Find(stu.InterviewTime); var oldtime = Context.Sessions.Find(stu.InterviewTime);
if(oldtime != null) if(oldtime != null)
{ {
oldtime.Students.RemoveAll(s => s == stu.Guid); oldtime.Students.RemoveAll(s => s == stu.Id);
Context.SaveChanges(); Context.SaveChanges();
} }
} }
stu.InterviewTime = CurSession.Guid; stu.InterviewTime = CurSession.Id;
stu.Status = status.已选时间; stu.Status = status.已选时间;
CurSession.Students.Add(guid); CurSession.Students.Add(idx);
} }
Context.SaveChanges(); Context.SaveChanges();
} }
return Construct(CurGuid); return Construct(Curint);
} }
public async Task<IActionResult> OnPostAddChiefAsync() public async Task<IActionResult> OnPostAddChiefAsync()
{ {
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); CurSession = Context.Sessions.Find(int.Parse(Curint));
if (Context.Users.Any(it => it.Guid == addedChief)) if (Context.Users.Any(it => it.Id == addedChief))
{ {
CurSession.Chiefs.Add(addedChief); CurSession.Chiefs.Add(addedChief);
} }
Context.SaveChanges(); Context.SaveChanges();
return Construct(CurGuid); return Construct(Curint);
} }
public async Task<IActionResult> OnPostDeleteChiefAsync(string id) public async Task<IActionResult> OnPostDeleteChiefAsync(string id)
{ {
var guid = Guid.Parse(id); var idx = int.Parse(id);
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid)); CurSession = Context.Sessions.Find(int.Parse(Curint));
if (CurSession.Chiefs.Contains(guid)) if (CurSession.Chiefs.Contains(idx))
{ {
CurSession.Chiefs.Remove(guid); CurSession.Chiefs.Remove(idx);
} }
Context.SaveChanges(); 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);
} }
} }
} }
+5 -5
View File
@@ -75,10 +75,10 @@
@Html.DisplayNameFor(model => model.LoadedSessions[0].Chiefs) @Html.DisplayNameFor(model => model.LoadedSessions[0].Chiefs)
</th> </th>
<th> <th>
剩余可用人数 容量
</th> </th>
<th> <th>
容量 剩余容量
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.LoadedSessions[0].SendSMS) @Html.DisplayNameFor(model => model.LoadedSessions[0].SendSMS)
@@ -157,9 +157,9 @@
} }
</td> </td>
<td> <td>
<a asp-page="./Edit" asp-route-id="@item.Guid">编辑</a> | <a asp-page="./Edit" asp-route-id="@item.Id">编辑</a> |
<a asp-page="./Delete" asp-route-id="@item.Guid">删除</a> | <a asp-page="./Delete" asp-route-id="@item.Id">删除</a> |
<a asp-page-handler="Reset" asp-route-id="@item.Guid">重置</a> <a asp-page-handler="Reset" asp-route-id="@item.Id">重置</a>
</td> </td>
</tr> </tr>
} }
+178 -109
View File
@@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Text.Json; using System.Text.Json;
using System.IO; using System.IO;
using System.Security.Claims;
namespace _2021_backend.Pages.Sessions namespace _2021_backend.Pages.Sessions
{ {
@@ -89,16 +90,16 @@ namespace _2021_backend.Pages.Sessions
return Construct(errmsg); 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); var s = Context.Sessions.Find(id);
foreach(var st in s.Students) foreach(var st in s.Students)
{ {
var e = Context.Students.Find(st); var e = Context.Students.Find(st);
e.Status = status.需调整时间; e.Status = status.需调整时间;
e.InterviewTime = Guid.Empty; e.InterviewTime = 0;
} }
s.Students.Clear(); s.Students.Clear();
} }
@@ -124,159 +125,227 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnPostArrangeAsync() public async Task<IActionResult> OnPostArrangeAsync()
{ {
if (Utils.Arranger.Arrange(Context)) return Construct(""); if (HttpContext.User.HasClaim((c) =>
else return Construct("排班失败,无法满足条件"); {
return c.Type == ClaimTypes.Role&& (
c.Value == "admin" || c.Value == "manager");
})){
if (Utils.Arranger.Arrange(Context)) return Construct("");
else return Construct("排班失败,无法满足条件");
}
else
{
return Construct("您无权进行此操作");
}
} }
public async Task<IActionResult> OnPostClearAllAsync() public async Task<IActionResult> OnPostClearAllAsync()
{ {
foreach(var s in Context.Students)
if (HttpContext.User.HasClaim((c) =>
{ {
s.InterviewTime = Guid.Empty; return c.Type == ClaimTypes.Role && (
s.Status = status.需调整时间; c.Value == "admin" || c.Value == "manager");
s.Timelist.Clear(); }))
}
Context.SaveChanges();
foreach(var s in Context.Sessions)
{ {
Context.Sessions.Remove(s); foreach (var s in Context.Students)
{
s.InterviewTime = 0;
s.Status = status.需调整时间;
s.Timelist.Clear();
}
Context.SaveChanges();
foreach (var s in Context.Sessions)
{
Context.Sessions.Remove(s);
}
Context.SaveChanges();
return Construct("");
}
else
{
return Construct("您无权进行此操作");
} }
Context.SaveChanges();
return Construct("");
} }
public async Task<IActionResult> OnPostResetAllAsync() public async Task<IActionResult> OnPostResetAllAsync()
{ {
var stus = Context.Students.ToList(); if (HttpContext.User.HasClaim((c) =>
foreach (var s in stus)
{ {
if(s.Status == status.已选时间) return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var stus = Context.Students.ToList();
foreach (var s in stus)
{ {
s.InterviewTime = Guid.Empty; if (s.Status == status.已选时间)
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
s.Timelist.Sort((Guid a, Guid b) =>
{ {
var x = Context.Sessions.Find(a); s.InterviewTime = 0;
var y = Context.Sessions.Find(b); s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
var k1 = x.Day.CompareTo(y.Day); s.Timelist.Sort((int a, int b) =>
var k2 = x.BeginTime.CompareTo(y.BeginTime); {
return k1 != 0 ? k1 : k2; var x = Context.Sessions.Find(a);
}); var y = Context.Sessions.Find(b);
var k1 = x.Day.CompareTo(y.Day);
var k2 = x.BeginTime.CompareTo(y.BeginTime);
return k1 != 0 ? k1 : k2;
});
}
} }
Context.SaveChanges();
foreach (var s in Context.Sessions)
{
s.Students.Clear();
}
Context.SaveChanges();
return Construct("");
} }
Context.SaveChanges(); else
foreach (var s in Context.Sessions)
{ {
s.Students.Clear(); return Construct("您无权进行此操作");
} }
Context.SaveChanges();
return Construct("");
} }
public async Task<IActionResult> OnPostSaveAsync() public async Task<IActionResult> OnPostSaveAsync()
{ {
var lst = Context.Sessions.ToList(); if (HttpContext.User.HasClaim((c) =>
var str = JsonSerializer.Serialize(lst); {
Console.WriteLine("Saving arrangement: " + str); return c.Type == ClaimTypes.Role && (
if(!Directory.Exists("./saves")) Directory.CreateDirectory("./saves/"); c.Value == "admin" || c.Value == "manager");
System.IO.File.WriteAllText($"./saves/{DateTime.Now.ToString("MM-dd-hh-mm-ss")}.txt", str); }))
return Construct(""); {
var lst = Context.Sessions.ToList();
var str = JsonSerializer.Serialize(lst);
Console.WriteLine("Saving arrangement: " + str);
if (!Directory.Exists("./saves")) Directory.CreateDirectory("./saves/");
System.IO.File.WriteAllText($"./saves/{DateTime.Now.ToString("MM-dd-hh-mm-ss")}.txt", str);
return Construct("");
}
else
{
return Construct("您无权进行此操作");
}
} }
public async Task<IActionResult> OnPostTidyAsync() public async Task<IActionResult> OnPostTidyAsync()
{ {
var stus = Context.Students.ToList(); if (HttpContext.User.HasClaim((c) =>
var sess = Context.Sessions.ToList();
foreach(var i in stus)
{ {
var tm = i.Timelist; return c.Type == ClaimTypes.Role && (
var ntm = new List<Session>(); c.Value == "admin" || c.Value == "manager");
foreach(var j in tm) }))
{
var stus = Context.Students.ToList();
var sess = Context.Sessions.ToList();
foreach (var i in stus)
{ {
var k = sess.Find(it => it.Guid == j); var tm = i.Timelist;
ntm.Add(k); var ntm = new List<Session>();
} foreach (var j in tm)
ntm.Sort((Session a,Session b) =>
{
var x = a.Day.CompareTo(b.Day);
var y = a.BeginTime.CompareTo(b.BeginTime);
return x != 0 ? x : y;
});
List<Guid> nl = new List<Guid>();
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; var k = sess.Find(it => it.Id == j);
nl.Add(j.Guid); ntm.Add(k);
} }
else ntm.Sort((Session a, Session b) =>
{ {
nl.Add(j.Guid); var x = a.Day.CompareTo(b.Day);
var y = a.BeginTime.CompareTo(b.BeginTime);
return x != 0 ? x : y;
});
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.Id))) continue;
nl.Add(j.Id);
}
else
{
nl.Add(j.Id);
}
} }
i.Timelist = nl;
} }
i.Timelist = nl; Context.SaveChanges();
return Construct("");
}
else
{
return Construct("您无权进行此操作");
} }
Context.SaveChanges();
return Construct("");
} }
public async Task<IActionResult> OnPostLoadAsync() public async Task<IActionResult> OnPostLoadAsync()
{ {
var str = ""; if (HttpContext.User.HasClaim((c) =>
{
return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
var str = "";
List<Session> loads = new List<Session>(); List<Session> loads = new List<Session>();
if (!string.IsNullOrEmpty(savename)) str = System.IO.File.ReadAllText(savename); if (!string.IsNullOrEmpty(savename)) str = System.IO.File.ReadAllText(savename);
loads = JsonSerializer.Deserialize<List<Session>>(str); loads = JsonSerializer.Deserialize<List<Session>>(str);
var stus = Context.Students.ToList(); var stus = Context.Students.ToList();
foreach (var s in stus) foreach (var s in stus)
{
if (s.Status == status.已选时间)
{ {
s.InterviewTime = Guid.Empty; if (s.Status == status.已选时间)
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
s.Timelist.Sort((Guid a, Guid b) =>
{ {
var x = Context.Sessions.Find(a); s.InterviewTime = 0;
var y = Context.Sessions.Find(b); s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
var k1 = x.Day.CompareTo(y.Day); s.Timelist.Sort((int a, int b) =>
var k2 = x.BeginTime.CompareTo(y.BeginTime);
return k1 != 0 ? k1 : k2;
});
}
}
Context.SaveChanges();
foreach (var s in Context.Sessions)
{
s.Students.Clear();
}
Context.SaveChanges();
foreach(var item in loads)
{
Session s = Context.Sessions.Find(item.Guid);
if(s != null)
{
s.BeginTime = item.BeginTime;
s.Day = item.Day;
s.Capacity = item.Capacity;
s.SendSMS = item.SendSMS;
s.Chiefs = item.Chiefs;
s.Students = new List<Guid>();
foreach(var s2 in item.Students)
{
if (Context.Students.Any(k => k.Guid == s2))
{ {
Context.Students.Find(s2).InterviewTime = item.Guid; var x = Context.Sessions.Find(a);
s.Students.Add(s2); var y = Context.Sessions.Find(b);
var k1 = x.Day.CompareTo(y.Day);
var k2 = x.BeginTime.CompareTo(y.BeginTime);
return k1 != 0 ? k1 : k2;
});
}
}
Context.SaveChanges();
foreach (var s in Context.Sessions)
{
s.Students.Clear();
}
Context.SaveChanges();
foreach (var item in loads)
{
Session s = Context.Sessions.Find(item.Id);
if (s != null)
{
s.BeginTime = item.BeginTime;
s.Day = item.Day;
s.Capacity = item.Capacity;
s.SendSMS = item.SendSMS;
s.Chiefs = item.Chiefs;
s.Students = new List<int>();
foreach (var s2 in item.Students)
{
if (Context.Students.Any(k => k.Id == s2))
{
Context.Students.Find(s2).InterviewTime = item.Id;
s.Students.Add(s2);
}
} }
} }
} }
Context.SaveChanges();
return Construct("");
}
else
{
return Construct("您无权进行此操作");
} }
Context.SaveChanges();
return Construct("");
} }
} }
} }
+23 -23
View File
@@ -6,7 +6,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - 2021 精品活动后台</title> <title>@ViewData["Title"] - 2022 3D打印后台</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" /> <link rel="stylesheet" href="~/css/site.css" />
</head> </head>
@@ -14,7 +14,7 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-page="/Index">2021纳新后台</a> <a class="navbar-brand" asp-area="" asp-page="/Index">2022 3D打印后台</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@@ -38,29 +38,29 @@
<span class="nav-item">欢迎您,@(HttpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value)</span> <span class="nav-item">欢迎您,@(HttpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value)</span>
</div> </div>
} }
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">首页</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Students/Index">已报名学生</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Submissions/Index">提交记录</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Message/Index">短信</a>
</li>
@if (HttpContextAccessor.HttpContext.User.HasClaim(EvaClaimTypes.IsManager, "true"))
{
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Users/Index">后台用户管理</a> <a class="nav-link text-dark" asp-area="" asp-page="/Index">首页</a>
</li> </li>
} <li class="nav-item">
<li class="nav-item"> <a class="nav-link text-dark" asp-area="" asp-page="/Students/Index">已报名学生</a>
<a class="nav-link text-dark" asp-area="" asp-page="/Sessions/Index">活动排班</a> </li>
</li> <li class="nav-item">
</ul> <a class="nav-link text-dark" asp-area="" asp-page="/Submissions/Index">提交记录</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Message/Index">短信</a>
</li>
@if (HttpContextAccessor.HttpContext.User.HasClaim(EvaClaimTypes.IsManager, "true"))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Users/Index">后台用户管理</a>
</li>
}
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Sessions/Index">活动排班</a>
</li>
</ul>
</div> </div>
</div> </div>
</nav> </nav>
+1 -1
View File
@@ -75,7 +75,7 @@
</dl> </dl>
<form method="post"> <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" /> | <input type="submit" value="删除" class="btn btn-danger" /> |
<a asp-page="./Index">返回列表</a> <a asp-page="./Index">返回列表</a>
</form> </form>
+3 -3
View File
@@ -28,9 +28,9 @@ namespace _2021_backend.Pages.Students
{ {
return NotFound(); 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) if (Student == null)
{ {
@@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students
{ {
return NotFound(); return NotFound();
} }
Guid id = Guid.Parse(idstr); int id = int.Parse(idstr);
Student = await Context.Students.FindAsync(id); Student = await Context.Students.FindAsync(id);
+39 -13
View File
@@ -70,7 +70,7 @@
<h5>此人的最终得分 : @Html.DisplayFor(model => model.Student.Score)</h5> <h5>此人的最终得分 : @Html.DisplayFor(model => model.Student.Score)</h5>
<form method="post" class="form-inline m-2"> <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 class="mb-2">
操作 操作
</div> </div>
@@ -82,9 +82,35 @@
</div> </div>
<div class="mb-2"> <div class="mb-2">
给他打分 给他打分
<input asp-for="score" class="form-control"/> <input asp-for="score" class="form-control" />
<input type="submit" value="打" class="btn btn-warning" style="margin:5px" asp-page-handler="Rank" /> <input type="submit" value="打分" class="btn btn-warning" style="margin:5px" asp-page-handler="Rank" />
</div> </div>
<div>
</div>
<div class="mb-2">
作品链接:
@{
if(Model.Student.Uploads == null)
{
<div>尚未提交作品</div>
}
else
{
var fd = Model.Context.FileDesc.Find(Model.Student.Uploads.Last());
if (fd == null)
{
<div>尚未提交作品</div>
}
else
{
<a href="https://@Html.DisplayFor(model => fd.Path)">点我</a>
}
}
}
</div>
</form> </form>
<br /> <br />
@@ -131,7 +157,7 @@
<span asp-validation-for="NewComment" class="text-danger"></span> <span asp-validation-for="NewComment" class="text-danger"></span>
</div> </div>
<div class="form-group"> <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" /> <input type="submit" value="→" class="btn btn-primary btn-sm" />
</div> </div>
</form> </form>
@@ -161,7 +187,7 @@
</h4> </h4>
<table class="table"> <table class="table">
<thead> <thead>
<tr > <tr>
<th>地点</th> <th>地点</th>
<th>日期</th> <th>日期</th>
<th>时间</th> <th>时间</th>
@@ -175,7 +201,7 @@
{ {
var it = Model.Student.Timelist[i]; var it = Model.Student.Timelist[i];
var dt = Model.Context.Sessions.Find(it); 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> <tr>
<td> <td>
@@ -211,9 +237,9 @@
</td> </td>
<td> <td>
<form method="post" class="form-inline"> <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> <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> </form>
</td> </td>
</tr> </tr>
@@ -225,7 +251,7 @@
Ta的短信 Ta的短信
</h4> </h4>
<form method="post"> <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="拉取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="Sign" />
<input type="submit" value="发送活动场次确认短信" class="btn btn-primary" asp-page-handler="Time" /> <input type="submit" value="发送活动场次确认短信" class="btn btn-primary" asp-page-handler="Time" />
@@ -293,7 +319,7 @@
<th> <th>
@Html.DisplayNameFor(model => model.SubmissionSample.Sex) @Html.DisplayNameFor(model => model.SubmissionSample.Sex)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.SubmissionSample.Yard) @Html.DisplayNameFor(model => model.SubmissionSample.Yard)
</th> </th>
<th> <th>
@@ -355,8 +381,8 @@
@Html.DisplayFor(modelItem => sub.SubmitTime) @Html.DisplayFor(modelItem => sub.SubmitTime)
</td> </td>
<td> <td>
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Guid">Edit</a> | <a asp-page="/Submissions/Edit" asp-route-strid="@sub.Id">Edit</a> |
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Guid">Details</a> <a asp-page="/Submissions/Details" asp-route-strid="@sub.Id">Details</a>
</td> </td>
</tr> </tr>
} }
@@ -366,6 +392,6 @@
<div> <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> <a asp-page="./Index">返回列表</a>
</div> </div>
+40 -40
View File
@@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students
{ {
return NotFound(); return NotFound();
} }
Guid id = Guid.Parse(idstr); int id = int.Parse(idstr);
Student = Context.Students.Find(id); Student = Context.Students.Find(id);
if (Student == null) if (Student == null)
{ {
@@ -62,7 +62,7 @@ namespace _2021_backend.Pages.Students
Sessions.Add(tm); Sessions.Add(tm);
} }
Messages = Context.SMS.Where(it => it.Host == id).ToList(); 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) => { Sessions.Sort((Session a, Session b) => {
var x = a.Day.CompareTo(b.Day); var x = a.Day.CompareTo(b.Day);
var y = a.BeginTime.CompareTo(b.BeginTime); var y = a.BeginTime.CompareTo(b.BeginTime);
@@ -84,60 +84,60 @@ namespace _2021_backend.Pages.Students
if (!string.IsNullOrWhiteSpace(NewComment)) if (!string.IsNullOrWhiteSpace(NewComment))
{ {
var cmt = new Comment(); var cmt = new Comment();
cmt.Student = Student.Guid; cmt.Student = Student.Id;
cmt.Content = NewComment; cmt.Content = NewComment;
cmt.Operator = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value); cmt.Operator = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value);
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
stu.Comments.Add(cmt.Guid); stu.Comments.Add(cmt.Id);
Context.Comments.Add(cmt); Context.Comments.Add(cmt);
Context.SaveChanges(); Context.SaveChanges();
} }
Construct(Student.Guid.ToString()); Construct(Student.Id.ToString());
return RedirectToPage(new { idstr = Student.Guid.ToString() }); return RedirectToPage(new { idstr = Student.Id.ToString() });
} }
public async Task<IActionResult> OnPostAcceptAsync() public async Task<IActionResult> OnPostAcceptAsync()
{ {
Student = Context.Students.Find(Student.Guid); Student = Context.Students.Find(Student.Id);
Student.Status = status.通过; Student.Status = status.通过;
Context.SaveChanges(); Context.SaveChanges();
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList(); CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList();
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList(); Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList();
Construct(Student.Guid.ToString()); Construct(Student.Id.ToString());
return RedirectToPage(new { idstr = Student.Guid.ToString() }); return RedirectToPage(new { idstr = Student.Id.ToString() });
} }
public async Task<IActionResult> OnPostRejectAsync() public async Task<IActionResult> OnPostRejectAsync()
{ {
Student = Context.Students.Find(Student.Guid); Student = Context.Students.Find(Student.Id);
Student.Status = status.不通过; Student.Status = status.不通过;
Context.SaveChanges(); Context.SaveChanges();
Student.Score = 0; Student.Score = 0;
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList(); CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList();
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList(); Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList();
Construct(Student.Guid.ToString()); Construct(Student.Id.ToString());
return RedirectToPage(new { idstr = Student.Guid.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); var st = Context.Students.Find(stu);
if (st != null) 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); var tm = Context.Sessions.Find(time);
if (tm.Students.Count < tm.Capacity) if (tm.Students.Count < tm.Capacity)
{ {
if (st.InterviewTime != Guid.Empty) if (st.InterviewTime != 0)
{ {
var tmold = Context.Sessions.Find(st.InterviewTime); var tmold = Context.Sessions.Find(st.InterviewTime);
if (tmold != null) if (tmold != null)
{ {
tmold.Students.RemoveAll(it => it == st.Guid); tmold.Students.RemoveAll(it => it == st.Id);
Context.SaveChanges(); 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() public async Task<IActionResult> OnPostPullAsync()
{ {
await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Guid), true); await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Id), true);
return Construct(Student.Guid.ToString()); return Construct(Student.Id.ToString());
} }
public async Task<IActionResult> OnPostRankAsync() public async Task<IActionResult> OnPostRankAsync()
{ {
var s = Context.Students.Find(Student.Guid); var s = Context.Students.Find(Student.Id);
s.Score = score; s.Score = score;
s.Status = status.已评分; s.Status = status.已评分;
Context.SaveChanges(); Context.SaveChanges();
return Construct(Student.Guid.ToString()); return Construct(Student.Id.ToString());
} }
public async Task<IActionResult> OnPostResultAsync() public async Task<IActionResult> OnPostResultAsync()
{ {
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
if (stu.Status == status.通过) 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.不通过) 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); 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.Guid.ToString()); return Construct(Student.Id.ToString());
} }
public async Task<IActionResult> OnPostSignAsync() public async Task<IActionResult> OnPostSignAsync()
{ {
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); 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.Guid.ToString()); return Construct(Student.Id.ToString());
} }
public async Task<IActionResult> OnPostSelectTimeAsync() public async Task<IActionResult> OnPostSelectTimeAsync()
{ {
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); 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.需调整时间; stu.Status = status.需调整时间;
Context.SaveChanges(); Context.SaveChanges();
return Construct(Student.Guid.ToString()); return Construct(Student.Id.ToString());
} }
public async Task<IActionResult> OnPostTimeAsync() public async Task<IActionResult> OnPostTimeAsync()
{ {
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); 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.已确认时间; stu.Status = status.已确认时间;
Context.SaveChanges(); Context.SaveChanges();
return Construct(Student.Guid.ToString()); return Construct(Student.Id.ToString());
} }
} }
} }
+1 -1
View File
@@ -13,7 +13,7 @@
<div class="col-md-4"> <div class="col-md-4">
<form method="post"> <form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <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"> <div class="form-group">
<label asp-for="Student.Name" class="control-label"></label> <label asp-for="Student.Name" class="control-label"></label>
<input asp-for="Student.Name" class="form-control" /> <input asp-for="Student.Name" class="form-control" />
+5 -5
View File
@@ -26,8 +26,8 @@ namespace _2021_backend.Pages.Students
{ {
return NotFound(); return NotFound();
} }
Guid id = Guid.Parse(idstr); int id = int.Parse(idstr);
Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Guid == id); Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Id == id);
if (Student == null) if (Student == null)
{ {
@@ -40,7 +40,7 @@ namespace _2021_backend.Pages.Students
// For more details, see https://aka.ms/RazorPagesCRUD. // For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync() public async Task<IActionResult> OnPostAsync()
{ {
var stu = Context.Students.Find(Student.Guid); var stu = Context.Students.Find(Student.Id);
stu.Status = Student.Status; stu.Status = Student.Status;
stu.Email = Student.Email; stu.Email = Student.Email;
stu.Name = Student.Name; stu.Name = Student.Name;
@@ -53,9 +53,9 @@ namespace _2021_backend.Pages.Students
return RedirectToPage("./Index"); 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);
} }
} }
} }
+6 -5
View File
@@ -35,6 +35,7 @@
</div> </div>
<button type="submit" class="btn btn-outline-primary m-2">搜索</button> <button type="submit" class="btn btn-outline-primary m-2">搜索</button>
<input type="submit" value="Cleanup" class="btn btn-primary" asp-page-handler="Finalize" /> <input type="submit" value="Cleanup" class="btn btn-primary" asp-page-handler="Finalize" />
<input type="submit" value="Reset Timeselect" class="btn btn-primary" asp-page-handler="ReselectAll" />
</form> </form>
<table class="table"> <table class="table">
<thead> <thead>
@@ -104,10 +105,10 @@
} }
</td> </td>
<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>
<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>
<td> <td>
@Html.DisplayFor(modelItem => item.Sex) @Html.DisplayFor(modelItem => item.Sex)
@@ -134,9 +135,9 @@
@Html.DisplayFor(modelItem => item.RegisterTime) @Html.DisplayFor(modelItem => item.RegisterTime)
</th> </th>
<td> <td>
<a asp-page="./Edit" 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.Guid.ToString()">审阅</a> | <a asp-page="./Details" asp-route-idstr="@item.Id.ToString()">审阅</a> |
<a asp-page="./Delete" asp-route-idstr="@item.Guid.ToString()">删除</a> <a asp-page="./Delete" asp-route-idstr="@item.Id.ToString()">删除</a>
</td> </td>
</tr> </tr>
} }
+41 -7
View File
@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using _2021_backend.Utils; using _2021_backend.Utils;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Security.Claims;
namespace _2021_backend.Pages.Students namespace _2021_backend.Pages.Students
{ {
@@ -96,15 +97,48 @@ namespace _2021_backend.Pages.Students
public async Task<IActionResult> OnPostFinalizeAsync(int? pageId, string errInfo) public async Task<IActionResult> OnPostFinalizeAsync(int? pageId, string errInfo)
{ {
if (pageId == null) pageId = 0; if (HttpContext.User.HasClaim((c) =>
foreach(var s in Context.Students)
{ {
if (s.RegisterTime.CompareTo(new DateTime(2021, 11, 11)) > 0) s.Status = status.不通过; return c.Type == ClaimTypes.Role && (
else if (s.Timelist.Count == 0) s.Status = status.需调整时间; c.Value == "admin" || c.Value == "manager");
}))
{
if (pageId == null) pageId = 0;
foreach (var s in Context.Students)
{
if (s.RegisterTime.CompareTo(new DateTime(2021, 11, 11)) > 0) s.Status = status.不通过;
else if (s.Timelist.Count == 0 && s.Status != status.不通过) s.Status = status.需调整时间;
}
Context.SaveChanges();
return Construct((int)pageId, errInfo);
}
else
{
return Construct(pageId??0, "您无权进行此操作");
}
}
public async Task<IActionResult> OnPostReselectAllAsync(int? pageId,string errInfo)
{
if (HttpContext.User.HasClaim((c) =>
{
return c.Type == ClaimTypes.Role && (
c.Value == "admin" || c.Value == "manager");
}))
{
if (pageId == null) pageId = 0;
foreach (var s in Context.Students)
{
if (s.Status != status.不通过) s.Status = status.需调整时间;
}
Context.SaveChanges();
return Construct((int)pageId, errInfo);
}
else
{
return Construct(pageId ?? 0, "您无权进行此操作");
} }
Context.SaveChanges();
return Construct((int)pageId, errInfo);
} }
} }
} }
+2 -2
View File
@@ -37,7 +37,7 @@ namespace _2021_backend.Pages.Submissions
{ {
stu = Student.create(Submission); stu = Student.create(Submission);
stu.Status = status.刚报名; 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(); var lst = q2.ToList();
stu.Timelist = lst; stu.Timelist = lst;
Context.Students.Add(stu); Context.Students.Add(stu);
@@ -47,7 +47,7 @@ namespace _2021_backend.Pages.Submissions
stu = q.FirstOrDefault(); stu = q.FirstOrDefault();
stu.Update(Submission); stu.Update(Submission);
} }
Submission.Host = stu.Guid; Submission.Host = stu.Id;
Context.Submissions.Add(Submission); Context.Submissions.Add(Submission);
Context.SaveChanges(); Context.SaveChanges();
+2 -2
View File
@@ -69,8 +69,8 @@
</dl> </dl>
<form method="post"> <form method="post">
<input type="hidden" asp-for="Submission.Guid" /> <input type="hidden" asp-for="Submission.Id" />
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Guid.ToString()"/> | <input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Id.ToString()"/> |
<a asp-page="./Index">返回列表</a> <a asp-page="./Index">返回列表</a>
</form> </form>
</div> </div>
+4 -4
View File
@@ -24,12 +24,12 @@ namespace _2021_backend.Pages.Submissions
public async Task<IActionResult> OnGetAsync(string? strid) public async Task<IActionResult> OnGetAsync(string? strid)
{ {
Guid id = Guid.Parse(strid); int id = int.Parse(strid);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
Submission = Context.Submissions.FirstOrDefault(m => m.Guid == id); Submission = Context.Submissions.FirstOrDefault(m => m.Id == id);
if (Submission == null) if (Submission == null)
{ {
@@ -38,7 +38,7 @@ namespace _2021_backend.Pages.Submissions
return Page(); return Page();
} }
public async Task<IActionResult> OnPostAsync(Guid? id) public async Task<IActionResult> OnPostAsync(int? id)
{ {
if (id == null) if (id == null)
{ {
@@ -51,7 +51,7 @@ namespace _2021_backend.Pages.Submissions
var stu = Context.Students.Find(Submission.Host); var stu = Context.Students.Find(Submission.Host);
if (stu != null) if (stu != null)
{ {
stu.Submissions.Remove(Submission.Guid); stu.Submissions.Remove(Submission.Id);
} }
Context.Submissions.Remove(Submission); Context.Submissions.Remove(Submission);
Context.SaveChanges(); Context.SaveChanges();
+1 -1
View File
@@ -74,6 +74,6 @@
</dl> </dl>
</div> </div>
<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> <a asp-page="./Index">返回列表</a>
</div> </div>
+2 -2
View File
@@ -28,8 +28,8 @@ namespace _2021_backend.Pages.Submissions
{ {
return NotFound(); return NotFound();
} }
Guid id = Guid.Parse(strid); int id = int.Parse(strid);
Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Guid == id); Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Id == id);
if (Submission == null) if (Submission == null)
{ {
+1 -1
View File
@@ -13,7 +13,7 @@
<div class="col-md-4"> <div class="col-md-4">
<form method="post"> <form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <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"> <div class="form-group">
<label asp-for="Submission.Name" class="control-label"></label> <label asp-for="Submission.Name" class="control-label"></label>
<input asp-for="Submission.Name" class="form-control" /> <input asp-for="Submission.Name" class="form-control" />
+5 -5
View File
@@ -25,13 +25,13 @@ namespace _2021_backend.Pages.Submissions
public async Task<IActionResult> OnGetAsync(string? strid) public async Task<IActionResult> OnGetAsync(string? strid)
{ {
Guid id = Guid.Parse(strid); int id = int.Parse(strid);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Guid == id); Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Id == id);
if (Submission == null) if (Submission == null)
{ {
@@ -57,7 +57,7 @@ namespace _2021_backend.Pages.Submissions
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
if (!SubmissionExists(Submission.Guid)) if (!SubmissionExists(Submission.Id))
{ {
return NotFound(); return NotFound();
} }
@@ -70,9 +70,9 @@ namespace _2021_backend.Pages.Submissions
return RedirectToPage("./Index"); 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);
} }
} }
} }
+3 -3
View File
@@ -75,9 +75,9 @@
@Html.DisplayFor(modelItem => item.SubmitTime) @Html.DisplayFor(modelItem => item.SubmitTime)
</td> </td>
<td> <td>
<a asp-page="./Edit" 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.Guid.ToString()">详细信息</a> | <a asp-page="./Details" asp-route-strid="@item.Id.ToString()">详细信息</a> |
<a asp-page="./Delete" asp-route-strid="@item.Guid.ToString()">删除</a> <a asp-page="./Delete" asp-route-strid="@item.Id.ToString()">删除</a>
</td> </td>
</tr> </tr>
} }
+1 -1
View File
@@ -34,7 +34,7 @@
</dl> </dl>
<form method="post"> <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" /> | <input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a> <a asp-page="./Index">Back to List</a>
</form> </form>
+4 -4
View File
@@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Users
public async Task<IActionResult> OnGetAsync(string id) public async Task<IActionResult> OnGetAsync(string id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
User = _context.Users.Find(guid); User = _context.Users.Find(idx);
if (User == null) if (User == null)
{ {
@@ -41,13 +41,13 @@ namespace _2021_backend.Pages.Users
public async Task<IActionResult> OnPostAsync(string id) public async Task<IActionResult> OnPostAsync(string id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
User = _context.Users.Find(id); User = _context.Users.Find(idx);
if (User != null) if (User != null)
{ {
+1 -1
View File
@@ -38,6 +38,6 @@
</dl> </dl>
</div> </div>
<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> <a asp-page="./Index">Back to List</a>
</div> </div>
+2 -2
View File
@@ -23,13 +23,13 @@ namespace _2021_backend.Pages.Users
public async Task<IActionResult> OnGetAsync(string id) public async Task<IActionResult> OnGetAsync(string id)
{ {
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
if (id == null) if (id == null)
{ {
return NotFound(); return NotFound();
} }
User = _context.Users.Find(guid); User = _context.Users.Find(idx);
if (User == null) if (User == null)
{ {
+1 -1
View File
@@ -13,7 +13,7 @@
<div class="col-md-4"> <div class="col-md-4">
<form method="post"> <form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <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"> <div class="form-group">
<label asp-for="USER.stuID" class="control-label"></label> <label asp-for="USER.stuID" class="control-label"></label>
<input asp-for="USER.stuID" class="form-control" /> <input asp-for="USER.stuID" class="form-control" />
+8 -8
View File
@@ -31,8 +31,8 @@ namespace _2021_backend.Pages.Users
{ {
return NotFound(); return NotFound();
} }
Guid guid = Guid.Parse(id); int idx = int.Parse(id);
USER = _context.Users.Find(guid); USER = _context.Users.Find(idx);
if (USER == null) if (USER == null)
{ {
@@ -52,12 +52,12 @@ namespace _2021_backend.Pages.Users
return Page(); return Page();
} }
if (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).CountAsync() > 0 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(); return new ConflictResult();
if (USER.Secret == null || USER.Secret == String.Empty) 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.Name = USER.Name;
user.stuID = USER.stuID; user.stuID = USER.stuID;
user.isManager = USER.isManager; user.isManager = USER.isManager;
@@ -65,7 +65,7 @@ namespace _2021_backend.Pages.Users
} }
else 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.Name = USER.Name;
user.stuID = USER.stuID; user.stuID = USER.stuID;
user.isManager = USER.isManager; user.isManager = USER.isManager;
@@ -80,7 +80,7 @@ namespace _2021_backend.Pages.Users
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
if (!UserExists(USER.Guid)) if (!UserExists(USER.Id))
{ {
return NotFound(); return NotFound();
} }
@@ -93,9 +93,9 @@ namespace _2021_backend.Pages.Users
return RedirectToPage("./Index"); 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);
} }
} }
} }
+3 -3
View File
@@ -40,9 +40,9 @@
@Html.DisplayFor(modelItem => item.isManager) @Html.DisplayFor(modelItem => item.isManager)
</td> </td>
<td> <td>
<a asp-page="./Edit" asp-route-id="@item.Guid">Edit</a> | <a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Guid">Details</a> | <a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Guid">Delete</a> <a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td> </td>
</tr> </tr>
} }
+11 -9
View File
@@ -14,8 +14,11 @@ namespace _2021_backend
{ {
public class Program public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
var host = CreateHostBuilder(args).Build(); var host = CreateHostBuilder(args).Build();
using (var scope = host.Services.CreateScope()) using (var scope = host.Services.CreateScope())
{ {
@@ -26,14 +29,14 @@ namespace _2021_backend
context.Database.Migrate(); context.Database.Migrate();
Console.WriteLine("Migration succeeded."); Console.WriteLine("Migration succeeded.");
var config = host.Services.GetRequiredService<IConfiguration>(); var config = host.Services.GetRequiredService<IConfiguration>();
TencentSMS.Init(config["TENCENT_ID"], config["TENCENT_KEY"], config["SMS_APPID"], config["SMS_ID_ACCEPT"], config["SMS_ID_REJECT"], config["SMS_ID_TIMESET"], config["SMS_ID_SUBMITTED"], config["SMS_ID_TIMESELECT"]); TencentSMS.Init(config["TENCENT_ID"], config["TENCENT_KEY"], config["SMS_APPID"], config["SMS_ID_ACCEPT"], config["SMS_ID_REJECT"], config["SMS_ID_TIMESET"], config["SMS_ID_SUBMITTED"], config["SMS_ID_TIMESELECT"], config["SMS_ID_CAPTCHA"]);
var botname = config["SMSBOT_NAME"]; var botname = config["SMSBOT_NAME"];
var q = context.Users.Where(it => it.Name == botname); var q = context.Users.Where(it => it.Name == botname);
if (q.Count() == 0) if (q.Count() == 0)
{ {
var botusr = new User(); var botusr = new User();
botusr.Name = botname; botusr.Name = botname;
botusr.Guid = Guid.NewGuid(); botusr.Id = 0;
botusr.isManager = true; botusr.isManager = true;
botusr.Secret = config["SMSBOT_SECRET"]; botusr.Secret = config["SMSBOT_SECRET"];
botusr.stuID = config["SMSBOT_STUID"]; botusr.stuID = config["SMSBOT_STUID"];
@@ -45,19 +48,18 @@ namespace _2021_backend
User.Bot = q.FirstOrDefault(); User.Bot = q.FirstOrDefault();
//do nothing cause I 've already got a bot //do nothing cause I 've already got a bot
} }
var id = Guid.Parse("4c20c535-3661-40c7-b4db-ce479675bbd7"); var name = config["ADMIN_USERNAME"];
while (context.Users.Any(e => e.Guid == id)) while (context.Users.Any(e => e.stuID == name))
{ {
context.Users.Remove(context.Users.Find(id)); context.Users.Remove(context.Users.FirstOrDefault(e => e.stuID == name));
context.SaveChanges(); context.SaveChanges();
} }
var usr = new User(); var usr = new User();
usr.Guid = id; usr.Name = "administrator";
usr.Name = config["ADMIN_USERNAME"];
usr.isManager = true; usr.isManager = true;
usr.Secret = EvaCryptoHelper.Password2Secret(config["ADMIN_PASSWORD"]); usr.Secret = EvaCryptoHelper.Password2Secret(config["ADMIN_PASSWORD"]);
usr.stuID = "zjueva"; usr.stuID = config["ADMIN_USERNAME"]; ;
Console.WriteLine(usr.Guid.ToString()); Console.WriteLine(usr.Id.ToString());
context.Users.Add(usr); context.Users.Add(usr);
context.SaveChanges(); context.SaveChanges();
} }
+2 -1
View File
@@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.Security.Claims; using System.Security.Claims;
namespace _2021_backend namespace _2021_backend
{ {
public class Startup public class Startup
@@ -77,7 +78,7 @@ namespace _2021_backend
}); });
services.AddDbContext<BackendContext>(options => services.AddDbContext<BackendContext>(options =>
options.UseNpgsql($"Host={Configuration["DB_HOST"]};Port={Configuration["DB_PORT"]};Database={Configuration["DB_NAME"]};Username={Configuration["DB_USER"]};Password={Configuration["DB_PASSWORD"]}")); options.UseNpgsql($"Host={Configuration["DB_HOST"]};Port={Configuration["DB_PORT"]};Database={Configuration["DB_NAME"]};Username={Configuration["DB_USER"]};Password={Configuration["DB_PASSWORD"]};CommandTimeout=500"));
} }
+11 -11
View File
@@ -24,12 +24,12 @@ namespace _2021_backend.Utils
var capb = 0; var capb = 0;
foreach (var tm in a.Timelist) 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; capa += t.Capacity - t.Students.Count;
} }
foreach (var tm in b.Timelist) 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; capb += t.Capacity - t.Students.Count;
} }
return capa - capb; return capa - capb;
@@ -43,7 +43,7 @@ namespace _2021_backend.Utils
var tmstr = ""; var tmstr = "";
foreach (var tm in st.Timelist) 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; cap += t.Capacity - t.Students.Count;
tmstr += t.Day.ToString("dd") + "-" + t.BeginTime.ToString("HH:mm-") + t.Place + " "; 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 lst = students[m].Timelist;
var stu = students[m]; 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); return m >= students.Count - 1 ? true : DFS(m + 1);
@@ -71,21 +71,21 @@ namespace _2021_backend.Utils
var tm = Context.Sessions.Find(stu.InterviewTime); var tm = Context.Sessions.Find(stu.InterviewTime);
if (tm != null) 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; bool depth = false;
foreach (var i in lst) 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) if (tm.Students.Count < tm.Capacity && tm.Day.CompareTo(DateTime.Now.AddHours(-14)) > 0)
{ {
status prev = students[m].Status; status prev = students[m].Status;
Guid prevs = students[m].InterviewTime; int prevs = students[m].InterviewTime;
students[m].Status = status.已选时间; students[m].Status = status.已选时间;
students[m].InterviewTime = tm.Guid; students[m].InterviewTime = tm.Id;
tm.Students.Add(students[m].Guid); tm.Students.Add(students[m].Id);
if (m == students.Count - 1) if (m == students.Count - 1)
{ {
return true; return true;
@@ -97,7 +97,7 @@ namespace _2021_backend.Utils
{ {
students[m].Status = prev; students[m].Status = prev;
students[m].InterviewTime = prevs; students[m].InterviewTime = prevs;
tm.Students.Remove(students[m].Guid); tm.Students.Remove(students[m].Id);
continue; continue;
} }
else return true; else return true;
+92
View File
@@ -0,0 +1,92 @@
using System;
using System.IO;
using System.Security.Cryptography;
namespace _2021_backend.Utils
{
public static class CipherHelper
{
static byte[] EncryptStringToBytes_Aes(string plainText, byte[] Key, byte[] IV)
{
// Check arguments.
if (plainText == null || plainText.Length <= 0)
throw new ArgumentNullException("plainText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
byte[] encrypted;
// Create an Aes object
// with the specified key and IV.
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = Key;
aesAlg.IV = IV;
// Create an encryptor to perform the stream transform.
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
// Create the streams used for encryption.
using (MemoryStream msEncrypt = new MemoryStream())
{
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
{
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
{
//Write all data to the stream.
swEncrypt.Write(plainText);
}
encrypted = msEncrypt.ToArray();
}
}
}
// Return the encrypted bytes from the memory stream.
return encrypted;
}
static string DecryptStringFromBytes_Aes(byte[] cipherText, byte[] Key, byte[] IV)
{
// Check arguments.
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
// Declare the string used to hold
// the decrypted text.
string plaintext = null;
// Create an Aes object
// with the specified key and IV.
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = Key;
aesAlg.IV = IV;
// Create a decryptor to perform the stream transform.
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
// Create the streams used for decryption.
using (MemoryStream msDecrypt = new MemoryStream(cipherText))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
// Read the decrypted bytes from the decrypting stream
// and place them in a string.
plaintext = srDecrypt.ReadToEnd();
}
}
}
}
return plaintext;
}
}
}
+23 -8
View File
@@ -9,6 +9,7 @@ using TencentCloud.Common;
using TencentCloud.Common.Profile; using TencentCloud.Common.Profile;
using TencentCloud.Sms.V20210111; using TencentCloud.Sms.V20210111;
using TencentCloud.Sms.V20210111.Models; using TencentCloud.Sms.V20210111.Models;
using System.Security.Cryptography;
namespace _2021_backend.Utils namespace _2021_backend.Utils
{ {
@@ -21,12 +22,13 @@ namespace _2021_backend.Utils
public static string SMSID_reject { get; set; } public static string SMSID_reject { get; set; }
public static string SMSID_timeSet { get; set; } public static string SMSID_timeSet { get; set; }
public static string SMSID_signed { get; set; } public static string SMSID_signed { get; set; }
public static string SMSID_captcha { get; set; }
private static bool Initialized = false; private static bool Initialized = false;
private static string SMSID_timeSelect { get; set; } private static string SMSID_timeSelect { get; set; }
public static void Init(string tencentid, string tencentKey, string appid, string ID_accept, string ID_reject, string ID_timeSet, string ID_submitted, string ID_timeSelect) public static void Init(string tencentid, string tencentKey, string appid, string ID_accept, string ID_reject, string ID_timeSet, string ID_submitted, string ID_timeSelect,string ID_captcha)
{ {
Tencent_id = tencentid; Tencent_id = tencentid;
Tencent_key = tencentKey; Tencent_key = tencentKey;
@@ -36,6 +38,7 @@ namespace _2021_backend.Utils
SMSID_timeSet = ID_timeSet; SMSID_timeSet = ID_timeSet;
SMSID_signed = ID_submitted; SMSID_signed = ID_submitted;
SMSID_timeSelect = ID_timeSelect; SMSID_timeSelect = ID_timeSelect;
SMSID_captcha = ID_captcha;
Initialized = true; Initialized = true;
} }
public static async Task<bool> Pull(BackendContext Context, Student stu, bool fullPull) public static async Task<bool> Pull(BackendContext Context, Student stu, bool fullPull)
@@ -80,9 +83,9 @@ namespace _2021_backend.Utils
var lst = obj.PullSmsReplyStatusSet; var lst = obj.PullSmsReplyStatusSet;
foreach (var item in lst) foreach (var item in lst)
{ {
var msg = new SMS(item, stu.Guid); var msg = new SMS(item, stu.Id);
Context.Add<SMS>(msg); Context.Add<SMS>(msg);
stu.Messages.Add(msg.Guid); stu.Messages.Add(msg.Id);
} }
Context.SaveChanges(); Context.SaveChanges();
return true; return true;
@@ -114,7 +117,7 @@ namespace _2021_backend.Utils
req.PhoneNumberSet[0] = "+86" + stu.Tel; req.PhoneNumberSet[0] = "+86" + stu.Tel;
req.SmsSdkAppId = SMS_appid; req.SmsSdkAppId = SMS_appid;
req.SignName = "ZJUEVA"; req.SignName = "ZJUEVA";
Guid index = stu.InterviewTime; int index = stu.InterviewTime;
SMS sms = new SMS(); SMS sms = new SMS();
switch (type) switch (type)
{ {
@@ -131,13 +134,13 @@ namespace _2021_backend.Utils
case SMSType.TimeSelect: case SMSType.TimeSelect:
sms.Type = SMSType.TimeSelect; sms.Type = SMSType.TimeSelect;
req.TemplateId = SMSID_timeSelect; req.TemplateId = SMSID_timeSelect;
req.TemplateParamSet = new string[] { stu.Name }; req.TemplateParamSet = new string[] { };
break; break;
case SMSType.TimeSet: case SMSType.TimeSet:
sms.Type = 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(); var time = await q.FirstOrDefaultAsync();
req.TemplateParamSet = new string[] { stu.Name, time.Day.ToString("MM-dd") + " " + time.BeginTime.ToString("HH:mm"), time.Place }; 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; req.TemplateId = SMSID_timeSet;
break; break;
case SMSType.Signed: case SMSType.Signed:
@@ -145,9 +148,21 @@ namespace _2021_backend.Utils
req.TemplateParamSet = new string[] { stu.Name }; req.TemplateParamSet = new string[] { stu.Name };
req.TemplateId = SMSID_signed; req.TemplateId = SMSID_signed;
break; break;
case SMSType.Captcha:
sms.Type = SMSType.Captcha;
var captchaBytes = new byte[]{0,0,0,0,0,0};
RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
csp.GetBytes(captchaBytes);
for (int i = 0; i < 6; i++) captchaBytes[i] %= 10;
string captcha = $"{captchaBytes[0]}{captchaBytes[1]}{captchaBytes[2]}{captchaBytes[3]}{captchaBytes[4]}{captchaBytes[5]}";
stu.LastCaptcha = captcha;
stu.LastCaptchaTime = DateTime.Now;
req.TemplateParamSet = new string[] { captcha };
req.TemplateId = SMSID_captcha;
break;
} }
sms.Tel = stu.Tel; 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 query = from e in Context.Users where e.stuID == sender select e;
var usr = await query.FirstOrDefaultAsync(); var usr = await query.FirstOrDefaultAsync();
sms.Sender = usr == null ? "null" : usr.Name; sms.Sender = usr == null ? "null" : usr.Name;
+4 -3
View File
@@ -12,9 +12,10 @@
"SMS_APPID": "1400562126", "SMS_APPID": "1400562126",
"SMS_ID_ACCPET": "1163892", "SMS_ID_ACCPET": "1163892",
"SMS_ID_REJECT": "1089595", "SMS_ID_REJECT": "1089595",
"SMS_ID_SUBMITTED": "1163892", "SMS_ID_SUBMITTED": "1313079",
"SMS_ID_TIMESET": "1131089", "SMS_ID_TIMESET": "1232109",
"SMS_ID_TIMESELECT": "1210823", "SMS_ID_TIMESELECT": "1232577",
"SMS_ID_CAPTCHA": "1312236",
"TENCENT_ID": "AKIDYv5JGwKSJtCE0VjhOpyqSotgDTSaYIsF", "TENCENT_ID": "AKIDYv5JGwKSJtCE0VjhOpyqSotgDTSaYIsF",
"TENCENT_KEY": "mPzSimdGenpdCWcT5TcWBboreAQQ9bmh", "TENCENT_KEY": "mPzSimdGenpdCWcT5TcWBboreAQQ9bmh",
"SMSBOT_NAME": "msgbot", "SMSBOT_NAME": "msgbot",
+1 -1
View File
@@ -1 +1 @@
张峻瑜 6 180 27-09:00-204 27-13:00-204 27-15:30-204 28-13:00-204 28-15:30-204 28-18:30-204 张峻瑜 1 19 11-14:00-200