添加项目文件。

This commit is contained in:
SpecialX
2025-05-23 19:03:00 +08:00
parent 6fa7679fd3
commit d36fef2bbb
185 changed files with 13413 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.DTO
{
public class UserForRegistrationDto
{
[Required(ErrorMessage = "姓名是必填项。")]
[StringLength(50, MinimumLength = 2, ErrorMessage = "姓名长度必须在 2 到 50 个字符之间。")]
public string Name { get; set; }
[Required(ErrorMessage = "电子邮件是必填项。")]
[EmailAddress(ErrorMessage = "电子邮件格式不正确。")] // 添加 Email 格式验证
public string Email { get; set; }
[Required(ErrorMessage = "密码是必填项。")]
[StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度至少为 6 个字符。")] // 确保长度验证
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&.])[A-Za-z\d@$!%*?&.]{6,}$",
ErrorMessage = " @$!%*?&. ")]
public string Password { get; set; }
[Compare(nameof(Password), ErrorMessage = "密码和确认密码不匹配。")]
[Required(ErrorMessage = "确认密码是必填项。")] // 确保确认密码也必须填写
public string ConfirmPassword { get; set; }
[Required(ErrorMessage = "至少选择一个角色。")]
public UserRoles Roles { get; set; } = UserRoles.Student; // 根据你当前的 MudRadioGroup 设定,这里是单选
[Required(ErrorMessage = "班级是必填项。")]
[Range(1, 14, ErrorMessage = "班级编号必须在 1 到 14 之间。")] // 班级范围已调整为 1-14
public int Class { get; set; } = 1;
[Required(ErrorMessage = "年级是必填项。")]
[Range(1, 6, ErrorMessage = "年级编号必须在 1 到 6 之间。")] // 年级范围已调整为 1-6
public int Grade { get; set; } = 1;
[Phone(ErrorMessage = "电话号码格式不正确。")]
[StringLength(11, MinimumLength = 11, ErrorMessage = "电话号码必须是 11 位数字。")] // 电话号码长度已调整为固定 11 位
public string PhoneNumber { get; set; }
[StringLength(200, ErrorMessage = "家庭住址不能超过 200 个字符。")]
public string HomeAddress { get; set; }
public string ClientURI { get; set; }
}
}