removed migration ,altered Guid to int

This commit is contained in:
2022-02-22 17:14:10 +08:00
parent 166821a52e
commit e0115e0e07
48 changed files with 559 additions and 505 deletions
+12 -11
View File
@@ -11,30 +11,31 @@ namespace _2021_backend.Models
{
public Comment()
{
Guid = Guid.NewGuid();
AddTime = DateTime.Now;
Id = 0;
AddTime = DateTime.Now;
}
[Key]
public Guid Guid { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required()]
[Display(Name ="评论者")]
public Guid Operator { get; set; }
[Display(Name = "评论者")]
public int Operator { get; set; }
[Required()]
[Display(Name ="内容")]
[Display(Name = "内容")]
public string Content { get; set; }
[Display(Name = "评论时间")]
[DataType(DataType.DateTime)]
public DateTime AddTime { get; set; }
[Display(Name ="被评论者")]
public Guid Student { get; set; }
public Comment(Guid opid,string content, Guid stuguid)
[Display(Name = "被评论者")]
public int Student { get; set; }
public Comment(int opid, string content, int stuint)
{
Guid = Guid.NewGuid();
Id = 0;
Operator = opid;
Content = content;
Student = stuguid;
Student = stuint;
AddTime = DateTime.Now;
}
+12 -10
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ComponentModel.DataAnnotations.Schema;
namespace _2021_backend.Models
{
@@ -18,16 +19,16 @@ namespace _2021_backend.Models
{
public SMS()
{
Guid = Guid.NewGuid();
Id = 0;
Tel = "";
Data = new List<string> { };
Type = SMSType.Accept;
Sender = "";
SendTime = DateTime.Now;
}
public SMS(SMSPartialDto dto, Guid host)
public SMS(SMSPartialDto dto, int host)
{
Guid = Guid.NewGuid();
Id = 0;
Tel = dto.SubscriberNumber;
Host = host;
Sender = dto.SubscriberNumber.ToString();
@@ -37,17 +38,18 @@ namespace _2021_backend.Models
SendTime = tm;
}
[Key]
public Guid Guid { get; set; }
[Display(Name ="Host")]
public Guid Host { get; set; }
[Display(Name ="电话号码")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Display(Name = "Host")]
public int Host { get; set; }
[Display(Name = "电话号码")]
public string Tel { get; set; }
[Display(Name ="短信内容")]
[Display(Name = "短信内容")]
public List<string> Data { get; set; }
[Display(Name ="短信类型")]
[Display(Name = "短信类型")]
public SMSType Type { get; set; }
[Display(Name ="发送者")]
[Display(Name = "发送者")]
public string Sender { get; set; }
[Display(Name = "发送时间")]
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
+7 -6
View File
@@ -14,12 +14,13 @@ namespace _2021_backend.Models
public Session()
{
Guid = Guid.NewGuid();
Id = 0;
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required()]
[Display(Name = "场次GUID")]
public Guid Guid { get; set; }
[Display(Name = "场次int")]
public int Id { get; set; }
[Required()]
[Display(Name = "活动日期")]
[DataType(DataType.Date)]
@@ -35,7 +36,7 @@ namespace _2021_backend.Models
[Required()]
public string Place { get; set; }
[Display(Name = "主活动官")]
public List<Guid> Chiefs { get; set; }
public List<int> Chiefs { get; set; }
[Display(Name = "可容纳人数")]
public int Capacity { get; set; }
@@ -43,7 +44,7 @@ namespace _2021_backend.Models
[Display(Name = "短信通知")]
public bool SendSMS { get; set; }
[Display(Name = "活动的人")]
public List<Guid> Students { get; set; }
public List<int> Students { get; set; }
}
public class SessionDto
@@ -57,7 +58,7 @@ namespace _2021_backend.Models
public class SessionDtoComparer : IEqualityComparer<SessionDto>
{
#region IEqualityComparer<user> Members
public bool Equals(SessionDto a,SessionDto b)
public bool Equals(SessionDto a, SessionDto b)
{
return a.Day == b.Day && a.BeginTime == b.BeginTime;
}
+20 -18
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
@@ -64,22 +65,22 @@ namespace _2021_backend.Models
Major = sub.Major;
Yard = sub.Yard;
Exp = sub.Exp;
Timelist = sub.Timelist;
Submissions.Add(sub.Guid);
Timelist = sub.Timelist;
Submissions.Add(sub.Id);
}
public Student()
{
Guid = Guid.NewGuid();
Comments = new List<Guid>();
Messages = new List<Guid>();
Submissions = new List<Guid>();
Timelist = new List<Guid>();
Id = 0;
Comments = new List<int>();
Messages = new List<int>();
Submissions = new List<int>();
Timelist = new List<int>();
}
public static Student create(Submission sub)
{
Student student = new Student();
student.Guid = Guid.NewGuid();
student.Id = 0;
student.Name = sub.Name;
student.Email = sub.Email;
student.Tel = sub.Tel;
@@ -90,13 +91,14 @@ namespace _2021_backend.Models
student.Yard = sub.Yard;
student.Exp = sub.Exp;
student.Timelist = sub.Timelist;
student.Submissions.Add(sub.Guid);
student.Submissions.Add(sub.Id);
student.RegisterTime = sub.SubmitTime;
return student;
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name = "ID")]
public Guid Guid { get; set; }
public int Id { get; set; }
[Display(Name = "姓名")]
public string Name { get; set; }
[Display(Name = "学号")]
@@ -107,7 +109,7 @@ namespace _2021_backend.Models
public grade Grade { get; set; }
[Display(Name = "学园")]
public yard Yard { get; set; }
public yard Yard { get; set; }
[Display(Name = "专业")]
public string Major { get; set; }
[Display(Name = "电子邮件")]
@@ -116,20 +118,20 @@ namespace _2021_backend.Models
public string Tel { get; set; }
[Display(Name = "经验程度")]
public experience Exp { get; set; }
public experience Exp { get; set; }
[Display(Name = "最终场次")]
public Guid InterviewTime { get; set; }
public int InterviewTime { get; set; }
[Display(Name = "提交记录")]
public List<Guid> Submissions { get; set; }
public List<int> Submissions { get; set; }
[Display(Name = "短信记录")]
public List<Guid> Messages { get; set; }
public List<int> Messages { get; set; }
[Display(Name = "可选场次")]
public List<Guid> Timelist { get; set; }
public List<int> Timelist { get; set; }
[Display(Name = "评论")]
public List<Guid> Comments { get; set; }
public List<int> Comments { get; set; }
[Display(Name = "打分")]
public int Score { get; set; }
public int Score { get; set; }
[Display(Name = "状态")]
public status Status { get; set; }
+18 -15
View File
@@ -3,6 +3,7 @@ using Org.BouncyCastle.Asn1.Cms;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -11,8 +12,9 @@ namespace _2021_backend.Models
{
public class Submission
{
public Submission() {
Guid = Guid.NewGuid();
public Submission()
{
Id = 0;
SubmitTime = DateTime.Now;
}
public Submission(SubmissionDto Dto, string ip)
@@ -26,16 +28,17 @@ namespace _2021_backend.Models
Tel = Dto.Tel;
Exp = (experience)Dto.Exp;
Yard = (yard)Dto.Yard;
Timelist = new List<Guid>();
Guid = System.Guid.NewGuid();
Timelist = new List<int>();
Id = 0;
SubmitTime = DateTime.Now;
Address = ip;
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name = "ID")]
public Guid Guid { get; set; }
[Display(Name ="Host")]
public Guid Host { get; set; }
public int Id { get; set; }
[Display(Name = "Host")]
public int Host { get; set; }
[Display(Name = "姓名")]
public string Name { get; set; }
[Display(Name = "学号")]
@@ -58,9 +61,9 @@ namespace _2021_backend.Models
public experience Exp { get; set; }
[Display(Name = "时间列表")]
public List<Guid> Timelist { get; set; }
[Display(Name ="Ip Address")]
public string Address { get; set; }
public List<int> Timelist { get; set; }
[Display(Name = "Ip Address")]
public string Address { get; set; }
[Display(Name = "提交时间")]
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
public DateTime SubmitTime { get; set; }
@@ -69,8 +72,8 @@ namespace _2021_backend.Models
}
public class TimeSpec
{
public DateTime Day { get; set; }
public DateTime BeginTime { get; set; }
public DateTime Day { get; set; }
public DateTime BeginTime { get; set; }
}
public class SubmissionDto
@@ -91,12 +94,12 @@ namespace _2021_backend.Models
public string Email { get; set; }
[Required()]
public string Tel { get; set; }
[Required()]
public int Exp { get; set; }
[Required()]
public List<TimeSpec> Timelist { get; set; }
public List<TimeSpec> Timelist { get; set; }
public static Regex r = new Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
@@ -118,7 +121,7 @@ namespace _2021_backend.Models
if (Major.Length > 20)
return false;
if (Yard >= 6 && Yard <= 0) return false;
if(Exp >= 5 && Exp <= 0) return false;
if (Exp >= 5 && Exp <= 0) return false;
if (!r.IsMatch(Email))
{
return false;
+10 -10
View File
@@ -10,37 +10,37 @@ using Microsoft.EntityFrameworkCore.Internal;
namespace _2021_backend.Models
{
public class User
{
public User()
{
Guid = Guid.NewGuid();
Id = 0;
}
public static User Bot;
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name ="ID")]
public Guid Guid { get; set; }
[Display(Name = "ID")]
public int Id { get; set; }
[Display(Name = "学号")]
public string stuID { get; set; }
[Display(Name ="姓名")]
[Display(Name = "姓名")]
public string Name { get; set; }
[Display(Name ="密码")]
[Display(Name = "密码")]
public string Secret { get; set; }
[Display(Name ="是否管理员")]
[Display(Name = "是否管理员")]
public bool isManager { get; set; }
}
public class Login
{
private readonly string[] Manager = { "3200102610", "3190104611", "3190104698", "3190103719", "3190104143", "3190100494", "3190103301", "3190102034", "3190100151", "3190103577", "3190105399", "3190100133" };
private readonly string[] Manager = { "3200102610", "3190104611", "3190104698", "3190103719", "3190104143", "3190100494", "3190103301", "3190102034", "3190100151", "3190103577", "3190105399", "3190100133" };
[JsonProperty("username")]
public string id_student { get; set; }
[JsonProperty("password")]
public string Password { get; set; }
public Login(string name,string pwd)
public Login(string name, string pwd)
{
id_student = name;
Password = pwd;
@@ -48,7 +48,7 @@ namespace _2021_backend.Models
public string GetSHASecret() => _2021_backend.Utils.EvaCryptoHelper.Password2Secret(Password);
public bool isManager()
{
if (Array.IndexOf(Manager,id_student) != -1)
if (Array.IndexOf(Manager, id_student) != -1)
return true;
return false;
}