Compare commits
2 Commits
166821a52e
...
772525a9b6
| Author | SHA1 | Date |
|---|---|---|
|
|
772525a9b6 | |
|
|
e0115e0e07 |
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_2021_backend</RootNamespace>
|
||||
<UserSecretsId>2023ab1c-9547-4989-a343-cd3428e085fe</UserSecretsId>
|
||||
<StartupObject>_2021_backend.Program</StartupObject>
|
||||
|
|
@ -19,21 +19,25 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="itext7" Version="7.1.16" />
|
||||
<PackageReference Include="itext7" Version="7.2.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.2" />
|
||||
<PackageReference Include="Nancy" Version="2.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||
<PackageReference Include="NPOI" Version="2.5.4" />
|
||||
<PackageReference Include="TencentCloudSDK" Version="3.0.362" />
|
||||
<PackageReference Include="NPOI" Version="2.5.5" />
|
||||
<PackageReference Include="TencentCloudSDK" Version="3.0.464" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -7,20 +7,52 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace _2021_backend.Controllers
|
||||
{
|
||||
[Route("api/submit")]
|
||||
|
||||
|
||||
[Route("api")]
|
||||
public class SubmissionController : Controller
|
||||
{
|
||||
public BackendContext Context;
|
||||
|
||||
public 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);
|
||||
string ip = Request.Headers["X-Real-IP"].FirstOrDefault();
|
||||
|
|
@ -29,48 +61,47 @@ namespace _2021_backend.Controllers
|
|||
if (aDto.Check() == false)
|
||||
return StatusCode(400, ApiResponse.Error("TICKET_NOT_LEGEAL"));
|
||||
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))
|
||||
{
|
||||
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;
|
||||
if (q.Count() == 0)
|
||||
{
|
||||
stu = Student.create(sub);
|
||||
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
|
||||
{
|
||||
stu = q.FirstOrDefault();
|
||||
sub.Host = stu.Id;
|
||||
context.Submissions.Add(sub);
|
||||
context.SaveChanges();
|
||||
stu.Update(sub);
|
||||
context.SaveChanges();
|
||||
}
|
||||
sub.Host = stu.Guid;
|
||||
Context.Submissions.Add(sub);
|
||||
Context.SaveChanges();
|
||||
await TencentSMS.Send(Context, SMSType.Signed, stu, _2021_backend.Models.User.Bot.stuID);
|
||||
|
||||
await TencentSMS.Send(context, SMSType.Signed, stu, _2021_backend.Models.User.Bot.stuID);
|
||||
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()
|
||||
{
|
||||
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
|
||||
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,
|
||||
Day = r.Day,
|
||||
|
|
@ -78,25 +109,79 @@ 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("报名结束了"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("fileinfo")]
|
||||
public async Task<IActionResult> GetInfo([FromQuery] string? stuid)
|
||||
{
|
||||
if (stuid == null || (!context.Students.Any(e => e.Stuid == stuid)))
|
||||
{
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("api/postsession")]
|
||||
public class PostsessionController : Controller
|
||||
{
|
||||
private readonly BackendContext Context;
|
||||
public PostsessionController(BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
[HttpPost]
|
||||
|
||||
|
||||
|
||||
[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)
|
||||
{
|
||||
Student stu = Context.Students.FirstOrDefault(r => r.Stuid == stuid);
|
||||
Student stu = context.Students.FirstOrDefault(r => r.Stuid == stuid);
|
||||
if (stu == null)
|
||||
{
|
||||
return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_GUID"));
|
||||
return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_int"));
|
||||
}
|
||||
SessionDto time;
|
||||
try
|
||||
|
|
@ -108,33 +193,34 @@ namespace _2021_backend.Controllers
|
|||
Console.WriteLine(ex);
|
||||
return StatusCode(400, ApiResponse.Error("MALFORMED_DATA"));
|
||||
};
|
||||
//get the selected session guids;
|
||||
Guid targetSession = Guid.Empty;
|
||||
var sessions = Context.Sessions.ToList();
|
||||
//get the selected session ints;
|
||||
int targetSession = 0;
|
||||
var sessions = context.Sessions.ToList();
|
||||
var s = sessions.Find((Session s) =>
|
||||
{
|
||||
return time.Day == s.Day && time.BeginTime == s.BeginTime;
|
||||
});
|
||||
var overwritten = false;
|
||||
if (s.Students.Count >= s.Capacity) return Ok(ApiResponse.Error("OUT_OF_CAPACITY"));
|
||||
if (Context.Sessions.Find(stu.InterviewTime) != null)
|
||||
if (context.Sessions.Find(stu.InterviewTime) != null)
|
||||
{
|
||||
var olds = Context.Sessions.Find(stu.InterviewTime);
|
||||
olds.Students.Remove(stu.Guid);
|
||||
Context.SaveChanges();
|
||||
var olds = context.Sessions.Find(stu.InterviewTime);
|
||||
olds.Students.Remove(stu.Id);
|
||||
context.SaveChanges();
|
||||
overwritten = true;
|
||||
}
|
||||
targetSession = s.Guid;
|
||||
s.Students.Add(stu.Guid);
|
||||
stu.Timelist = new List<Guid> { targetSession};
|
||||
targetSession = s.Id;
|
||||
s.Students.Add(stu.Id);
|
||||
stu.Timelist = new List<int> { targetSession };
|
||||
stu.Status = status.已选时间;
|
||||
stu.InterviewTime = s.Guid;
|
||||
await TencentSMS.Send(Context, SMSType.TimeSet, stu, "smsbot");
|
||||
Context.SaveChanges();
|
||||
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("报名结束了"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,18 +16,21 @@ namespace _2021_backend.Data
|
|||
public DbSet<Student> Students { get; set; }
|
||||
public DbSet<SMS> SMS { get; set; }
|
||||
|
||||
public DbSet<FileDesc> FileDesc { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder mb)
|
||||
{
|
||||
mb.Entity<Submission>()
|
||||
.HasKey(r => r.Guid);
|
||||
.HasKey(r => r.Id);
|
||||
mb.Entity<User>()
|
||||
.HasKey(u => u.Guid);
|
||||
.HasKey(u => u.Id);
|
||||
mb.Entity<Comment>()
|
||||
.HasKey(u => u.Guid);
|
||||
.HasKey(u => u.Id);
|
||||
mb.Entity<Session>()
|
||||
.HasKey(u => u.Guid);
|
||||
.HasKey(u => u.Id);
|
||||
mb.Entity<SMS>()
|
||||
.HasKey(u => u.Guid);
|
||||
.HasKey(u => u.Id);
|
||||
mb.Entity<FileDesc>().HasKey(u => u.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,58 +8,128 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using _2021_backend.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _2021_backend.Migrations
|
||||
{
|
||||
[DbContext(typeof(BackendContext))]
|
||||
[Migration("20211018220015_Initial")]
|
||||
partial class Initial
|
||||
[Migration("20220223070103_initial")]
|
||||
partial class initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63)
|
||||
.HasAnnotation("ProductVersion", "5.0.9")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasAnnotation("ProductVersion", "6.0.2")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Comment", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("AddTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Content")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("Operator")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Operator")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("Student")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Student")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.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 =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<List<string>>("Data")
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.Property<Guid>("Host")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Host")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("SendTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Sender")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -70,52 +140,21 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SMS");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Session", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("BeginTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<List<Guid>>("Chiefs")
|
||||
.HasColumnType("uuid[]");
|
||||
|
||||
b.Property<DateTime>("Day")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Place")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("SendSMS")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<List<Guid>>("Students")
|
||||
.HasColumnType("uuid[]");
|
||||
|
||||
b.HasKey("Guid");
|
||||
|
||||
b.ToTable("Sessions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<List<Guid>>("Comments")
|
||||
.HasColumnType("uuid[]");
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<List<int>>("Comments")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -126,23 +165,29 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Grade")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("InterviewTime")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("InterviewTime")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("LastCaptcha")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("LastCaptchaTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("LastSubmission")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Major")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Messages")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Messages")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("RegisterTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("integer");
|
||||
|
|
@ -156,28 +201,33 @@ namespace _2021_backend.Migrations
|
|||
b.Property<string>("Stuid")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Submissions")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Submissions")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Timelist")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Timelist")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<List<int>>("Uploads")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<int>("Yard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Submission", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -191,8 +241,8 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Grade")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("Host")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Host")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Major")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -207,27 +257,29 @@ namespace _2021_backend.Migrations
|
|||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("SubmitTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Timelist")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Timelist")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<int>("Yard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Submissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -241,7 +293,7 @@ namespace _2021_backend.Migrations
|
|||
b.Property<string>("stuID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _2021_backend.Migrations
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
public partial class initial : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
|
@ -12,57 +15,78 @@ namespace _2021_backend.Migrations
|
|||
name: "Comments",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Operator = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Operator = table.Column<int>(type: "integer", nullable: false),
|
||||
Content = table.Column<string>(type: "text", nullable: false),
|
||||
AddTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Student = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
AddTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Student = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Comments", x => x.Guid);
|
||||
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "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(
|
||||
name: "Sessions",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Day = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
BeginTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Day = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
BeginTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Place = table.Column<string>(type: "text", nullable: false),
|
||||
Chiefs = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
Chiefs = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Capacity = table.Column<int>(type: "integer", nullable: false),
|
||||
SendSMS = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Students = table.Column<List<Guid>>(type: "uuid[]", nullable: true)
|
||||
Students = table.Column<List<int>>(type: "integer[]", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Sessions", x => x.Guid);
|
||||
table.PrimaryKey("PK_Sessions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SMS",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Host = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Host = table.Column<int>(type: "integer", nullable: false),
|
||||
Tel = table.Column<string>(type: "text", nullable: true),
|
||||
Data = table.Column<List<string>>(type: "text[]", nullable: true),
|
||||
Type = table.Column<int>(type: "integer", nullable: false),
|
||||
Sender = table.Column<string>(type: "text", nullable: true),
|
||||
SendTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
SendTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SMS", x => x.Guid);
|
||||
table.PrimaryKey("PK_SMS", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Students",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: true),
|
||||
Stuid = table.Column<string>(type: "text", nullable: true),
|
||||
Sex = table.Column<int>(type: "integer", nullable: false),
|
||||
|
|
@ -72,27 +96,31 @@ namespace _2021_backend.Migrations
|
|||
Email = table.Column<string>(type: "text", nullable: true),
|
||||
Tel = table.Column<string>(type: "text", nullable: true),
|
||||
Exp = table.Column<int>(type: "integer", nullable: false),
|
||||
InterviewTime = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Submissions = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
Messages = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
Timelist = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
Comments = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
InterviewTime = table.Column<int>(type: "integer", nullable: false),
|
||||
Submissions = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Uploads = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Messages = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Timelist = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Comments = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Score = table.Column<int>(type: "integer", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
LastSubmission = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
RegisterTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
LastSubmission = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
RegisterTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
LastCaptcha = table.Column<string>(type: "text", nullable: true),
|
||||
LastCaptchaTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Students", x => x.Guid);
|
||||
table.PrimaryKey("PK_Students", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Submissions",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Host = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Host = table.Column<int>(type: "integer", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: true),
|
||||
Stuid = table.Column<string>(type: "text", nullable: true),
|
||||
Sex = table.Column<int>(type: "integer", nullable: false),
|
||||
|
|
@ -102,20 +130,21 @@ namespace _2021_backend.Migrations
|
|||
Email = table.Column<string>(type: "text", nullable: true),
|
||||
Tel = table.Column<string>(type: "text", nullable: true),
|
||||
Exp = table.Column<int>(type: "integer", nullable: false),
|
||||
Timelist = table.Column<List<Guid>>(type: "uuid[]", nullable: true),
|
||||
Timelist = table.Column<List<int>>(type: "integer[]", nullable: true),
|
||||
Address = table.Column<string>(type: "text", nullable: true),
|
||||
SubmitTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
SubmitTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Submissions", x => x.Guid);
|
||||
table.PrimaryKey("PK_Submissions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
stuID = table.Column<string>(type: "text", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: true),
|
||||
Secret = table.Column<string>(type: "text", nullable: true),
|
||||
|
|
@ -123,7 +152,7 @@ namespace _2021_backend.Migrations
|
|||
},
|
||||
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(
|
||||
name: "Comments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FileDesc");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sessions");
|
||||
|
||||
|
|
@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using _2021_backend.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _2021_backend.Migrations
|
||||
{
|
||||
[DbContext(typeof(BackendContext))]
|
||||
|
|
@ -16,48 +18,116 @@ namespace _2021_backend.Migrations
|
|||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63)
|
||||
.HasAnnotation("ProductVersion", "5.0.9")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasAnnotation("ProductVersion", "6.0.2")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Comment", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("AddTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Content")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("Operator")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Operator")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("Student")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Student")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
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 =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<List<string>>("Data")
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.Property<Guid>("Host")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Host")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("SendTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Sender")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -68,52 +138,21 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SMS");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Session", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("BeginTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<List<Guid>>("Chiefs")
|
||||
.HasColumnType("uuid[]");
|
||||
|
||||
b.Property<DateTime>("Day")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Place")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("SendSMS")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<List<Guid>>("Students")
|
||||
.HasColumnType("uuid[]");
|
||||
|
||||
b.HasKey("Guid");
|
||||
|
||||
b.ToTable("Sessions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<List<Guid>>("Comments")
|
||||
.HasColumnType("uuid[]");
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<List<int>>("Comments")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -124,23 +163,29 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Grade")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("InterviewTime")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("InterviewTime")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("LastCaptcha")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("LastCaptchaTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("LastSubmission")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Major")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Messages")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Messages")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("RegisterTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("integer");
|
||||
|
|
@ -154,28 +199,33 @@ namespace _2021_backend.Migrations
|
|||
b.Property<string>("Stuid")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Submissions")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Submissions")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Timelist")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Timelist")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<List<int>>("Uploads")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<int>("Yard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.Submission", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -189,8 +239,8 @@ namespace _2021_backend.Migrations
|
|||
b.Property<int>("Grade")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("Host")
|
||||
.HasColumnType("uuid");
|
||||
b.Property<int>("Host")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Major")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -205,27 +255,29 @@ namespace _2021_backend.Migrations
|
|||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("SubmitTime")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<List<Guid>>("Timelist")
|
||||
.HasColumnType("uuid[]");
|
||||
b.Property<List<int>>("Timelist")
|
||||
.HasColumnType("integer[]");
|
||||
|
||||
b.Property<int>("Yard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Submissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_2021_backend.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Guid")
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
|
@ -239,7 +291,7 @@ namespace _2021_backend.Migrations
|
|||
b.Property<string>("stuID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Guid");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,15 +11,16 @@ namespace _2021_backend.Models
|
|||
{
|
||||
public Comment()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
AddTime = DateTime.Now;
|
||||
}
|
||||
|
||||
[Key]
|
||||
public Guid Guid { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Required()]
|
||||
[Display(Name = "评论者")]
|
||||
public Guid Operator { get; set; }
|
||||
public int Operator { get; set; }
|
||||
|
||||
[Required()]
|
||||
[Display(Name = "内容")]
|
||||
|
|
@ -28,13 +29,13 @@ namespace _2021_backend.Models
|
|||
[DataType(DataType.DateTime)]
|
||||
public DateTime AddTime { get; set; }
|
||||
[Display(Name = "被评论者")]
|
||||
public Guid Student { get; set; }
|
||||
public Comment(Guid opid,string content, Guid stuguid)
|
||||
public int Student { get; set; }
|
||||
public Comment(int opid, string content, int stuint)
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
Operator = opid;
|
||||
Content = content;
|
||||
Student = stuguid;
|
||||
Student = stuint;
|
||||
AddTime = DateTime.Now;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
|
|
@ -12,22 +13,23 @@ namespace _2021_backend.Models
|
|||
TimeSelect,
|
||||
TimeSet,
|
||||
Signed,
|
||||
Reply
|
||||
Reply,
|
||||
Captcha,
|
||||
}
|
||||
public class SMS
|
||||
{
|
||||
public SMS()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
Tel = "";
|
||||
Data = new List<string> { };
|
||||
Type = SMSType.Accept;
|
||||
Sender = "";
|
||||
SendTime = DateTime.Now;
|
||||
}
|
||||
public SMS(SMSPartialDto dto, Guid host)
|
||||
public SMS(SMSPartialDto dto, int host)
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
Tel = dto.SubscriberNumber;
|
||||
Host = host;
|
||||
Sender = dto.SubscriberNumber.ToString();
|
||||
|
|
@ -37,9 +39,10 @@ namespace _2021_backend.Models
|
|||
SendTime = tm;
|
||||
}
|
||||
[Key]
|
||||
public Guid Guid { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Display(Name = "Host")]
|
||||
public Guid Host { get; set; }
|
||||
public int Host { get; set; }
|
||||
[Display(Name = "电话号码")]
|
||||
public string Tel { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ namespace _2021_backend.Models
|
|||
|
||||
public Session()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
}
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Required()]
|
||||
[Display(Name = "场次GUID")]
|
||||
public Guid Guid { get; set; }
|
||||
[Display(Name = "场次int")]
|
||||
public int Id { get; set; }
|
||||
[Required()]
|
||||
[Display(Name = "活动日期")]
|
||||
[DataType(DataType.Date)]
|
||||
|
|
@ -35,7 +36,7 @@ namespace _2021_backend.Models
|
|||
[Required()]
|
||||
public string Place { get; set; }
|
||||
[Display(Name = "主活动官")]
|
||||
public List<Guid> Chiefs { get; set; }
|
||||
public List<int> Chiefs { get; set; }
|
||||
|
||||
[Display(Name = "可容纳人数")]
|
||||
public int Capacity { get; set; }
|
||||
|
|
@ -43,7 +44,7 @@ namespace _2021_backend.Models
|
|||
[Display(Name = "短信通知")]
|
||||
public bool SendSMS { get; set; }
|
||||
[Display(Name = "活动的人")]
|
||||
public List<Guid> Students { get; set; }
|
||||
public List<int> Students { get; set; }
|
||||
|
||||
}
|
||||
public class SessionDto
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ namespace _2021_backend.Models
|
|||
需调整时间,
|
||||
已确认时间,
|
||||
不通过,
|
||||
已提交,
|
||||
已评分,
|
||||
暂缺
|
||||
}
|
||||
|
|
@ -47,8 +49,21 @@ namespace _2021_backend.Models
|
|||
暂缺 = 0,
|
||||
萌新 = 1,
|
||||
略有了解 = 2,
|
||||
了解较多 = 3,
|
||||
轻车熟路 = 4
|
||||
轻车熟路 = 3,
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -65,21 +80,21 @@ namespace _2021_backend.Models
|
|||
Yard = sub.Yard;
|
||||
Exp = sub.Exp;
|
||||
Timelist = sub.Timelist;
|
||||
Submissions.Add(sub.Guid);
|
||||
Submissions.Add(sub.Id);
|
||||
}
|
||||
public Student()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Comments = new List<Guid>();
|
||||
Messages = new List<Guid>();
|
||||
Submissions = new List<Guid>();
|
||||
Timelist = new List<Guid>();
|
||||
Id = 0;
|
||||
Comments = new List<int>();
|
||||
Messages = new List<int>();
|
||||
Submissions = new List<int>();
|
||||
Timelist = new List<int>();
|
||||
}
|
||||
|
||||
public static Student create(Submission sub)
|
||||
{
|
||||
Student student = new Student();
|
||||
student.Guid = Guid.NewGuid();
|
||||
student.Id = 0;
|
||||
student.Name = sub.Name;
|
||||
student.Email = sub.Email;
|
||||
student.Tel = sub.Tel;
|
||||
|
|
@ -90,13 +105,13 @@ namespace _2021_backend.Models
|
|||
student.Yard = sub.Yard;
|
||||
student.Exp = sub.Exp;
|
||||
student.Timelist = sub.Timelist;
|
||||
student.Submissions.Add(sub.Guid);
|
||||
student.RegisterTime = sub.SubmitTime;
|
||||
return student;
|
||||
}
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name = "ID")]
|
||||
public Guid Guid { get; set; }
|
||||
public int Id { get; set; }
|
||||
[Display(Name = "姓名")]
|
||||
public string Name { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
|
|
@ -119,15 +134,19 @@ namespace _2021_backend.Models
|
|||
public experience Exp { get; set; }
|
||||
|
||||
[Display(Name = "最终场次")]
|
||||
public Guid InterviewTime { get; set; }
|
||||
[Display(Name = "提交记录")]
|
||||
public List<Guid> Submissions { get; set; }
|
||||
public int InterviewTime { get; set; }
|
||||
[Display(Name = "报名记录")]
|
||||
public List<int> Submissions { get; set; }
|
||||
|
||||
[Display(Name = "提交的文件")]
|
||||
public List<int> Uploads { get; set; }
|
||||
|
||||
[Display(Name = "短信记录")]
|
||||
public List<Guid> Messages { get; set; }
|
||||
public List<int> Messages { get; set; }
|
||||
[Display(Name = "可选场次")]
|
||||
public List<Guid> Timelist { get; set; }
|
||||
public List<int> Timelist { get; set; }
|
||||
[Display(Name = "评论")]
|
||||
public List<Guid> Comments { get; set; }
|
||||
public List<int> Comments { get; set; }
|
||||
[Display(Name = "打分")]
|
||||
public int Score { get; set; }
|
||||
|
||||
|
|
@ -141,5 +160,9 @@ namespace _2021_backend.Models
|
|||
[Display(Name = "报名时间")]
|
||||
[DataType(DataType.DateTime)]
|
||||
public DateTime RegisterTime { get; set; }
|
||||
|
||||
public string LastCaptcha { get; set; }
|
||||
|
||||
public DateTime LastCaptchaTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Org.BouncyCastle.Asn1.Cms;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -11,8 +12,9 @@ namespace _2021_backend.Models
|
|||
{
|
||||
public class Submission
|
||||
{
|
||||
public Submission() {
|
||||
Guid = Guid.NewGuid();
|
||||
public Submission()
|
||||
{
|
||||
Id = 0;
|
||||
SubmitTime = DateTime.Now;
|
||||
}
|
||||
public Submission(SubmissionDto Dto, string ip)
|
||||
|
|
@ -26,16 +28,17 @@ namespace _2021_backend.Models
|
|||
Tel = Dto.Tel;
|
||||
Exp = (experience)Dto.Exp;
|
||||
Yard = (yard)Dto.Yard;
|
||||
Timelist = new List<Guid>();
|
||||
Guid = System.Guid.NewGuid();
|
||||
Timelist = new List<int>();
|
||||
Id = 0;
|
||||
SubmitTime = DateTime.Now;
|
||||
Address = ip;
|
||||
}
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name = "ID")]
|
||||
public Guid Guid { get; set; }
|
||||
public int Id { get; set; }
|
||||
[Display(Name = "Host")]
|
||||
public Guid Host { get; set; }
|
||||
public int Host { get; set; }
|
||||
[Display(Name = "姓名")]
|
||||
public string Name { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
|
|
@ -58,7 +61,7 @@ namespace _2021_backend.Models
|
|||
public experience Exp { get; set; }
|
||||
|
||||
[Display(Name = "时间列表")]
|
||||
public List<Guid> Timelist { get; set; }
|
||||
public List<int> Timelist { get; set; }
|
||||
[Display(Name = "Ip Address")]
|
||||
public string Address { get; set; }
|
||||
[Display(Name = "提交时间")]
|
||||
|
|
@ -118,7 +121,7 @@ namespace _2021_backend.Models
|
|||
if (Major.Length > 20)
|
||||
return false;
|
||||
if (Yard >= 6 && Yard <= 0) return false;
|
||||
if(Exp >= 5 && Exp <= 0) return false;
|
||||
if (Exp >= 3 && Exp <= 0) return false;
|
||||
if (!r.IsMatch(Email))
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ namespace _2021_backend.Models
|
|||
{
|
||||
public User()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Id = 0;
|
||||
}
|
||||
|
||||
public static User Bot;
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name = "ID")]
|
||||
public Guid Guid { get; set; }
|
||||
public int Id { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
public string stuID { get; set; }
|
||||
[Display(Name = "姓名")]
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace _2021_backend.Pages.Account
|
|||
{
|
||||
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);
|
||||
identity.AddClaim(new Claim(ClaimTypes.Name, user.Name));
|
||||
identity.AddClaim(new Claim(ClaimTypes.Sid, user.Guid.ToString()));
|
||||
identity.AddClaim(new Claim(ClaimTypes.Sid, user.Id.ToString()));
|
||||
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, username));
|
||||
if (user.isManager)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<strong>@Html.DisplayFor(model => Model.Errmsg)</strong>
|
||||
</h5>
|
||||
<h3><strong>发送短信</strong></h3>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="pageid" />
|
||||
<input type="submit" value="拉取5天内的回复短信" class="btn btn-primary" asp-page-handler="Pull" />
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ namespace _2021_backend.Pages.Message
|
|||
Context = context;
|
||||
}
|
||||
|
||||
public IActionResult Construct(int PageId)
|
||||
public IActionResult Construct(int PageId, string emsg)
|
||||
{
|
||||
List<Guid> stus;
|
||||
IQueryable<Guid> q;
|
||||
if (!String.IsNullOrEmpty(SearchString)) q = from e in Context.Students where e.Name.Contains(SearchString) select e.Guid;
|
||||
else q = from e in Context.Students select e.Guid;
|
||||
List<int> stus;
|
||||
IQueryable<int> q;
|
||||
if (!String.IsNullOrEmpty(SearchString)) q = from e in Context.Students where e.Name.Contains(SearchString) select e.Id;
|
||||
else q = from e in Context.Students select e.Id;
|
||||
stus = q.ToList();
|
||||
var q2 = from e in Context.SMS where stus.Contains(e.Host) select e;
|
||||
if (showReceive && !showSend) q2 = from e in q2 where e.Type == SMSType.Reply select e;
|
||||
|
|
@ -62,101 +62,149 @@ namespace _2021_backend.Pages.Message
|
|||
int count = (PageId + 1) * pageSize > cnt ? (cnt - PageId * pageSize) : pageSize;
|
||||
Messages = Messages.GetRange(PageId * pageSize, count);
|
||||
|
||||
Errmsg = emsg;
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int PageId)
|
||||
{
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int PageId)
|
||||
{
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
|
||||
public async void OnPostPullAsync(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)
|
||||
{
|
||||
await Utils.TencentSMS.Pull(Context, e, true);
|
||||
}
|
||||
|
||||
Construct(PageId);
|
||||
Construct(PageId, "");
|
||||
}
|
||||
else Construct(PageId, "您无权进行此操作");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSignAsync(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)
|
||||
{
|
||||
if (e.Status == status.刚报名)
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Signed, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Signed, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
}
|
||||
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
else return Construct(PageId, "您无权进行此操作");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostResultRejectAsync(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)
|
||||
{
|
||||
if (e.Status == status.不通过)
|
||||
{
|
||||
if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Reject))
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Reject, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
if (!Context.SMS.Any(it => it.Host == e.Id && it.Type == SMSType.Reject))
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Reject, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
}
|
||||
}
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
else return Construct(PageId, "您无权进行此操作");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostTimeSelectAsync(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)
|
||||
{
|
||||
if (e.Status != status.不通过 && e.Status != status.已选时间)
|
||||
{
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
}
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
else return Construct(PageId, "您无权进行此操作");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostResultAccpetAsync(int PageId)
|
||||
public async Task<IActionResult> OnPostResultAcceptAsync(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)
|
||||
{
|
||||
if (e.Status == status.通过)
|
||||
{
|
||||
if (!Context.SMS.Any(it => it.Host == e.Guid && it.Type == SMSType.Accept))
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Accept, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
if (!Context.SMS.Any(it => it.Host == e.Id && it.Type == SMSType.Accept))
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Accept, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
}
|
||||
|
||||
}
|
||||
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.Guid)!= Guid.Empty && e.Status == status.已选时间)
|
||||
if (t != null && t.Students.Find(s => s == e.Id) != 0 && e.Status == status.已选时间)
|
||||
{
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, e, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
e.Status = status.已确认时间;
|
||||
}
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return Construct(PageId);
|
||||
return Construct(PageId, "");
|
||||
}
|
||||
else return Construct(PageId, "您无权进行此操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
[BindProperty]
|
||||
[Display(Name = "活动官")]
|
||||
public string ChiefGuid { get; set; }
|
||||
public string Chiefint { get; set; }
|
||||
|
||||
|
||||
public List<SelectListItem> ChiefList { get; set; }
|
||||
|
|
@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false });
|
||||
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false });
|
||||
var lst = qlst.ToList().Distinct().ToList();
|
||||
ChiefList = lst;
|
||||
return Page();
|
||||
|
|
@ -48,8 +48,8 @@ namespace _2021_backend.Pages.Sessions
|
|||
{
|
||||
return Page();
|
||||
}
|
||||
InterviewTime.Students = new List<Guid>();
|
||||
InterviewTime.Chiefs = new List<Guid>();
|
||||
InterviewTime.Students = new List<int>();
|
||||
InterviewTime.Chiefs = new List<int>();
|
||||
Session interviewTimeSecond = new Session();
|
||||
if (CreateTwo)
|
||||
{
|
||||
|
|
@ -62,9 +62,9 @@ namespace _2021_backend.Pages.Sessions
|
|||
Day = InterviewTime.Day,
|
||||
BeginTime = InterviewTime.BeginTime,
|
||||
Place = anotherPlace,
|
||||
Chiefs = new List<Guid>(),
|
||||
Chiefs = new List<int>(),
|
||||
SendSMS = InterviewTime.SendSMS,
|
||||
Students = new List<Guid>(),
|
||||
Students = new List<int>(),
|
||||
Capacity = InterviewTime.Capacity
|
||||
};
|
||||
Context.Add(interviewTimeSecond);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="InterviewTime.Guid" />
|
||||
<input type="hidden" asp-for="InterviewTime.Id" />
|
||||
<input type="submit" value="确定删除" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string? id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
InterviewTime = Context.Sessions.Find(guid);
|
||||
InterviewTime = Context.Sessions.Find(idx);
|
||||
|
||||
if (InterviewTime == null)
|
||||
{
|
||||
|
|
@ -41,12 +41,12 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnPostAsync(string? id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
InterviewTime = await Context.Sessions.FindAsync(guid);
|
||||
InterviewTime = await Context.Sessions.FindAsync(idx);
|
||||
|
||||
if (InterviewTime != null)
|
||||
{
|
||||
|
|
@ -57,15 +57,15 @@ namespace _2021_backend.Pages.Sessions
|
|||
Student stu = Context.Students.Find(x);
|
||||
if (stu != null)
|
||||
{
|
||||
stu.InterviewTime = Guid.Empty;
|
||||
stu.Timelist.RemoveAll(it => it == guid);
|
||||
stu.InterviewTime = 0;
|
||||
stu.Timelist.RemoveAll(it => it == idx);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
foreach(var x in Context.Students)
|
||||
{
|
||||
x.Timelist.RemoveAll(it => it == guid);
|
||||
x.Timelist.RemoveAll(it => it == idx);
|
||||
}
|
||||
Context.Sessions.Remove(InterviewTime);
|
||||
Context.SaveChanges();
|
||||
|
|
|
|||
|
|
@ -64,6 +64,6 @@
|
|||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Guid">Edit</a> |
|
||||
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Id">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string? id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
CurSession = Context.Sessions.Find(guid);
|
||||
CurSession = Context.Sessions.Find(idx);
|
||||
if (CurSession == null)
|
||||
{
|
||||
return NotFound();
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="CurSession.Guid" />
|
||||
<input type="hidden" asp-for="CurGuid">
|
||||
<input type="hidden" asp-for="CurSession.Id" />
|
||||
<input type="hidden" asp-for="Curint">
|
||||
<div class="form-group">
|
||||
<label asp-for="newDay" class="control-label"></label>
|
||||
<input asp-for="newDay" class="form-control" />
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
<form method="post">
|
||||
<label class="col-sm-2">添加一个</label>
|
||||
<select asp-items=Model.Stulist id="stuselect" asp-for="addedStu" class="col-sm-2"></select>
|
||||
<input type="hidden" asp-for="CurGuid" />
|
||||
<input type="hidden" asp-for="Curint" />
|
||||
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="Add" />
|
||||
</form>
|
||||
<br />
|
||||
|
|
@ -76,11 +76,11 @@
|
|||
<td>@Html.DisplayFor(model=>stu.Name)</td>
|
||||
<td>
|
||||
|
||||
<a asp-page="/Students/Details" asp-route-idstr=@stu.Guid.ToString() class="btn btn-primary">详细信息</a>
|
||||
<a asp-page="/Students/Details" asp-route-idstr=@stu.Id.ToString() class="btn btn-primary">详细信息</a>
|
||||
<div style="float:left">
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="CurGuid">
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Guid.ToString() />
|
||||
<input type="hidden" asp-for="Curint">
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Id.ToString() />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
<form method="post">
|
||||
<label class="col-sm-2">添加一个</label>
|
||||
<select id="chiefselect"asp-items=Model.ChiefList asp-for="addedChief" class="col-sm-2"></select>
|
||||
<input type="hidden" asp-for="CurGuid" />
|
||||
<input type="hidden" asp-for="Curint" />
|
||||
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="AddChief" />
|
||||
</form>
|
||||
<br />
|
||||
|
|
@ -121,8 +121,8 @@
|
|||
<td>
|
||||
<div style="float:left">
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="CurGuid">
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Guid.ToString() />
|
||||
<input type="hidden" asp-for="Curint">
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Id.ToString() />
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
public Session CurSession { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string CurGuid { get; set; }
|
||||
public string Curint { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string ChiefSearch { get; set; }
|
||||
|
|
@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
public List<SelectListItem> Stulist { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public Guid addedChief { get; set; }
|
||||
public int addedChief { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string addedStu { get; set; }
|
||||
|
|
@ -71,13 +71,13 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public IActionResult Construct(string id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
CurGuid = id;
|
||||
CurSession = Context.Sessions.Find(guid);
|
||||
Curint = id;
|
||||
CurSession = Context.Sessions.Find(idx);
|
||||
|
||||
newDay = CurSession.Day;
|
||||
newTime = CurSession.BeginTime;
|
||||
|
|
@ -86,10 +86,10 @@ namespace _2021_backend.Pages.Sessions
|
|||
newPlace = CurSession.Place;
|
||||
|
||||
if (CurSession == null) return RedirectToPage("./Index", new { errmsg = "未找到该活动场次" });
|
||||
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false });
|
||||
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false });
|
||||
ChiefList = qlst.ToList().Distinct().ToList();
|
||||
|
||||
var slst = from e in Context.Students where e.InterviewTime == Guid.Empty select new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false };
|
||||
var slst = from e in Context.Students where e.InterviewTime == 0 select new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false };
|
||||
Stulist = slst.ToList().Distinct().ToList();
|
||||
return Page();
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
// more details, see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
var ssn = Context.Sessions.Find(Guid.Parse(CurGuid));
|
||||
var ssn = Context.Sessions.Find(int.Parse(Curint));
|
||||
ssn.SendSMS = sendSMS;
|
||||
ssn.Day = newDay;
|
||||
ssn.BeginTime = newTime;
|
||||
|
|
@ -116,73 +116,73 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnPostDeleteAsync(string id)
|
||||
{
|
||||
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
|
||||
var guid = Guid.Parse(id);
|
||||
CurSession = Context.Sessions.Find(int.Parse(Curint));
|
||||
var idx = int.Parse(id);
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
if (Context.Students.Any(it => it.Guid == guid))
|
||||
if (Context.Students.Any(it => it.Id == idx))
|
||||
{
|
||||
Context.Students.Find(guid).InterviewTime = Guid.Empty;
|
||||
CurSession.Students.RemoveAll(it => it == guid);
|
||||
Context.Students.Find(idx).InterviewTime = 0;
|
||||
CurSession.Students.RemoveAll(it => it == idx);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
}
|
||||
return Construct(CurGuid);
|
||||
return Construct(Curint);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAddAsync()
|
||||
{
|
||||
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
|
||||
var guid = Guid.Parse(addedStu);
|
||||
CurSession = Context.Sessions.Find(int.Parse(Curint));
|
||||
var idx = int.Parse(addedStu);
|
||||
if (!string.IsNullOrEmpty(addedStu))
|
||||
{
|
||||
if (Context.Students.Any(it => it.Guid == guid))
|
||||
if (Context.Students.Any(it => it.Id == idx))
|
||||
{
|
||||
var stu = Context.Students.Find(guid);
|
||||
if(stu.InterviewTime != Guid.Empty)
|
||||
var stu = Context.Students.Find(idx);
|
||||
if(stu.InterviewTime != 0)
|
||||
{
|
||||
var oldtime = Context.Sessions.Find(stu.InterviewTime);
|
||||
if(oldtime != null)
|
||||
{
|
||||
oldtime.Students.RemoveAll(s => s == stu.Guid);
|
||||
oldtime.Students.RemoveAll(s => s == stu.Id);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
stu.InterviewTime = CurSession.Guid;
|
||||
stu.InterviewTime = CurSession.Id;
|
||||
stu.Status = status.已选时间;
|
||||
CurSession.Students.Add(guid);
|
||||
CurSession.Students.Add(idx);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
}
|
||||
return Construct(CurGuid);
|
||||
return Construct(Curint);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAddChiefAsync()
|
||||
{
|
||||
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
|
||||
if (Context.Users.Any(it => it.Guid == addedChief))
|
||||
CurSession = Context.Sessions.Find(int.Parse(Curint));
|
||||
if (Context.Users.Any(it => it.Id == addedChief))
|
||||
{
|
||||
CurSession.Chiefs.Add(addedChief);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return Construct(CurGuid);
|
||||
return Construct(Curint);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostDeleteChiefAsync(string id)
|
||||
{
|
||||
var guid = Guid.Parse(id);
|
||||
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
|
||||
if (CurSession.Chiefs.Contains(guid))
|
||||
var idx = int.Parse(id);
|
||||
CurSession = Context.Sessions.Find(int.Parse(Curint));
|
||||
if (CurSession.Chiefs.Contains(idx))
|
||||
{
|
||||
CurSession.Chiefs.Remove(guid);
|
||||
CurSession.Chiefs.Remove(idx);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return Construct(CurGuid);
|
||||
return Construct(Curint);
|
||||
}
|
||||
|
||||
private bool InterviewTimeExists(Guid id)
|
||||
private bool InterviewTimeExists(int id)
|
||||
{
|
||||
return Context.Sessions.Any(e => e.Guid == id);
|
||||
return Context.Sessions.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@
|
|||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.Guid">编辑</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.Guid">删除</a> |
|
||||
<a asp-page-handler="Reset" asp-route-id="@item.Guid">重置</a>
|
||||
<a asp-page="./Edit" asp-route-id="@item.Id">编辑</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.Id">删除</a> |
|
||||
<a asp-page-handler="Reset" asp-route-id="@item.Id">重置</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace _2021_backend.Pages.Sessions
|
||||
{
|
||||
|
|
@ -89,16 +90,16 @@ namespace _2021_backend.Pages.Sessions
|
|||
return Construct(errmsg);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetResetAsync(Guid id)
|
||||
public async Task<IActionResult> OnGetResetAsync(int id)
|
||||
{
|
||||
if(Context.Sessions.Any(it => it.Guid == id))
|
||||
if(Context.Sessions.Any(it => it.Id == id))
|
||||
{
|
||||
var s = Context.Sessions.Find(id);
|
||||
foreach(var st in s.Students)
|
||||
{
|
||||
var e = Context.Students.Find(st);
|
||||
e.Status = status.需调整时间;
|
||||
e.InterviewTime = Guid.Empty;
|
||||
e.InterviewTime = 0;
|
||||
}
|
||||
s.Students.Clear();
|
||||
}
|
||||
|
|
@ -124,15 +125,32 @@ namespace _2021_backend.Pages.Sessions
|
|||
|
||||
public async Task<IActionResult> OnPostArrangeAsync()
|
||||
{
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
return c.Type == ClaimTypes.Role && (
|
||||
c.Value == "admin" || c.Value == "manager");
|
||||
}))
|
||||
{
|
||||
foreach (var s in Context.Students)
|
||||
{
|
||||
s.InterviewTime = Guid.Empty;
|
||||
s.InterviewTime = 0;
|
||||
s.Status = status.需调整时间;
|
||||
s.Timelist.Clear();
|
||||
}
|
||||
|
|
@ -144,17 +162,30 @@ namespace _2021_backend.Pages.Sessions
|
|||
Context.SaveChanges();
|
||||
return Construct("");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Construct("您无权进行此操作");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostResetAllAsync()
|
||||
{
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
return c.Type == ClaimTypes.Role && (
|
||||
c.Value == "admin" || c.Value == "manager");
|
||||
}))
|
||||
{
|
||||
|
||||
|
||||
var stus = Context.Students.ToList();
|
||||
foreach (var s in stus)
|
||||
{
|
||||
if (s.Status == status.已选时间)
|
||||
{
|
||||
s.InterviewTime = Guid.Empty;
|
||||
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
|
||||
s.Timelist.Sort((Guid a, Guid b) =>
|
||||
s.InterviewTime = 0;
|
||||
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
|
||||
s.Timelist.Sort((int a, int b) =>
|
||||
{
|
||||
var x = Context.Sessions.Find(a);
|
||||
var y = Context.Sessions.Find(b);
|
||||
|
|
@ -173,8 +204,19 @@ namespace _2021_backend.Pages.Sessions
|
|||
Context.SaveChanges();
|
||||
return Construct("");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Construct("您无权进行此操作");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSaveAsync()
|
||||
{
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
return c.Type == ClaimTypes.Role && (
|
||||
c.Value == "admin" || c.Value == "manager");
|
||||
}))
|
||||
{
|
||||
var lst = Context.Sessions.ToList();
|
||||
var str = JsonSerializer.Serialize(lst);
|
||||
|
|
@ -183,7 +225,18 @@ namespace _2021_backend.Pages.Sessions
|
|||
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()
|
||||
{
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
return c.Type == ClaimTypes.Role && (
|
||||
c.Value == "admin" || c.Value == "manager");
|
||||
}))
|
||||
{
|
||||
var stus = Context.Students.ToList();
|
||||
var sess = Context.Sessions.ToList();
|
||||
|
|
@ -193,7 +246,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
var ntm = new List<Session>();
|
||||
foreach (var j in tm)
|
||||
{
|
||||
var k = sess.Find(it => it.Guid == j);
|
||||
var k = sess.Find(it => it.Id == j);
|
||||
ntm.Add(k);
|
||||
}
|
||||
ntm.Sort((Session a, Session b) =>
|
||||
|
|
@ -202,17 +255,17 @@ namespace _2021_backend.Pages.Sessions
|
|||
var y = a.BeginTime.CompareTo(b.BeginTime);
|
||||
return x != 0 ? x : y;
|
||||
});
|
||||
List<Guid> nl = new List<Guid>();
|
||||
List<int> nl = new List<int>();
|
||||
foreach (var j in ntm)
|
||||
{
|
||||
if (i.Status != status.不通过 && i.Status != status.通过 && i.Status != status.已确认时间)
|
||||
{
|
||||
if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k ==i.Guid) )) continue;
|
||||
nl.Add(j.Guid);
|
||||
if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k == i.Id))) continue;
|
||||
nl.Add(j.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
nl.Add(j.Guid);
|
||||
nl.Add(j.Id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -221,9 +274,20 @@ namespace _2021_backend.Pages.Sessions
|
|||
Context.SaveChanges();
|
||||
return Construct("");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Construct("您无权进行此操作");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostLoadAsync()
|
||||
{
|
||||
if (HttpContext.User.HasClaim((c) =>
|
||||
{
|
||||
return c.Type == ClaimTypes.Role && (
|
||||
c.Value == "admin" || c.Value == "manager");
|
||||
}))
|
||||
{
|
||||
var str = "";
|
||||
|
||||
|
|
@ -236,9 +300,9 @@ namespace _2021_backend.Pages.Sessions
|
|||
{
|
||||
if (s.Status == status.已选时间)
|
||||
{
|
||||
s.InterviewTime = Guid.Empty;
|
||||
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
|
||||
s.Timelist.Sort((Guid a, Guid b) =>
|
||||
s.InterviewTime = 0;
|
||||
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
|
||||
s.Timelist.Sort((int a, int b) =>
|
||||
{
|
||||
var x = Context.Sessions.Find(a);
|
||||
var y = Context.Sessions.Find(b);
|
||||
|
|
@ -256,7 +320,7 @@ namespace _2021_backend.Pages.Sessions
|
|||
Context.SaveChanges();
|
||||
foreach (var item in loads)
|
||||
{
|
||||
Session s = Context.Sessions.Find(item.Guid);
|
||||
Session s = Context.Sessions.Find(item.Id);
|
||||
if (s != null)
|
||||
{
|
||||
s.BeginTime = item.BeginTime;
|
||||
|
|
@ -264,12 +328,12 @@ namespace _2021_backend.Pages.Sessions
|
|||
s.Capacity = item.Capacity;
|
||||
s.SendSMS = item.SendSMS;
|
||||
s.Chiefs = item.Chiefs;
|
||||
s.Students = new List<Guid>();
|
||||
s.Students = new List<int>();
|
||||
foreach (var s2 in item.Students)
|
||||
{
|
||||
if (Context.Students.Any(k => k.Guid == s2))
|
||||
if (Context.Students.Any(k => k.Id == s2))
|
||||
{
|
||||
Context.Students.Find(s2).InterviewTime = item.Guid;
|
||||
Context.Students.Find(s2).InterviewTime = item.Id;
|
||||
s.Students.Add(s2);
|
||||
}
|
||||
}
|
||||
|
|
@ -278,6 +342,11 @@ namespace _2021_backend.Pages.Sessions
|
|||
Context.SaveChanges();
|
||||
return Construct("");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Construct("您无权进行此操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<input type="submit" value="删除" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace _2021_backend.Pages.Students
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
int id = int.Parse(idstr);
|
||||
|
||||
Student = await Context.Students.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
Student = await Context.Students.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (Student == null)
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
int id = int.Parse(idstr);
|
||||
|
||||
Student = await Context.Students.FindAsync(id);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
<h5>此人的最终得分 : @Html.DisplayFor(model => model.Student.Score)</h5>
|
||||
<form method="post" class="form-inline m-2">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<div class="mb-2">
|
||||
操作
|
||||
</div>
|
||||
|
|
@ -83,8 +83,34 @@
|
|||
<div class="mb-2">
|
||||
给他打分
|
||||
<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 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>
|
||||
<br />
|
||||
|
||||
|
|
@ -131,7 +157,7 @@
|
|||
<span asp-validation-for="NewComment" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<input type="submit" value="→" class="btn btn-primary btn-sm" />
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -175,7 +201,7 @@
|
|||
{
|
||||
var it = Model.Student.Timelist[i];
|
||||
var dt = Model.Context.Sessions.Find(it);
|
||||
if (dt.Capacity > dt.Students.Count || dt.Students.Contains(Model.Student.Guid))
|
||||
if (dt.Capacity > dt.Students.Count || dt.Students.Contains(Model.Student.Id))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -211,9 +237,9 @@
|
|||
</td>
|
||||
<td>
|
||||
<form method="post" class="form-inline">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<a asp-page="/Sessions/Edit" asp-route-id="@it.ToString()" class="btn btn-sm btn-primary">场次详情</a>
|
||||
<input type="submit" asp-page-handler="Select" asp-route-stu="@Model.Student.Guid" asp-route-time="@it.ToString()" class="btn btn-sm btn-warning" value="选择这个" />
|
||||
<input type="submit" asp-page-handler="Select" asp-route-stu="@Model.Student.Id" asp-route-time="@it.ToString()" class="btn btn-sm btn-warning" value="选择这个" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -225,7 +251,7 @@
|
|||
Ta的短信
|
||||
</h4>
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<input type="submit" value="拉取5天内的回复短信" class="btn btn-primary" asp-page-handler="Pull" />
|
||||
<input type="submit" value="发送报名确认短信" class="btn btn-primary" asp-page-handler="Sign" />
|
||||
<input type="submit" value="发送活动场次确认短信" class="btn btn-primary" asp-page-handler="Time" />
|
||||
|
|
@ -355,8 +381,8 @@
|
|||
@Html.DisplayFor(modelItem => sub.SubmitTime)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Guid">Edit</a> |
|
||||
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Guid">Details</a>
|
||||
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Id">Edit</a> |
|
||||
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Id">Details</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
@ -366,6 +392,6 @@
|
|||
|
||||
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-idstr="@Model.Student.Guid">编辑信息</a> |
|
||||
<a asp-page="./Edit" asp-route-idstr="@Model.Student.Id">编辑信息</a> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace _2021_backend.Pages.Students
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
int id = int.Parse(idstr);
|
||||
Student = Context.Students.Find(id);
|
||||
if (Student == null)
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ namespace _2021_backend.Pages.Students
|
|||
Sessions.Add(tm);
|
||||
}
|
||||
Messages = Context.SMS.Where(it => it.Host == id).ToList();
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList();
|
||||
Sessions.Sort((Session a, Session b) => {
|
||||
var x = a.Day.CompareTo(b.Day);
|
||||
var y = a.BeginTime.CompareTo(b.BeginTime);
|
||||
|
|
@ -84,60 +84,60 @@ namespace _2021_backend.Pages.Students
|
|||
if (!string.IsNullOrWhiteSpace(NewComment))
|
||||
{
|
||||
var cmt = new Comment();
|
||||
cmt.Student = Student.Guid;
|
||||
cmt.Student = Student.Id;
|
||||
cmt.Content = NewComment;
|
||||
cmt.Operator = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value);
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
stu.Comments.Add(cmt.Guid);
|
||||
cmt.Operator = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value);
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
stu.Comments.Add(cmt.Id);
|
||||
Context.Comments.Add(cmt);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
Construct(Student.Id.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Id.ToString() });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAcceptAsync()
|
||||
{
|
||||
Student = Context.Students.Find(Student.Guid);
|
||||
Student = Context.Students.Find(Student.Id);
|
||||
Student.Status = status.通过;
|
||||
Context.SaveChanges();
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList();
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList();
|
||||
Construct(Student.Id.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Id.ToString() });
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostRejectAsync()
|
||||
{
|
||||
Student = Context.Students.Find(Student.Guid);
|
||||
Student = Context.Students.Find(Student.Id);
|
||||
Student.Status = status.不通过;
|
||||
Context.SaveChanges();
|
||||
Student.Score = 0;
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList();
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Id).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Id).ToList();
|
||||
Construct(Student.Id.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Id.ToString() });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSelectAsync(Guid stu, Guid time)
|
||||
public async Task<IActionResult> OnPostSelectAsync(int stu, int time)
|
||||
{
|
||||
var st = Context.Students.Find(stu);
|
||||
if (st != null)
|
||||
{
|
||||
|
||||
if (Context.Sessions.Any(it => it.Guid == time))
|
||||
if (Context.Sessions.Any(it => it.Id == time))
|
||||
{
|
||||
var tm = Context.Sessions.Find(time);
|
||||
if (tm.Students.Count < tm.Capacity)
|
||||
{
|
||||
if (st.InterviewTime != Guid.Empty)
|
||||
if (st.InterviewTime != 0)
|
||||
{
|
||||
var tmold = Context.Sessions.Find(st.InterviewTime);
|
||||
if (tmold != null)
|
||||
{
|
||||
tmold.Students.RemoveAll(it => it == st.Guid);
|
||||
tmold.Students.RemoveAll(it => it == st.Id);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
|
@ -148,58 +148,58 @@ namespace _2021_backend.Pages.Students
|
|||
}
|
||||
}
|
||||
}
|
||||
return Construct(Student.Guid.ToString());
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostPullAsync()
|
||||
{
|
||||
await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Guid), true);
|
||||
return Construct(Student.Guid.ToString());
|
||||
await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Id), true);
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostRankAsync()
|
||||
{
|
||||
var s = Context.Students.Find(Student.Guid);
|
||||
var s = Context.Students.Find(Student.Id);
|
||||
s.Score = score;
|
||||
s.Status = status.已评分;
|
||||
Context.SaveChanges();
|
||||
return Construct(Student.Guid.ToString());
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostResultAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
if (stu.Status == status.通过)
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Accept, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Accept, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
else if (stu.Status == status.不通过)
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Reject, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Guid.ToString());
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Reject, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSignAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Guid.ToString());
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSelectTimeAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
stu.Status = status.需调整时间;
|
||||
Context.SaveChanges();
|
||||
return Construct(Student.Guid.ToString());
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostTimeAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
stu.Status = status.已确认时间;
|
||||
Context.SaveChanges();
|
||||
return Construct(Student.Guid.ToString());
|
||||
return Construct(Student.Id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="hidden" asp-for="Student.Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Name" class="control-label"></label>
|
||||
<input asp-for="Student.Name" class="form-control" />
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ namespace _2021_backend.Pages.Students
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Guid == id);
|
||||
int id = int.Parse(idstr);
|
||||
Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (Student == null)
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ namespace _2021_backend.Pages.Students
|
|||
// For more details, see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
var stu = Context.Students.Find(Student.Id);
|
||||
stu.Status = Student.Status;
|
||||
stu.Email = Student.Email;
|
||||
stu.Name = Student.Name;
|
||||
|
|
@ -53,9 +53,9 @@ namespace _2021_backend.Pages.Students
|
|||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool StudentExists(Guid id)
|
||||
private bool StudentExists(int id)
|
||||
{
|
||||
return Context.Students.Any(e => e.Guid == id);
|
||||
return Context.Students.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@
|
|||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Name)</a>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()"> @Html.DisplayFor(modelItem => item.Name)</a>
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Stuid)</a>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()"> @Html.DisplayFor(modelItem => item.Stuid)</a>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sex)
|
||||
|
|
@ -135,9 +135,9 @@
|
|||
@Html.DisplayFor(modelItem => item.RegisterTime)
|
||||
</th>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-idstr="@item.Guid.ToString()">编辑资料</a> |
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()">审阅</a> |
|
||||
<a asp-page="./Delete" asp-route-idstr="@item.Guid.ToString()">删除</a>
|
||||
<a asp-page="./Edit" asp-route-idstr="@item.Id.ToString()">编辑资料</a> |
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Id.ToString()">审阅</a> |
|
||||
<a asp-page="./Delete" asp-route-idstr="@item.Id.ToString()">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using _2021_backend.Utils;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace _2021_backend.Pages.Students
|
||||
{
|
||||
|
|
@ -95,6 +96,12 @@ namespace _2021_backend.Pages.Students
|
|||
}
|
||||
|
||||
public async Task<IActionResult> OnPostFinalizeAsync(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;
|
||||
|
||||
|
|
@ -106,8 +113,19 @@ namespace _2021_backend.Pages.Students
|
|||
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)
|
||||
|
|
@ -117,5 +135,10 @@ namespace _2021_backend.Pages.Students
|
|||
Context.SaveChanges();
|
||||
return Construct((int)pageId, errInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Construct(pageId ?? 0, "您无权进行此操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace _2021_backend.Pages.Submissions
|
|||
{
|
||||
stu = Student.create(Submission);
|
||||
stu.Status = status.刚报名;
|
||||
var q2 = from e in Context.Sessions select e.Guid;
|
||||
var q2 = from e in Context.Sessions select e.Id;
|
||||
var lst = q2.ToList();
|
||||
stu.Timelist = lst;
|
||||
Context.Students.Add(stu);
|
||||
|
|
@ -47,7 +47,7 @@ namespace _2021_backend.Pages.Submissions
|
|||
stu = q.FirstOrDefault();
|
||||
stu.Update(Submission);
|
||||
}
|
||||
Submission.Host = stu.Guid;
|
||||
Submission.Host = stu.Id;
|
||||
Context.Submissions.Add(Submission);
|
||||
Context.SaveChanges();
|
||||
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@
|
|||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Submission.Guid" />
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Guid.ToString()"/> |
|
||||
<input type="hidden" asp-for="Submission.Id" />
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Id.ToString()"/> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ namespace _2021_backend.Pages.Submissions
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string? strid)
|
||||
{
|
||||
Guid id = Guid.Parse(strid);
|
||||
int id = int.Parse(strid);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Submission = Context.Submissions.FirstOrDefault(m => m.Guid == id);
|
||||
Submission = Context.Submissions.FirstOrDefault(m => m.Id == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
|
|
@ -38,7 +38,7 @@ namespace _2021_backend.Pages.Submissions
|
|||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(Guid? id)
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ namespace _2021_backend.Pages.Submissions
|
|||
var stu = Context.Students.Find(Submission.Host);
|
||||
if (stu != null)
|
||||
{
|
||||
stu.Submissions.Remove(Submission.Guid);
|
||||
stu.Submissions.Remove(Submission.Id);
|
||||
}
|
||||
Context.Submissions.Remove(Submission);
|
||||
Context.SaveChanges();
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@
|
|||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Submission.Guid">Edit</a> |
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Submission.Id">Edit</a> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ namespace _2021_backend.Pages.Submissions
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(strid);
|
||||
Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
int id = int.Parse(strid);
|
||||
Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Submission.Guid" />
|
||||
<input type="hidden" asp-for="Submission.Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Name" class="control-label"></label>
|
||||
<input asp-for="Submission.Name" class="form-control" />
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ namespace _2021_backend.Pages.Submissions
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string? strid)
|
||||
{
|
||||
Guid id = Guid.Parse(strid);
|
||||
int id = int.Parse(strid);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
|
|
@ -57,7 +57,7 @@ namespace _2021_backend.Pages.Submissions
|
|||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!SubmissionExists(Submission.Guid))
|
||||
if (!SubmissionExists(Submission.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
|
@ -70,9 +70,9 @@ namespace _2021_backend.Pages.Submissions
|
|||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool SubmissionExists(Guid id)
|
||||
private bool SubmissionExists(int id)
|
||||
{
|
||||
return Context.Submissions.Any(e => e.Guid == id);
|
||||
return Context.Submissions.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@
|
|||
@Html.DisplayFor(modelItem => item.SubmitTime)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-strid="@item.Guid.ToString()">编辑</a> |
|
||||
<a asp-page="./Details" asp-route-strid="@item.Guid.ToString()">详细信息</a> |
|
||||
<a asp-page="./Delete" asp-route-strid="@item.Guid.ToString()">删除</a>
|
||||
<a asp-page="./Edit" asp-route-strid="@item.Id.ToString()">编辑</a> |
|
||||
<a asp-page="./Details" asp-route-strid="@item.Id.ToString()">详细信息</a> |
|
||||
<a asp-page="./Delete" asp-route-strid="@item.Id.ToString()">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="User.Guid" />
|
||||
<input type="hidden" asp-for="User.Id" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Users
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
User = _context.Users.Find(guid);
|
||||
User = _context.Users.Find(idx);
|
||||
|
||||
if (User == null)
|
||||
{
|
||||
|
|
@ -41,13 +41,13 @@ namespace _2021_backend.Pages.Users
|
|||
|
||||
public async Task<IActionResult> OnPostAsync(string id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
User = _context.Users.Find(id);
|
||||
User = _context.Users.Find(idx);
|
||||
|
||||
if (User != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@
|
|||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.User.Guid">Edit</a> |
|
||||
<a asp-page="./Edit" asp-route-id="@Model.User.Id">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ namespace _2021_backend.Pages.Users
|
|||
|
||||
public async Task<IActionResult> OnGetAsync(string id)
|
||||
{
|
||||
Guid guid = Guid.Parse(id);
|
||||
int idx = int.Parse(id);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
User = _context.Users.Find(guid);
|
||||
User = _context.Users.Find(idx);
|
||||
|
||||
if (User == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="USER.Guid" />
|
||||
<input type="hidden" asp-for="USER.Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="USER.stuID" class="control-label"></label>
|
||||
<input asp-for="USER.stuID" class="form-control" />
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace _2021_backend.Pages.Users
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid guid = Guid.Parse(id);
|
||||
USER = _context.Users.Find(guid);
|
||||
int idx = int.Parse(id);
|
||||
USER = _context.Users.Find(idx);
|
||||
|
||||
if (USER == null)
|
||||
{
|
||||
|
|
@ -52,12 +52,12 @@ namespace _2021_backend.Pages.Users
|
|||
return Page();
|
||||
}
|
||||
if (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).CountAsync() > 0
|
||||
&& (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).FirstOrDefaultAsync()).Guid != USER.Guid
|
||||
&& (await _context.Users.AsNoTracking().Where(u => u.stuID == USER.stuID).FirstOrDefaultAsync()).Id != USER.Id
|
||||
)
|
||||
return new ConflictResult();
|
||||
if (USER.Secret == null || USER.Secret == String.Empty)
|
||||
{
|
||||
var user = await _context.Users.AsNoTracking().Where(u => u.Guid == USER.Guid).FirstOrDefaultAsync();
|
||||
var user = await _context.Users.AsNoTracking().Where(u => u.Id == USER.Id).FirstOrDefaultAsync();
|
||||
user.Name = USER.Name;
|
||||
user.stuID = USER.stuID;
|
||||
user.isManager = USER.isManager;
|
||||
|
|
@ -65,7 +65,7 @@ namespace _2021_backend.Pages.Users
|
|||
}
|
||||
else
|
||||
{
|
||||
var user = await _context.Users.AsNoTracking().Where(u => u.Guid == USER.Guid).FirstOrDefaultAsync();
|
||||
var user = await _context.Users.AsNoTracking().Where(u => u.Id == USER.Id).FirstOrDefaultAsync();
|
||||
user.Name = USER.Name;
|
||||
user.stuID = USER.stuID;
|
||||
user.isManager = USER.isManager;
|
||||
|
|
@ -80,7 +80,7 @@ namespace _2021_backend.Pages.Users
|
|||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!UserExists(USER.Guid))
|
||||
if (!UserExists(USER.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
|
@ -93,9 +93,9 @@ namespace _2021_backend.Pages.Users
|
|||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool UserExists(Guid id)
|
||||
private bool UserExists(int id)
|
||||
{
|
||||
return _context.Users.Any(e => e.Guid == id);
|
||||
return _context.Users.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@
|
|||
@Html.DisplayFor(modelItem => item.isManager)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-id="@item.Guid">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.Guid">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.Guid">Delete</a>
|
||||
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
|||
16
Program.cs
16
Program.cs
|
|
@ -14,8 +14,11 @@ namespace _2021_backend
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
|
|
@ -26,14 +29,14 @@ namespace _2021_backend
|
|||
context.Database.Migrate();
|
||||
Console.WriteLine("Migration succeeded.");
|
||||
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 q = context.Users.Where(it => it.Name == botname);
|
||||
if (q.Count() == 0)
|
||||
{
|
||||
var botusr = new User();
|
||||
botusr.Name = botname;
|
||||
botusr.Guid = Guid.NewGuid();
|
||||
botusr.Id = 0;
|
||||
botusr.isManager = true;
|
||||
botusr.Secret = config["SMSBOT_SECRET"];
|
||||
botusr.stuID = config["SMSBOT_STUID"];
|
||||
|
|
@ -45,19 +48,18 @@ namespace _2021_backend
|
|||
User.Bot = q.FirstOrDefault();
|
||||
//do nothing cause I 've already got a bot
|
||||
}
|
||||
var id = Guid.Parse("4c20c535-3661-40c7-b4db-ce479675bbd7");
|
||||
while (context.Users.Any(e => e.Guid == id))
|
||||
var name = config["ADMIN_USERNAME"];
|
||||
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();
|
||||
}
|
||||
var usr = new User();
|
||||
usr.Guid = id;
|
||||
usr.Name = config["ADMIN_USERNAME"];
|
||||
usr.isManager = true;
|
||||
usr.Secret = EvaCryptoHelper.Password2Secret(config["ADMIN_PASSWORD"]);
|
||||
usr.stuID = "zjueva";
|
||||
Console.WriteLine(usr.Guid.ToString());
|
||||
Console.WriteLine(usr.Id.ToString());
|
||||
context.Users.Add(usr);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace _2021_backend
|
||||
{
|
||||
public class Startup
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ namespace _2021_backend.Utils
|
|||
var capb = 0;
|
||||
foreach (var tm in a.Timelist)
|
||||
{
|
||||
var t = sessions.Find(x => x.Guid == tm);
|
||||
var t = sessions.Find(x => x.Id == tm);
|
||||
capa += t.Capacity - t.Students.Count;
|
||||
}
|
||||
foreach (var tm in b.Timelist)
|
||||
{
|
||||
var t = sessions.Find(x => x.Guid == tm);
|
||||
var t = sessions.Find(x => x.Id == tm);
|
||||
capb += t.Capacity - t.Students.Count;
|
||||
}
|
||||
return capa - capb;
|
||||
|
|
@ -43,7 +43,7 @@ namespace _2021_backend.Utils
|
|||
var tmstr = "";
|
||||
foreach (var tm in st.Timelist)
|
||||
{
|
||||
var t = sessions.Find(x => x.Guid == tm);
|
||||
var t = sessions.Find(x => x.Id == tm);
|
||||
cap += t.Capacity - t.Students.Count;
|
||||
tmstr += t.Day.ToString("dd") + "-" + t.BeginTime.ToString("HH:mm-") + t.Place + " ";
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ namespace _2021_backend.Utils
|
|||
var lst = students[m].Timelist;
|
||||
var stu = students[m];
|
||||
|
||||
if (stu.Timelist.Contains(stu.InterviewTime) || stu.Timelist.Count() == 0 || stu.InterviewTime != Guid.Empty || stu.Status != status.已选时间)
|
||||
if (stu.Timelist.Contains(stu.InterviewTime) || stu.Timelist.Count() == 0 || stu.InterviewTime != 0 || stu.Status != status.已选时间)
|
||||
{
|
||||
|
||||
return m >= students.Count - 1 ? true : DFS(m + 1);
|
||||
|
|
@ -71,21 +71,21 @@ namespace _2021_backend.Utils
|
|||
var tm = Context.Sessions.Find(stu.InterviewTime);
|
||||
if (tm != null)
|
||||
{
|
||||
tm.Students.RemoveAll(it => it == stu.Guid);
|
||||
tm.Students.RemoveAll(it => it == stu.Id);
|
||||
}
|
||||
stu.InterviewTime = Guid.Empty;
|
||||
stu.InterviewTime = 0;
|
||||
}
|
||||
bool depth = false;
|
||||
foreach (var i in lst)
|
||||
{
|
||||
var tm = sessions.Find(s => s.Guid == i);
|
||||
var tm = sessions.Find(s => s.Id == i);
|
||||
if (tm.Students.Count < tm.Capacity && tm.Day.CompareTo(DateTime.Now.AddHours(-14)) > 0)
|
||||
{
|
||||
status prev = students[m].Status;
|
||||
Guid prevs = students[m].InterviewTime;
|
||||
int prevs = students[m].InterviewTime;
|
||||
students[m].Status = status.已选时间;
|
||||
students[m].InterviewTime = tm.Guid;
|
||||
tm.Students.Add(students[m].Guid);
|
||||
students[m].InterviewTime = tm.Id;
|
||||
tm.Students.Add(students[m].Id);
|
||||
if (m == students.Count - 1)
|
||||
{
|
||||
return true;
|
||||
|
|
@ -97,7 +97,7 @@ namespace _2021_backend.Utils
|
|||
{
|
||||
students[m].Status = prev;
|
||||
students[m].InterviewTime = prevs;
|
||||
tm.Students.Remove(students[m].Guid);
|
||||
tm.Students.Remove(students[m].Id);
|
||||
continue;
|
||||
}
|
||||
else return true;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ using TencentCloud.Common;
|
|||
using TencentCloud.Common.Profile;
|
||||
using TencentCloud.Sms.V20210111;
|
||||
using TencentCloud.Sms.V20210111.Models;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace _2021_backend.Utils
|
||||
{
|
||||
|
|
@ -21,12 +22,13 @@ namespace _2021_backend.Utils
|
|||
public static string SMSID_reject { get; set; }
|
||||
public static string SMSID_timeSet { get; set; }
|
||||
public static string SMSID_signed { get; set; }
|
||||
public static string SMSID_captcha { get; set; }
|
||||
|
||||
private static bool Initialized = false;
|
||||
|
||||
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_key = tencentKey;
|
||||
|
|
@ -36,6 +38,7 @@ namespace _2021_backend.Utils
|
|||
SMSID_timeSet = ID_timeSet;
|
||||
SMSID_signed = ID_submitted;
|
||||
SMSID_timeSelect = ID_timeSelect;
|
||||
SMSID_captcha = ID_captcha;
|
||||
Initialized = true;
|
||||
}
|
||||
public static async Task<bool> Pull(BackendContext Context, Student stu, bool fullPull)
|
||||
|
|
@ -80,9 +83,9 @@ namespace _2021_backend.Utils
|
|||
var lst = obj.PullSmsReplyStatusSet;
|
||||
foreach (var item in lst)
|
||||
{
|
||||
var msg = new SMS(item, stu.Guid);
|
||||
var msg = new SMS(item, stu.Id);
|
||||
Context.Add<SMS>(msg);
|
||||
stu.Messages.Add(msg.Guid);
|
||||
stu.Messages.Add(msg.Id);
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return true;
|
||||
|
|
@ -114,7 +117,7 @@ namespace _2021_backend.Utils
|
|||
req.PhoneNumberSet[0] = "+86" + stu.Tel;
|
||||
req.SmsSdkAppId = SMS_appid;
|
||||
req.SignName = "ZJUEVA";
|
||||
Guid index = stu.InterviewTime;
|
||||
int index = stu.InterviewTime;
|
||||
SMS sms = new SMS();
|
||||
switch (type)
|
||||
{
|
||||
|
|
@ -135,7 +138,7 @@ namespace _2021_backend.Utils
|
|||
break;
|
||||
case SMSType.TimeSet:
|
||||
sms.Type = SMSType.TimeSet;
|
||||
var q = from e in Context.Sessions where e.Guid == index select e;
|
||||
var q = from e in Context.Sessions where e.Id == index select e;
|
||||
var time = await q.FirstOrDefaultAsync();
|
||||
req.TemplateParamSet = new string[] { stu.Name, time.Day.ToString("dd") ,time.BeginTime.ToString("HH"),time.BeginTime.ToString("mm"), time.BeginTime.AddHours(1).ToString("HH") ,time.BeginTime.AddMinutes(30).ToString("mm")};
|
||||
req.TemplateId = SMSID_timeSet;
|
||||
|
|
@ -145,9 +148,21 @@ namespace _2021_backend.Utils
|
|||
req.TemplateParamSet = new string[] { stu.Name };
|
||||
req.TemplateId = SMSID_signed;
|
||||
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.Host = stu.Guid;
|
||||
sms.Host = stu.Id;
|
||||
var query = from e in Context.Users where e.stuID == sender select e;
|
||||
var usr = await query.FirstOrDefaultAsync();
|
||||
sms.Sender = usr == null ? "null" : usr.Name;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"SMS_ID_SUBMITTED": "1163892",
|
||||
"SMS_ID_TIMESET": "1232109",
|
||||
"SMS_ID_TIMESELECT": "1232577",
|
||||
"SMS_ID_CAPTCHA": "1312236",
|
||||
"TENCENT_ID": "AKIDYv5JGwKSJtCE0VjhOpyqSotgDTSaYIsF",
|
||||
"TENCENT_KEY": "mPzSimdGenpdCWcT5TcWBboreAQQ9bmh",
|
||||
"SMSBOT_NAME": "msgbot",
|
||||
|
|
|
|||
Loading…
Reference in New Issue