添加项目文件。
This commit is contained in:
23
Entities/DTO/ApiResponse.cs
Normal file
23
Entities/DTO/ApiResponse.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace TechHelper.Services
|
||||
{
|
||||
public class ApiResponse
|
||||
{
|
||||
public ApiResponse(string message, bool status = false)
|
||||
{
|
||||
this.Message = message;
|
||||
this.Status = status;
|
||||
}
|
||||
|
||||
public ApiResponse(bool status, object result)
|
||||
{
|
||||
this.Status = status;
|
||||
this.Result = result;
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public bool Status { get; set; }
|
||||
|
||||
public object Result { get; set; }
|
||||
}
|
||||
}
|
12
Entities/DTO/AuthResponseDto.cs
Normal file
12
Entities/DTO/AuthResponseDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class AuthResponseDto
|
||||
{
|
||||
public bool IsAuthSuccessful { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public string? Token { get; set; }
|
||||
public string? RefreshToken { get; set; }
|
||||
public bool Is2StepVerificationRequired { get; set; }
|
||||
public string Provider { get; set; }
|
||||
}
|
||||
}
|
21
Entities/DTO/ClassDto.cs
Normal file
21
Entities/DTO/ClassDto.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class ClassDto
|
||||
{
|
||||
public byte Class { get; set; }
|
||||
|
||||
[StringLength(50, ErrorMessage = "班级名称不能超过 50 个字符。")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "年级是必填项。")]
|
||||
[Range(1, 12, ErrorMessage = "年级编号必须在 1 到 12 之间。")]
|
||||
public byte Grade { get; set; }
|
||||
|
||||
public string Description { get; set; } = "HELLO WORLD";
|
||||
|
||||
|
||||
public int? HeadTeacherId { get; set; }
|
||||
}
|
||||
}
|
17
Entities/DTO/ForgotPasswordDto.cs
Normal file
17
Entities/DTO/ForgotPasswordDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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 ForgotPasswordDto
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public string ClientURI { get; set; }
|
||||
}
|
||||
}
|
8
Entities/DTO/RefreshTokenDto.cs
Normal file
8
Entities/DTO/RefreshTokenDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class RefreshTokenDto
|
||||
{
|
||||
public string? Token { get; set; }
|
||||
public string? RefreshToken { get; set; }
|
||||
}
|
||||
}
|
22
Entities/DTO/ResetPasswordDto.cs
Normal file
22
Entities/DTO/ResetPasswordDto.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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 ResetPasswordDto
|
||||
{
|
||||
[Required(ErrorMessage = "Password is required")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Compare(nameof(Password), ErrorMessage = "The password and confirmation password do not match")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public string Token { get; set; }
|
||||
}
|
||||
}
|
14
Entities/DTO/ResetPasswordResponseDto.cs
Normal file
14
Entities/DTO/ResetPasswordResponseDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class ResetPasswordResponseDto
|
||||
{
|
||||
public bool IsResetPasswordSuccessful { get; set; }
|
||||
public IEnumerable<string> Errors { get; set; } = Enumerable.Empty<string>();
|
||||
}
|
||||
}
|
14
Entities/DTO/ResponseDto.cs
Normal file
14
Entities/DTO/ResponseDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class ResponseDto
|
||||
{
|
||||
public bool IsSuccessfulRegistration { get; set; }
|
||||
public IEnumerable<string> Errors { get; set; } = Enumerable.Empty<string>();
|
||||
}
|
||||
}
|
17
Entities/DTO/TwoFactorVerificationDto.cs
Normal file
17
Entities/DTO/TwoFactorVerificationDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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 TwoFactorVerificationDto
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public string Provider { get; set; }
|
||||
[Required(ErrorMessage = "Token is required")]
|
||||
public string TwoFactorToken { get; set; }
|
||||
}
|
||||
}
|
12
Entities/DTO/UserForAuthenticationDto.cs
Normal file
12
Entities/DTO/UserForAuthenticationDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class UserForAuthenticationDto
|
||||
{
|
||||
[Required(ErrorMessage = "Email is required")]
|
||||
public string? Email { get; set; }
|
||||
[Required(ErrorMessage = "Password is required")]
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
51
Entities/DTO/UserForRegistrationDto.cs
Normal file
51
Entities/DTO/UserForRegistrationDto.cs
Normal 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; }
|
||||
}
|
||||
}
|
18
Entities/DTO/UserRegistrationToClassDto.cs
Normal file
18
Entities/DTO/UserRegistrationToClassDto.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Entities.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Entities.DTO
|
||||
{
|
||||
public class UserRegistrationToClassDto
|
||||
{
|
||||
public string User { get; set; }
|
||||
public byte ClassId { get; set; }
|
||||
public byte GradeId { get; set; }
|
||||
public UserRoles Roles { get; set; } = UserRoles.Student;
|
||||
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user