diff --git a/YD_Event.Application/Client/Dtos/MiniProgramDtos.cs b/YD_Event.Application/Client/Dtos/MiniProgramDtos.cs
index 17a2b3e..85aaf07 100644
--- a/YD_Event.Application/Client/Dtos/MiniProgramDtos.cs
+++ b/YD_Event.Application/Client/Dtos/MiniProgramDtos.cs
@@ -2,54 +2,29 @@ using System.ComponentModel.DataAnnotations;
namespace YD_Event.Application.Client.Dtos;
-public class WeChatLoginInput
+///
+/// 小程序登录输入参数
+///
+public class MiniProgramLoginInput
{
///
- /// 微信临时授权码
+ /// 手机号
///
- [Required(ErrorMessage = "code不能为空")]
- public string Code { get; set; }
+ [Required(ErrorMessage = "手机号不能为空")]
+ [RegularExpression(@"^1[3456789]\d{9}$", ErrorMessage = "手机号格式不正确")]
+ public string Mobile { get; set; }
///
- /// 加密数据
+ /// 密码
///
- [Required(ErrorMessage = "encryptedData不能为空")]
- public string EncryptedData { get; set; }
-
- ///
- /// 初始向量
- ///
- [Required(ErrorMessage = "iv不能为空")]
- public string Iv { get; set; }
-
- ///
- /// 原始数据
- ///
- [Required(ErrorMessage = "rawData不能为空")]
- public string RawData { get; set; }
-
- ///
- /// 签名
- ///
- [Required(ErrorMessage = "signature不能为空")]
- public string Signature { get; set; }
+ public string Password { get; set; }
}
///
-/// 微信登录输出参数
+/// 小程序登录输出参数
///
-public class WeChatLoginOutput
+public class MiniProgramLoginOutput
{
- ///
- /// OpenId
- ///
- public string Openid { get; set; }
-
- ///
- /// 会话密钥
- ///
- public string SessionKey { get; set; }
-
///
/// 访问令牌
///
@@ -61,7 +36,7 @@ public class WeChatLoginOutput
public string RefreshToken { get; set; }
///
- /// 过期时间
+ /// 过期时间(秒)
///
public int ExpiresIn { get; set; }
@@ -72,50 +47,47 @@ public class WeChatLoginOutput
}
///
-/// 微信注册输入参数
+/// 小程序注册输入参数
///
-public class WeChatRegisterInput
+public class MiniProgramRegisterInput
{
///
- /// OpenId
+ /// 手机号(必填)
///
- [Required(ErrorMessage = "openid不能为空")]
- public string Openid { get; set; }
+ [Required(ErrorMessage = "手机号不能为空")]
+ [RegularExpression(@"^1[3456789]\d{9}$", ErrorMessage = "手机号格式不正确")]
+ public string Mobile { get; set; }
///
- /// 加密数据
+ /// 密码(必填)
///
- [Required(ErrorMessage = "encryptedData不能为空")]
- public string EncryptedData { get; set; }
+ [Required(ErrorMessage = "密码不能为空")]
+ [StringLength(32, MinimumLength = 6, ErrorMessage = "密码长度必须在6-32位之间")]
+ public string Password { get; set; }
///
- /// 初始向量
+ /// 验证码(必填)
///
- [Required(ErrorMessage = "iv不能为空")]
- public string Iv { get; set; }
+ [Required(ErrorMessage = "验证码不能为空")]
+ public string VerificationCode { get; set; }
///
- /// 原始数据
+ /// 昵称(可选)
///
- [Required(ErrorMessage = "rawData不能为空")]
- public string RawData { get; set; }
+ [StringLength(64, ErrorMessage = "昵称长度不能超过64个字符")]
+ public string NickName { get; set; }
///
- /// 签名
+ /// 头像(可选)
///
- [Required(ErrorMessage = "signature不能为空")]
- public string Signature { get; set; }
-
- ///
- /// 邀请码 (可选)
- ///
- public string? InviteCode { get; set; }
+ [StringLength(512, ErrorMessage = "头像URL长度不能超过512个字符")]
+ public string Avatar { get; set; }
}
///
-/// 微信注册输出参数
+/// 小程序注册输出参数
///
-public class WeChatRegisterOutput
+public class MiniProgramRegisterOutput
{
///
/// 用户ID
@@ -123,14 +95,14 @@ public class WeChatRegisterOutput
public long UserId { get; set; }
///
- /// 昵称
+ /// 手机号
///
- public string Nickname { get; set; }
+ public string Mobile { get; set; }
///
- /// 头像URL
+ /// 昵称
///
- public string AvatarUrl { get; set; }
+ public string NickName { get; set; }
///
/// 注册时间
@@ -139,123 +111,27 @@ public class WeChatRegisterOutput
}
///
-/// 微信重置密码输入参数
+/// 小程序重置密码输入参数
///
-public class WeChatResetPasswordInput
+public class MiniProgramResetPasswordInput
{
///
- /// OpenId
+ /// 手机号(必填)
///
- [Required(ErrorMessage = "openid不能为空")]
- public string Openid { get; set; }
+ [Required(ErrorMessage = "手机号不能为空")]
+ [RegularExpression(@"^1[3456789]\d{9}$", ErrorMessage = "手机号格式不正确")]
+ public string Mobile { get; set; }
///
- /// 加密数据
+ /// 新密码(必填)
///
- [Required(ErrorMessage = "encryptedData不能为空")]
- public string EncryptedData { get; set; }
+ [Required(ErrorMessage = "新密码不能为空")]
+ [StringLength(32, MinimumLength = 6, ErrorMessage = "密码长度必须在6-32位之间")]
+ public string NewPassword { get; set; }
///
- /// 初始向量
+ /// 验证码(必填)
///
- [Required(ErrorMessage = "iv不能为空")]
- public string Iv { get; set; }
-
- ///
- /// 邮箱 (可选)
- ///
- public string? Email { get; set; }
-
- ///
- /// 短信验证码 (可选)
- ///
- public string? SmsCode { get; set; }
-}
-
-///
-/// 微信重置密码输出参数
-///
-public class WeChatResetPasswordOutput
-{
- ///
- /// 重置令牌
- ///
- public string ResetToken { get; set; }
-
- ///
- /// 过期时间
- ///
- public DateTime ExpireTime { get; set; }
-
- ///
- /// 发送渠道 (email/sms)
- ///
- public string SendChannel { get; set; }
-}
-
-///
-/// 微信用户信息
-///
-public class WeChatUserInfo
-{
- ///
- /// OpenId
- ///
- public string OpenId { get; set; }
-
- ///
- /// 昵称
- ///
- public string NickName { get; set; }
-
- ///
- /// 性别
- ///
- public int Gender { get; set; }
-
- ///
- /// 城市
- ///
- public string City { get; set; }
-
- ///
- /// 省份
- ///
- public string Province { get; set; }
-
- ///
- /// 国家
- ///
- public string Country { get; set; }
-
- ///
- /// 头像URL
- ///
- public string AvatarUrl { get; set; }
-
- ///
- /// UnionId
- ///
- public string UnionId { get; set; }
-
- ///
- /// 水印
- ///
- public Watermark Watermark { get; set; }
-}
-
-///
-/// 水印信息
-///
-public class Watermark
-{
- ///
- /// 时间戳
- ///
- public long Timestamp { get; set; }
-
- ///
- /// AppId
- ///
- public string Appid { get; set; }
+ [Required(ErrorMessage = "验证码不能为空")]
+ public string VerificationCode { get; set; }
}
diff --git a/YD_Event.Application/Client/OAuthController.cs b/YD_Event.Application/Client/OAuthController.cs
index 3fefb1b..ff2a0d2 100644
--- a/YD_Event.Application/Client/OAuthController.cs
+++ b/YD_Event.Application/Client/OAuthController.cs
@@ -1,13 +1,6 @@
+using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
-using System.Security.Cryptography;
-using System.Text;
-using Microsoft.IdentityModel.Tokens;
-using System.IdentityModel.Tokens.Jwt;
using YD_Event.Application.Client.Dtos;
-using YD_Event.Core.Infrastructure.WeChat;
-using YD_Event.Application.Auth;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json;
namespace YD_Event.Application.Client;
@@ -17,33 +10,21 @@ namespace YD_Event.Application.Client;
[ApiDescriptionSettings("微信小程序接口")]
public class OAuthController : IDynamicApiController
{
- private readonly WeChatService _weChatTool;
- private readonly ISqlSugarRepository _accountRepository;
private readonly ISqlSugarRepository _appUserRepository;
- private readonly ISqlSugarRepository _roleRepository;
- private readonly ISqlSugarRepository _userRoleRepository;
- private readonly IEasyCachingProvider _easyCachingProvider;
+ private readonly IMemoryCache _memoryCache;
private readonly IIdGenerator _idGenerator;
private readonly ILogger _logger;
- private const string SessionKeyCachePrefix = "wechat_session_";
+ private const string SmsCodeCachePrefix = "sms:code:";
public OAuthController(
- WeChatService weChatTool,
- ISqlSugarRepository accountRepository,
ISqlSugarRepository appUserRepository,
- ISqlSugarRepository roleRepository,
- ISqlSugarRepository userRoleRepository,
- IEasyCachingProvider easyCachingProvider,
+ IMemoryCache memoryCache,
IIdGenerator idGenerator,
ILogger logger)
{
- _weChatTool = weChatTool;
- _accountRepository = accountRepository;
_appUserRepository = appUserRepository;
- _roleRepository = roleRepository;
- _userRoleRepository = userRoleRepository;
- _easyCachingProvider = easyCachingProvider;
+ _memoryCache = memoryCache;
_idGenerator = idGenerator;
_logger = logger;
}
@@ -55,52 +36,59 @@ public class OAuthController : IDynamicApiController
///
[HttpPost("login")]
[AllowAnonymous]
- public async Task Login([FromBody] WeChatLoginInput input)
+ public async Task Login([FromBody] MiniProgramLoginInput input)
{
- // 1. code2Session
- var sessionResult = await _weChatTool.Code2Session(input.Code);
- string openid = sessionResult.OpenId;
- string sessionKey = sessionResult.SessionKey;
-
- // 缓存 session_key,用于后续解密
- await _easyCachingProvider.SetAsync($"{SessionKeyCachePrefix}{openid}", sessionKey, TimeSpan.FromHours(2));
-
- // 2. 校验签名 (可选,根据业务严谨性)
- // var signature2 = Hash(input.RawData + sessionKey);
- // if (signature2 != input.Signature) throw Oops.Bah("签名校验失败");
-
- // 3. 查找用户
- var account = await _accountRepository.GetFirstAsync(x => x.OAuthId == openid && x.Type == "WeChat");
-
- string accessToken = null;
- string refreshToken = null;
- object userInfo = null;
- int expiresIn = 7200;
-
- if (account != null)
+ if (string.IsNullOrEmpty(input.Password) && string.IsNullOrEmpty(input.VerificationCode))
{
- // 生成 Token
- (accessToken, refreshToken) = GenerateTokens(account);
-
- // 获取用户信息
- var appUser = await _appUserRepository.GetFirstAsync(x => x.UserId == account.Id);
- if (appUser != null)
+ throw Oops.Bah("密码和验证码至少提供一个");
+ }
+
+ var appUser = await _appUserRepository.GetFirstAsync(x => x.Mobile == input.Mobile);
+ if (appUser == null)
+ {
+ throw Oops.Bah("用户不存在,请先注册");
+ }
+
+ if (!string.IsNullOrEmpty(input.Password))
+ {
+ if (string.IsNullOrEmpty(appUser.Password))
{
- userInfo = new { appUser.Name, appUser.Id, appUser.Mobile, appUser.Avatar, appUser.NickName };
+ throw Oops.Bah("该用户未设置密码,请使用验证码登录");
}
- else
+ var encryptedPassword = MD5Encryption.Encrypt($"{_idGenerator.Encode(appUser.Id)}{input.Password}");
+ if (appUser.Password != encryptedPassword)
{
- userInfo = new { account.Name, account.Avatar };
+ throw Oops.Bah("密码错误");
}
}
- return new WeChatLoginOutput
+ if (!string.IsNullOrEmpty(input.VerificationCode))
+ {
+ var cacheKey = $"{SmsCodeCachePrefix}{input.Mobile}";
+ string cachedCode = null;
+ if (!_memoryCache.TryGetValue(cacheKey, out cachedCode) || cachedCode != input.VerificationCode)
+ {
+ throw Oops.Bah("验证码错误或已过期");
+ }
+ _memoryCache.Remove(cacheKey);
+ }
+
+ (string accessToken, string refreshToken) = GenerateTokens(appUser);
+
+ var userInfo = new
+ {
+ appUser.Name,
+ appUser.Id,
+ appUser.Mobile,
+ appUser.Avatar,
+ appUser.NickName
+ };
+
+ return new MiniProgramLoginOutput
{
- Openid = openid,
- SessionKey = sessionKey, // 需求要求返回
AccessToken = accessToken,
RefreshToken = refreshToken,
- ExpiresIn = expiresIn,
+ ExpiresIn = 7200,
UserInfo = userInfo
};
}
@@ -113,204 +101,95 @@ public class OAuthController : IDynamicApiController
[HttpPost("register")]
[AllowAnonymous]
[UnitOfWork]
- public async Task Register([FromBody] WeChatRegisterInput input)
+ public async Task Register([FromBody] MiniProgramRegisterInput input)
{
- // 1. 获取 session_key
- var cacheKey = $"{SessionKeyCachePrefix}{input.Openid}";
- var sessionKeyCache = await _easyCachingProvider.GetAsync(cacheKey);
- if (!sessionKeyCache.HasValue) throw Oops.Bah("SessionKey已过期,请重新登录");
- string sessionKey = sessionKeyCache.Value;
-
- // 2. 解密用户信息
- string json = DecryptWeChatData(input.EncryptedData, sessionKey, input.Iv);
- var wxUser = JsonConvert.DeserializeObject(json);
- if (wxUser == null) throw Oops.Bah("解密用户信息失败");
-
- // 验证 watermark
- var configAppId = App.Configuration["WeChat:AppId"];
- if (!string.IsNullOrEmpty(configAppId) && wxUser.Watermark?.Appid != configAppId)
+ var cacheKey = $"{SmsCodeCachePrefix}{input.Mobile}";
+ string cachedCode = null;
+ if (!_memoryCache.TryGetValue(cacheKey, out cachedCode) || cachedCode != input.VerificationCode)
{
- // 仅记录警告,防止配置不一致导致注册失败
- _logger.LogWarning($"Watermark AppId mismatch: {wxUser.Watermark?.Appid} vs {configAppId}");
+ throw Oops.Bah("验证码错误或已过期");
+ }
+ _memoryCache.Remove(cacheKey);
+
+ if (await _appUserRepository.IsAnyAsync(x => x.Mobile == input.Mobile))
+ {
+ throw Oops.Bah("该手机号已注册");
}
- // 3. 写入 AuthAccount
- // 检查是否已存在
- if (await _accountRepository.IsAnyAsync(x => x.OAuthId == input.Openid && x.Type == "WeChat"))
- {
- throw Oops.Bah("该用户已注册");
- }
-
- long accountId = _idGenerator.NewLong();
- var account = new AuthAccount
- {
- Id = accountId,
- OAuthId = input.Openid,
- Type = "WeChat",
- Name = wxUser.NickName,
- Avatar = wxUser.AvatarUrl,
- Gender = (Gender)wxUser.Gender, // 假设 Gender 枚举兼容
- CreatedTime = DateTime.Now,
- CreatedUserId = accountId // 自指
- };
- await _accountRepository.InsertAsync(account);
-
- // 4. 写入 AppUser (Profile)
long appUserId = _idGenerator.NewLong();
+ var encryptedPassword = MD5Encryption.Encrypt($"{_idGenerator.Encode(appUserId)}{input.Password}");
+
var appUser = new YD_Event.Core.Entities.AppUser
{
Id = appUserId,
- UserId = accountId,
- Name = wxUser.NickName,
- NickName = wxUser.NickName,
- Avatar = wxUser.AvatarUrl,
- Gender = (Gender)wxUser.Gender,
- PersonType = PersonType.User, // 普通用户
+ Name = input.NickName ?? input.Mobile,
+ NickName = input.NickName,
+ Avatar = input.Avatar,
+ Gender = Gender.Unknown,
+ Mobile = input.Mobile,
+ Password = encryptedPassword,
+ PersonType = PersonType.User,
Status = AvailabilityStatus.Enable,
AuditStatus = AuditStatus.Pass,
CreatedTime = DateTime.Now,
- CreatedUserId = accountId
+ CreatedUserId = appUserId
};
await _appUserRepository.InsertAsync(appUser);
- // 5. 初始化默认角色
- // 查找默认角色,假设为 "OrdinaryUser" 或 "User"
- var defaultRole = await _roleRepository.GetFirstAsync(x => x.Code == "User" || x.Code == "OrdinaryUser");
- if (defaultRole == null)
+ return new MiniProgramRegisterOutput
{
- // 如果不存在,创建一个默认角色
- defaultRole = new SysRole
- {
- Id = _idGenerator.NewLong(),
- Name = "普通用户",
- Code = "User",
- Status = AvailabilityStatus.Enable,
- CreatedTime = DateTime.Now
- };
- await _roleRepository.InsertAsync(defaultRole);
- }
-
- // 绑定角色 (这里是 AppUser 还是 AuthAccount 绑定角色? SysUserRole 关联 UserId,通常指 AuthAccount.Id 或 SysUser.Id)
- // 假设 SysUserRole.UserId 对应 AuthAccount.Id (因为 AuthAccount 是登录主体)
- await _userRoleRepository.InsertAsync(new SysUserRole
- {
- Id = _idGenerator.NewLong(),
- UserId = accountId,
- RoleId = defaultRole.Id,
- CreatedTime = DateTime.Now
- });
-
- return new WeChatRegisterOutput
- {
- UserId = accountId,
- Nickname = account.Name,
- AvatarUrl = account.Avatar,
- RegisterTime = account.CreatedTime
+ UserId = appUser.Id,
+ Mobile = appUser.Mobile,
+ NickName = appUser.NickName,
+ RegisterTime = appUser.CreatedTime
};
}
///
- /// 找回密码接口
+ /// 重置密码接口
///
///
///
[HttpPost("reset-password")]
[AllowAnonymous]
- public async Task ResetPassword([FromBody] WeChatResetPasswordInput input)
+ public async Task ResetPassword([FromBody] MiniProgramResetPasswordInput input)
{
- // 1. 获取 session_key
- var cacheKey = $"{SessionKeyCachePrefix}{input.Openid}";
- var sessionKeyCache = await _easyCachingProvider.GetAsync(cacheKey);
- if (!sessionKeyCache.HasValue) throw Oops.Bah("SessionKey已过期,请重新登录");
- string sessionKey = sessionKeyCache.Value;
-
- // 2. 验证微信身份 (尝试解密)
- try
+ var cacheKey = $"{SmsCodeCachePrefix}{input.Mobile}";
+ string cachedCode = null;
+ if (!_memoryCache.TryGetValue(cacheKey, out cachedCode) || cachedCode != input.VerificationCode)
{
- string json = DecryptWeChatData(input.EncryptedData, sessionKey, input.Iv);
- var wxUser = JsonConvert.DeserializeObject(json);
- if (wxUser.OpenId != input.Openid) throw Oops.Bah("身份验证失败: OpenId不匹配");
+ throw Oops.Bah("验证码错误或已过期");
}
- catch (Exception ex)
+ _memoryCache.Remove(cacheKey);
+
+ var appUser = await _appUserRepository.GetFirstAsync(x => x.Mobile == input.Mobile);
+ if (appUser == null)
{
- _logger.LogError(ex, "ResetPassword Decrypt Failed");
- throw Oops.Bah("身份验证失败");
+ throw Oops.Bah("用户不存在");
}
- // 3. 生成一次性 Token
- string resetToken = Guid.NewGuid().ToString("N");
-
- // 4. 发送邮件/短信 (Mock)
- string sendChannel = "none";
- if (!string.IsNullOrEmpty(input.Email))
- {
- // Mock send email
- _logger.LogInformation($"Send Reset Token {resetToken} to Email {input.Email}");
- sendChannel = "email";
- }
- else if (!string.IsNullOrEmpty(input.SmsCode))
- {
- // Verify Sms Code (Mock)
- // Mock send sms
- _logger.LogInformation($"Verify SMS Code {input.SmsCode} and generate token");
- sendChannel = "sms";
- }
+ var encryptedPassword = MD5Encryption.Encrypt($"{_idGenerator.Encode(appUser.Id)}{input.NewPassword}");
+ appUser.Password = encryptedPassword;
+ appUser.UpdatedTime = DateTime.Now;
+ appUser.UpdatedUserId = appUser.Id;
- return new WeChatResetPasswordOutput
- {
- ResetToken = resetToken,
- ExpireTime = DateTime.Now.AddMinutes(15),
- SendChannel = sendChannel
- };
- }
-
- ///
- /// AES-128-CBC 解密
- ///
- private string DecryptWeChatData(string encryptedData, string sessionKey, string iv)
- {
- try
- {
- byte[] encryptedBytes = Convert.FromBase64String(encryptedData);
- byte[] keyBytes = Convert.FromBase64String(sessionKey);
- byte[] ivBytes = Convert.FromBase64String(iv);
-
- using var aes = Aes.Create();
- aes.KeySize = 128;
- aes.BlockSize = 128;
- aes.Mode = CipherMode.CBC;
- aes.Padding = PaddingMode.PKCS7;
- aes.Key = keyBytes;
- aes.IV = ivBytes;
-
- using var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
- using var ms = new MemoryStream(encryptedBytes);
- using var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read);
- using var sr = new StreamReader(cs);
- return sr.ReadToEnd();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "AES Decrypt Error");
- throw Oops.Bah("数据解密失败");
- }
+ await _appUserRepository.UpdateAsync(appUser);
}
///
/// 生成自定义 Token
///
- private (string AccessToken, string RefreshToken) GenerateTokens(AuthAccount account)
+ private (string AccessToken, string RefreshToken) GenerateTokens(YD_Event.Core.Entities.AppUser appUser)
{
long uniqueId = _idGenerator.NewLong();
string accessToken = JWTEncryption.Encrypt(new Dictionary()
{
- [AuthClaimsConst.AuthIdKey] = account.Id,
- [AuthClaimsConst.AccountKey] = account.OAuthId,
+ [AuthClaimsConst.AuthIdKey] = appUser.Id,
+ [AuthClaimsConst.AccountKey] = appUser.Mobile,
[AuthClaimsConst.UuidKey] = uniqueId,
[AuthClaimsConst.AuthPlatformTypeKey] = AuthPlatformType.WeChatApplet
});
- // 获取刷新 token
string refreshToken = JWTEncryption.GenerateRefreshToken(accessToken);
return (accessToken, refreshToken);
diff --git a/YD_Event.Application/Common/Dtos/SendVerificationCodeInput.cs b/YD_Event.Application/Common/Dtos/SendVerificationCodeInput.cs
index 50146c4..f0f9403 100644
--- a/YD_Event.Application/Common/Dtos/SendVerificationCodeInput.cs
+++ b/YD_Event.Application/Common/Dtos/SendVerificationCodeInput.cs
@@ -8,6 +8,4 @@ public class SendVerificationCodeInput
[Required(ErrorMessage = "手机号不能为空")]
[RegularExpression(@"^1[3456789]\d{9}$", ErrorMessage = "手机号格式不正确")]
public string Phone { get; set; } = null!;
-
- public string? Code { get; set; }
}
diff --git a/YD_Event.Application/Common/SmsService.cs b/YD_Event.Application/Common/SmsService.cs
index c48c1eb..115b007 100644
--- a/YD_Event.Application/Common/SmsService.cs
+++ b/YD_Event.Application/Common/SmsService.cs
@@ -16,7 +16,7 @@ public class SmsService : IDynamicApiController, ITransient
_memoryCache = memoryCache;
}
- [HttpPost("sms/sendVerificationCode")]
+ [HttpPost("sendVerificationCode")]
[DisplayName("发送短信验证码")]
[AllowAnonymous]
public async Task SendVerificationCode([FromBody] SendVerificationCodeInput input)
@@ -27,7 +27,7 @@ public class SmsService : IDynamicApiController, ITransient
throw Oops.Bah("发送太频繁,请稍后再试");
}
- string code = input.Code ?? new Random().Next(100000, 999999).ToString();
+ string code = new Random().Next(100000, 999999).ToString();
await _smsService.SendVerificationCode(input.Phone, code);
diff --git a/YD_Event.Application/Event/UserEventRegistrationService.cs b/YD_Event.Application/Event/UserEventRegistrationService.cs
index 42cb8c0..2088d19 100644
--- a/YD_Event.Application/Event/UserEventRegistrationService.cs
+++ b/YD_Event.Application/Event/UserEventRegistrationService.cs
@@ -360,7 +360,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
Gender = member.Gender,
IdCard = member.IdCardNumber,
Phone = member.Mobile,
- Age = member.Age,
+ Age = member.Age ?? 0,
BirthDate = member.BirthDate ?? DateTime.MinValue,
PersonType = PersonType.Athlete,
CreatedUserId = userId,
diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml
index dc6e7f0..c437991 100644
--- a/YD_Event.Application/YD_Event.Application.xml
+++ b/YD_Event.Application/YD_Event.Application.xml
@@ -2080,239 +2080,124 @@
拒绝/取消原因
-
+
- 微信临时授权码
+ 小程序登录输入参数
-
+
- 加密数据
+ 手机号
-
+
- 初始向量
+ 密码(可选,与验证码至少提供一个)
-
+
- 原始数据
+ 验证码(可选,与密码至少提供一个)
-
+
- 签名
+ 小程序登录输出参数
-
-
- 微信登录输出参数
-
-
-
-
- OpenId
-
-
-
-
- 会话密钥
-
-
-
+
访问令牌
-
+
刷新令牌
-
+
- 过期时间
+ 过期时间(秒)
-
+
用户信息
-
+
- 微信注册输入参数
+ 小程序注册输入参数
-
+
- OpenId
+ 手机号(必填)
-
+
- 加密数据
+ 密码(必填)
-
+
- 初始向量
+ 验证码(必填)
-
+
- 原始数据
+ 昵称(可选)
-
+
- 签名
+ 头像(可选)
-
+
- 邀请码 (可选)
+ 小程序注册输出参数
-
-
- 微信注册输出参数
-
-
-
+
用户ID
-
+
+
+ 手机号
+
+
+
昵称
-
-
- 头像URL
-
-
-
+
注册时间
-
+
- 微信重置密码输入参数
+ 小程序重置密码输入参数
-
+
- OpenId
+ 手机号(必填)
-
+
- 加密数据
+ 新密码(必填)
-
+
- 初始向量
-
-
-
-
- 邮箱 (可选)
-
-
-
-
- 短信验证码 (可选)
-
-
-
-
- 微信重置密码输出参数
-
-
-
-
- 重置令牌
-
-
-
-
- 过期时间
-
-
-
-
- 发送渠道 (email/sms)
-
-
-
-
- 微信用户信息
-
-
-
-
- OpenId
-
-
-
-
- 昵称
-
-
-
-
- 性别
-
-
-
-
- 城市
-
-
-
-
- 省份
-
-
-
-
- 国家
-
-
-
-
- 头像URL
-
-
-
-
- UnionId
-
-
-
-
- 水印
-
-
-
-
- 水印信息
-
-
-
-
- 时间戳
-
-
-
-
- AppId
+ 验证码(必填)
@@ -2719,33 +2604,28 @@
微信小程序认证接口
-
+
登录接口
-
+
注册接口
-
+
- 找回密码接口
+ 重置密码接口
-
-
- AES-128-CBC 解密
-
-
-
+
生成自定义 Token
diff --git a/YD_Event.Core/Entities/AppUser.cs b/YD_Event.Core/Entities/AppUser.cs
index 9b31839..1ed92ff 100644
--- a/YD_Event.Core/Entities/AppUser.cs
+++ b/YD_Event.Core/Entities/AppUser.cs
@@ -52,8 +52,8 @@ public class AppUser : Entity, ISoftDelete, ICreatedUserId, ICreatedTime,
///
/// 姓名
///
- [SugarColumn(Length = 64)]
- public string Name { get; set; }
+ [SugarColumn(Length = 64, IsNullable = true)]
+ public string? Name { get; set; }
///
/// 性别
@@ -63,7 +63,8 @@ public class AppUser : Entity, ISoftDelete, ICreatedUserId, ICreatedTime,
///
/// 年龄
///
- public int Age { get; set; }
+ [SugarColumn(IsNullable = true)]
+ public int? Age { get; set; }
///
/// 出生日期
@@ -75,18 +76,24 @@ public class AppUser : Entity, ISoftDelete, ICreatedUserId, ICreatedTime,
/// 联系电话
///
[SugarColumn(Length = 20)]
- public string Mobile { get; set; }
+ public string Mobile { get; set; } = null!;
+
+ ///
+ /// 密码(用于登录)
+ ///
+ [SugarColumn(Length = 64, IsNullable = true)]
+ public string? Password { get; set; }
///
/// 身份证号码
///
- [SugarColumn(Length = 20)]
- public string IdCardNumber { get; set; }
+ [SugarColumn(Length = 20, IsNullable = true)]
+ public string? IdCardNumber { get; set; }
///
/// 身份证图片URL
///
- [SugarColumn(Length = 512)]
+ [SugarColumn(Length = 512, IsNullable = true)]
public string? IdCardImageUrl { get; set; }
///
diff --git a/YD_Event.Core/Entities/AuthAccount.cs b/YD_Event.Core/Entities/AuthAccount.cs
deleted file mode 100644
index d47aded..0000000
--- a/YD_Event.Core/Entities/AuthAccount.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using YD_Event.Core.Enum;
-
-namespace YD_Event.Core.Entities;
-///
-/// 博客授权用户
-///
-public class AuthAccount : Entity, ISoftDelete, ICreatedUserId, ICreatedTime, IUpdatedUserId, IUpdatedTime
-{
- ///
- /// 授权唯一标识
- ///
- public string OAuthId { get; set; }
-
- ///
- /// 授权类型
- ///
- public string Type { get; set; }
-
- ///
- /// 博主标识
- ///
- public bool IsBlogger { get; set; }
-
- ///
- /// 姓名(昵称)
- ///
- [SugarColumn(Length = 64)]
- public string? Name { get; set; }
-
- ///
- /// 性别
- ///
- public Gender Gender { get; set; }
-
- ///
- /// 头像
- ///
- [SugarColumn(Length = 256)]
- public string? Avatar { get; set; }
-
- ///
- /// 邮箱
- ///
- [SugarColumn(Length = 128)]
- public string? Email { get; set; }
-
- ///
- /// 标记删除
- ///
- public bool DeleteMark { get; set; }
-
- ///
- /// 创建人
- ///
- public long CreatedUserId { get; set; }
-
- ///
- /// 创建时间
- ///
- public DateTime CreatedTime { get; set; }
-
- ///
- /// 更新人
- ///
- public long? UpdatedUserId { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime? UpdatedTime { get; set; }
-}
\ No newline at end of file
diff --git a/YD_Event.Core/YD_Event.Core.xml b/YD_Event.Core/YD_Event.Core.xml
index 87760b9..c87086c 100644
--- a/YD_Event.Core/YD_Event.Core.xml
+++ b/YD_Event.Core/YD_Event.Core.xml
@@ -509,6 +509,11 @@
联系电话
+
+
+ 密码(用于登录)
+
+
身份证号码
@@ -564,71 +569,6 @@
更新时间
-
-
- 博客授权用户
-
-
-
-
- 授权唯一标识
-
-
-
-
- 授权类型
-
-
-
-
- 博主标识
-
-
-
-
- 姓名(昵称)
-
-
-
-
- 性别
-
-
-
-
- 头像
-
-
-
-
- 邮箱
-
-
-
-
- 标记删除
-
-
-
-
- 创建人
-
-
-
-
- 创建时间
-
-
-
-
- 更新人
-
-
-
-
- 更新时间
-
-
轮播图配置