initial
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
public class Comment
|
||||
{
|
||||
public Comment()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
AddTime = DateTime.Now;
|
||||
}
|
||||
|
||||
[Key]
|
||||
public Guid Guid { get; set; }
|
||||
[Required()]
|
||||
[Display(Name ="评论者")]
|
||||
public Guid Operator { get; set; }
|
||||
|
||||
[Required()]
|
||||
[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)
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Operator = opid;
|
||||
Content = content;
|
||||
Student = stuguid;
|
||||
AddTime = DateTime.Now;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
public enum SMSType
|
||||
{
|
||||
Accept,
|
||||
Reject,
|
||||
TimeSelect,
|
||||
TimeSet,
|
||||
Signed,
|
||||
Reply
|
||||
}
|
||||
public class SMS
|
||||
{
|
||||
public SMS()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Tel = "";
|
||||
Data = new List<string> { };
|
||||
Type = SMSType.Accept;
|
||||
Sender = "";
|
||||
SendTime = DateTime.Now;
|
||||
}
|
||||
public SMS(SMSPartialDto dto, Guid host)
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Tel = dto.SubscriberNumber;
|
||||
Host = host;
|
||||
Sender = dto.SubscriberNumber.ToString();
|
||||
Data = (new string[] { dto.ReplyContent }).ToList<string>();
|
||||
Type = SMSType.Reply;
|
||||
var tm = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(dto.ReplyTime).ToLocalTime();
|
||||
SendTime = tm;
|
||||
}
|
||||
[Key]
|
||||
public Guid Guid { get; set; }
|
||||
[Display(Name ="Host")]
|
||||
public Guid Host { get; set; }
|
||||
[Display(Name ="电话号码")]
|
||||
public string Tel { get; set; }
|
||||
|
||||
[Display(Name ="短信内容")]
|
||||
public List<string> Data { get; set; }
|
||||
[Display(Name ="短信类型")]
|
||||
public SMSType Type { get; set; }
|
||||
[Display(Name ="发送者")]
|
||||
public string Sender { get; set; }
|
||||
[Display(Name = "发送时间")]
|
||||
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
|
||||
public DateTime SendTime { get; set; }
|
||||
}
|
||||
|
||||
public class SMSResponseDto
|
||||
{
|
||||
public class error
|
||||
{
|
||||
public string Code;
|
||||
public string Message;
|
||||
}
|
||||
public List<SMSPartialDto> PullSmsReplyStatusSet { get; set; }
|
||||
public string RequestId { get; set; }
|
||||
error Error { get; set; }
|
||||
}
|
||||
|
||||
public class SMSPartialDto
|
||||
{
|
||||
public string CountryCode { get; set; }
|
||||
public string ReplyContent { get; set; }
|
||||
public string SubscriberNumber { get; set; }
|
||||
public string ExtendCode { get; set; }
|
||||
public ulong ReplyTime { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string SignName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
public class Session
|
||||
{
|
||||
|
||||
public Session()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
}
|
||||
[Key]
|
||||
[Required()]
|
||||
[Display(Name = "场次GUID")]
|
||||
public Guid Guid { get; set; }
|
||||
[Required()]
|
||||
[Display(Name = "活动日期")]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
|
||||
public DateTime Day { get; set; }
|
||||
[Display(Name = "开始时间")]
|
||||
[DataType(DataType.Time)]
|
||||
[DisplayFormat(DataFormatString = "{0:t}", ApplyFormatInEditMode = true)]
|
||||
[Required()]
|
||||
public DateTime BeginTime { get; set; }
|
||||
[RegularExpression(@"^20[04]$", ErrorMessage = "200或204")]
|
||||
[Display(Name = "地点")]
|
||||
[Required()]
|
||||
public string Place { get; set; }
|
||||
[Display(Name = "主活动官")]
|
||||
public List<Guid> Chiefs { get; set; }
|
||||
|
||||
[Display(Name = "可容纳人数")]
|
||||
public int Capacity { get; set; }
|
||||
|
||||
[Display(Name = "短信通知")]
|
||||
public bool SendSMS { get; set; }
|
||||
[Display(Name = "活动的人")]
|
||||
public List<Guid> Students { get; set; }
|
||||
|
||||
}
|
||||
public class SessionDto
|
||||
{
|
||||
|
||||
public DateTime Day { get; set; }
|
||||
public DateTime BeginTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SessionDtoComparer : IEqualityComparer<SessionDto>
|
||||
{
|
||||
#region IEqualityComparer<user> Members
|
||||
public bool Equals(SessionDto a,SessionDto b)
|
||||
{
|
||||
return a.Day == b.Day && a.BeginTime == b.BeginTime;
|
||||
}
|
||||
public int GetHashCode(SessionDto a)
|
||||
{
|
||||
return a.Day.GetHashCode() + a.BeginTime.GetHashCode();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
public enum status
|
||||
{
|
||||
刚报名,
|
||||
通过,
|
||||
已选时间,
|
||||
需调整时间,
|
||||
已确认时间,
|
||||
不通过,
|
||||
已评分,
|
||||
暂缺
|
||||
}
|
||||
|
||||
public enum yard
|
||||
{
|
||||
暂缺 = 0,
|
||||
丹青 = 1,
|
||||
蓝田 = 2,
|
||||
云峰 = 3,
|
||||
竺院 = 4,
|
||||
其他 = 5,
|
||||
}
|
||||
|
||||
public enum sex
|
||||
{
|
||||
Boy = 1,
|
||||
Girl = 0,
|
||||
Unknown = 2
|
||||
}
|
||||
public enum grade
|
||||
{
|
||||
暂缺 = 0,
|
||||
大一 = 1,
|
||||
大二 = 2,
|
||||
大三 = 3,
|
||||
大四 = 4,
|
||||
}
|
||||
public enum experience
|
||||
{
|
||||
暂缺 = 0,
|
||||
萌新 = 1,
|
||||
略有了解 = 2,
|
||||
了解较多 = 3,
|
||||
轻车熟路 = 4
|
||||
}
|
||||
|
||||
public class Student
|
||||
{
|
||||
public void Update(Submission sub)
|
||||
{
|
||||
Name = sub.Name;
|
||||
Email = sub.Email;
|
||||
Tel = sub.Tel;
|
||||
Stuid = sub.Stuid;
|
||||
Sex = sub.Sex;
|
||||
Grade = sub.Grade;
|
||||
Major = sub.Major;
|
||||
Yard = sub.Yard;
|
||||
Exp = sub.Exp;
|
||||
Timelist = sub.Timelist;
|
||||
Submissions.Add(sub.Guid);
|
||||
}
|
||||
public Student()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
Comments = new List<Guid>();
|
||||
Messages = new List<Guid>();
|
||||
Submissions = new List<Guid>();
|
||||
Timelist = new List<Guid>();
|
||||
}
|
||||
|
||||
public static Student create(Submission sub)
|
||||
{
|
||||
Student student = new Student();
|
||||
student.Guid = Guid.NewGuid();
|
||||
student.Name = sub.Name;
|
||||
student.Email = sub.Email;
|
||||
student.Tel = sub.Tel;
|
||||
student.Stuid = sub.Stuid;
|
||||
student.Sex = sub.Sex;
|
||||
student.Grade = sub.Grade;
|
||||
student.Major = sub.Major;
|
||||
student.Yard = sub.Yard;
|
||||
student.Exp = sub.Exp;
|
||||
student.Timelist = sub.Timelist;
|
||||
student.Submissions.Add(sub.Guid);
|
||||
student.RegisterTime = sub.SubmitTime;
|
||||
return student;
|
||||
}
|
||||
[Key]
|
||||
[Display(Name = "ID")]
|
||||
public Guid Guid { get; set; }
|
||||
[Display(Name = "姓名")]
|
||||
public string Name { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
public string Stuid { get; set; }
|
||||
[Display(Name = "性别")]
|
||||
public sex Sex { get; set; }
|
||||
[Display(Name = "年级")]
|
||||
public grade Grade { get; set; }
|
||||
|
||||
[Display(Name = "学园")]
|
||||
public yard Yard { get; set; }
|
||||
[Display(Name = "专业")]
|
||||
public string Major { get; set; }
|
||||
[Display(Name = "电子邮件")]
|
||||
public string Email { get; set; }
|
||||
[Display(Name = "电话")]
|
||||
public string Tel { get; set; }
|
||||
|
||||
[Display(Name = "经验程度")]
|
||||
public experience Exp { get; set; }
|
||||
|
||||
[Display(Name = "最终场次")]
|
||||
public Guid InterviewTime { get; set; }
|
||||
[Display(Name = "提交记录")]
|
||||
public List<Guid> Submissions { get; set; }
|
||||
[Display(Name = "短信记录")]
|
||||
public List<Guid> Messages { get; set; }
|
||||
[Display(Name = "可选场次")]
|
||||
public List<Guid> Timelist { get; set; }
|
||||
[Display(Name = "评论")]
|
||||
public List<Guid> Comments { get; set; }
|
||||
[Display(Name = "打分")]
|
||||
public int Score { get; set; }
|
||||
|
||||
[Display(Name = "状态")]
|
||||
public status Status { get; set; }
|
||||
|
||||
[Display(Name = "最近一次提交时间")]
|
||||
[DataType(DataType.DateTime)]
|
||||
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
|
||||
public DateTime LastSubmission { get; set; }
|
||||
[Display(Name = "报名时间")]
|
||||
[DataType(DataType.DateTime)]
|
||||
public DateTime RegisterTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
public class Submission
|
||||
{
|
||||
public Submission() {
|
||||
Guid = Guid.NewGuid();
|
||||
SubmitTime = DateTime.Now;
|
||||
}
|
||||
public Submission(SubmissionDto Dto, string ip)
|
||||
{
|
||||
Email = Dto.Email;
|
||||
Grade = (grade)(Dto.Grade);
|
||||
Sex = (sex)Dto.Sex;
|
||||
Stuid = Dto.Stuid;
|
||||
Major = Dto.Major;
|
||||
Name = Dto.Name;
|
||||
Tel = Dto.Tel;
|
||||
Exp = (experience)Dto.Exp;
|
||||
Yard = (yard)Dto.Yard;
|
||||
Timelist = new List<Guid>();
|
||||
Guid = System.Guid.NewGuid();
|
||||
SubmitTime = DateTime.Now;
|
||||
Address = ip;
|
||||
}
|
||||
[Key]
|
||||
[Display(Name = "ID")]
|
||||
public Guid Guid { get; set; }
|
||||
[Display(Name ="Host")]
|
||||
public Guid Host { get; set; }
|
||||
[Display(Name = "姓名")]
|
||||
public string Name { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
public string Stuid { get; set; }
|
||||
[Display(Name = "性别")]
|
||||
public sex Sex { get; set; }
|
||||
|
||||
[Display(Name = "学园")]
|
||||
public yard Yard { get; set; }
|
||||
[Display(Name = "年级")]
|
||||
public grade Grade { get; set; }
|
||||
[Display(Name = "专业")]
|
||||
public string Major { get; set; }
|
||||
[Display(Name = "电子邮件")]
|
||||
public string Email { get; set; }
|
||||
[Display(Name = "电话")]
|
||||
public string Tel { get; set; }
|
||||
|
||||
[Display(Name = "经验程度")]
|
||||
public experience Exp { get; set; }
|
||||
|
||||
[Display(Name = "时间列表")]
|
||||
public List<Guid> 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; }
|
||||
//活动场次ID
|
||||
|
||||
}
|
||||
public class TimeSpec
|
||||
{
|
||||
public DateTime Day { get; set; }
|
||||
public DateTime BeginTime { get; set; }
|
||||
}
|
||||
|
||||
public class SubmissionDto
|
||||
{
|
||||
[Required()]
|
||||
public string Name { get; set; }
|
||||
[Required()]
|
||||
public string Stuid { get; set; }
|
||||
[Required()]
|
||||
public int Sex { get; set; }
|
||||
[Required()]
|
||||
public int Grade { get; set; }
|
||||
[Required()]
|
||||
public int Yard { get; set; }
|
||||
[Required()]
|
||||
public string Major { get; set; }
|
||||
[Required()]
|
||||
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 static Regex r = new Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
|
||||
public static Regex phone_regex = new Regex("^1\\d{10}$");
|
||||
|
||||
public bool Iscomplete() => Name != null && Stuid != null && (Sex == 0 || Sex == 1) && Major != null && Email != null && Tel != null && Yard > 0 && Yard < 6;
|
||||
public bool Check()
|
||||
{
|
||||
if (Name.Length > 15)
|
||||
return false;
|
||||
if (Regex.Matches(Name, @"\d").Count > 0)
|
||||
return false;
|
||||
if (Stuid.Length > 10 || Stuid.Length < 7)
|
||||
return false;
|
||||
if (Sex > 1 || Sex < 0)
|
||||
return false;
|
||||
if (Grade < 0 || Grade > 4)
|
||||
return false;
|
||||
if (Major.Length > 20)
|
||||
return false;
|
||||
if (Yard >= 6 && Yard <= 0) return false;
|
||||
if(Exp >= 5 && Exp <= 0) return false;
|
||||
if (!r.IsMatch(Email))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!phone_regex.IsMatch(Tel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
|
||||
namespace _2021_backend.Models
|
||||
{
|
||||
|
||||
public class User
|
||||
{
|
||||
public User()
|
||||
{
|
||||
Guid = Guid.NewGuid();
|
||||
}
|
||||
|
||||
public static User Bot;
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name ="ID")]
|
||||
public Guid Guid { get; set; }
|
||||
[Display(Name = "学号")]
|
||||
public string stuID { get; set; }
|
||||
[Display(Name ="姓名")]
|
||||
public string Name { get; set; }
|
||||
[Display(Name ="密码")]
|
||||
public string Secret { get; set; }
|
||||
[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" };
|
||||
[JsonProperty("username")]
|
||||
public string id_student { get; set; }
|
||||
[JsonProperty("password")]
|
||||
public string Password { get; set; }
|
||||
public Login(string name,string pwd)
|
||||
{
|
||||
id_student = name;
|
||||
Password = pwd;
|
||||
}
|
||||
public string GetSHASecret() => _2021_backend.Utils.EvaCryptoHelper.Password2Secret(Password);
|
||||
public bool isManager()
|
||||
{
|
||||
if (Array.IndexOf(Manager,id_student) != -1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user