feat: 完成ai message、session搭建
This commit is contained in:
@@ -5,11 +5,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Authorization;
|
||||
using Volo.Abp.Caching;
|
||||
@@ -81,8 +77,8 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
/// <summary>
|
||||
/// 校验图片登录验证码,无需和账号绑定
|
||||
/// </summary>
|
||||
[RemoteService(isEnabled:false)]
|
||||
public void ValidationImageCaptcha(string? uuid,string? code )
|
||||
[RemoteService(isEnabled: false)]
|
||||
private void ValidationImageCaptcha(string? uuid, string? code)
|
||||
{
|
||||
if (_rbacOptions.EnableCaptcha)
|
||||
{
|
||||
@@ -109,7 +105,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
}
|
||||
|
||||
//校验验证码
|
||||
ValidationImageCaptcha(input.Uuid,input.Code);
|
||||
ValidationImageCaptcha(input.Uuid, input.Code);
|
||||
|
||||
UserAggregateRoot user = new();
|
||||
//校验
|
||||
@@ -174,7 +170,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
/// <summary>
|
||||
/// 验证电话号码
|
||||
/// </summary>
|
||||
/// <param name="str_handset"></param>
|
||||
/// <param name="phone"></param>
|
||||
private async Task ValidationPhone(string phone)
|
||||
{
|
||||
var res = Regex.IsMatch(phone, @"^\d{11}$");
|
||||
@@ -207,7 +203,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.RetrievePassword, input);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手机验证码-绑定
|
||||
/// </summary>
|
||||
@@ -219,20 +215,20 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.Bind, input);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手机验证码-需通过图形验证码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[RemoteService(isEnabled:false)]
|
||||
[RemoteService(isEnabled: false)]
|
||||
private async Task<object> PostCaptchaPhoneAsync(ValidationPhoneTypeEnum validationPhoneType,
|
||||
PhoneCaptchaImageDto input)
|
||||
{
|
||||
//验证uuid 和 验证码
|
||||
ValidationImageCaptcha(input.Uuid,input.Code);
|
||||
|
||||
ValidationImageCaptcha(input.Uuid, input.Code);
|
||||
|
||||
await ValidationPhone(input.Phone);
|
||||
|
||||
|
||||
if (validationPhoneType == ValidationPhoneTypeEnum.Register &&
|
||||
await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone))
|
||||
{
|
||||
@@ -310,7 +306,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[UnitOfWork]
|
||||
public async Task PostRegisterAsync(RegisterDto input)
|
||||
public async Task<LoginOutputDto> PostRegisterAsync(RegisterDto input)
|
||||
{
|
||||
if (_rbacOptions.EnableRegister == false)
|
||||
{
|
||||
@@ -321,20 +317,22 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
throw new UserFriendlyException("手机号不能为空");
|
||||
}
|
||||
|
||||
//临时账号
|
||||
if (input.UserName.StartsWith("ls_"))
|
||||
{
|
||||
throw new UserFriendlyException("注册账号不能以ls_字符开头");
|
||||
}
|
||||
|
||||
|
||||
if (_rbacOptions.EnableCaptcha)
|
||||
{
|
||||
//校验验证码,根据电话号码获取 value,比对验证码已经uuid
|
||||
await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.Register, input.Phone.Value, input.Code);
|
||||
}
|
||||
|
||||
//注册领域逻辑
|
||||
await _accountManager.RegisterAsync(input.UserName, input.Password, input.Phone, input.Nick);
|
||||
//注册之后,免再次登录,直接给前端token
|
||||
var userId = await _accountManager.RegisterAsync(input.UserName, input.Password, input.Phone, input.Nick);
|
||||
return await this.PostLoginAsync(userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -342,7 +340,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
/// 不需要验证,为了给第三方使用,例如微信小程序,后续可通过绑定操作,进行账号合并
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
[RemoteService(isEnabled:false)]
|
||||
[RemoteService(isEnabled: false)]
|
||||
public async Task PostTempRegisterAsync(RegisterDto input)
|
||||
{
|
||||
//注册领域逻辑
|
||||
@@ -423,13 +421,17 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
output =
|
||||
ObjectMapper.Map<List<MenuDto>, List<MenuAggregateRoot>>(menus.Where(x=>x.MenuSource==MenuSourceEnum.Ruoyi).ToList()).Vue3RuoYiRouterBuild();
|
||||
ObjectMapper
|
||||
.Map<List<MenuDto>, List<MenuAggregateRoot>>(menus
|
||||
.Where(x => x.MenuSource == MenuSourceEnum.Ruoyi).ToList()).Vue3RuoYiRouterBuild();
|
||||
}
|
||||
else if (routerType == "pure")
|
||||
{
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
output =
|
||||
ObjectMapper.Map<List<MenuDto>, List<MenuAggregateRoot>>(menus.Where(x=>x.MenuSource==MenuSourceEnum.Pure).ToList()).Vue3PureRouterBuild();
|
||||
ObjectMapper
|
||||
.Map<List<MenuDto>, List<MenuAggregateRoot>>(menus
|
||||
.Where(x => x.MenuSource == MenuSourceEnum.Pure).ToList()).Vue3PureRouterBuild();
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
Reference in New Issue
Block a user