feat: 注册公众号用户时保存额外用户信息到数据库
This commit is contained in:
@@ -10,11 +10,13 @@ using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Fuwuhao;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
using Yi.Framework.AiHub.Domain.Managers.Fuwuhao;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Consts;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums.Fuwuhao;
|
||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.Account;
|
||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Services;
|
||||
|
||||
@@ -28,14 +30,14 @@ public class FuwuhaoService : ApplicationService
|
||||
private readonly FuwuhaoManager _fuwuhaoManager;
|
||||
private IDistributedCache<SceneCacheDto> _sceneCache;
|
||||
private IDistributedCache<string> _openIdToSceneCache;
|
||||
|
||||
private ISqlSugarRepository<AiUserExtraInfoEntity> _userRepository;
|
||||
private IAccountService _accountService;
|
||||
private IFileService _fileService;
|
||||
public IDistributedLockProvider DistributedLock => LazyServiceProvider.LazyGetService<IDistributedLockProvider>();
|
||||
|
||||
public FuwuhaoService(ILogger<FuwuhaoService> logger, IHttpContextAccessor accessor, FuwuhaoManager fuwuhaoManager,
|
||||
IDistributedCache<SceneCacheDto> sceneCache, IAccountService accountService, IFileService fileService,
|
||||
IDistributedCache<string> openIdToSceneCache)
|
||||
IDistributedCache<string> openIdToSceneCache, ISqlSugarRepository<AiUserExtraInfoEntity> userRepositroy)
|
||||
{
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
@@ -44,6 +46,7 @@ public class FuwuhaoService : ApplicationService
|
||||
_accountService = accountService;
|
||||
_fileService = fileService;
|
||||
_openIdToSceneCache = openIdToSceneCache;
|
||||
_userRepository = userRepositroy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -223,7 +226,7 @@ public class FuwuhaoService : ApplicationService
|
||||
|
||||
var result = await _fileService.Post(files);
|
||||
|
||||
await _accountService.PostSystemRegisterAsync(new RegisterDto
|
||||
var userId = await _accountService.PostSystemRegisterAsync(new RegisterDto
|
||||
{
|
||||
UserName = $"wx{Random.Shared.Next(100000, 999999)}",
|
||||
Password = Guid.NewGuid().ToString("N"),
|
||||
@@ -232,6 +235,7 @@ public class FuwuhaoService : ApplicationService
|
||||
Nick = userInfo.Nickname,
|
||||
Icon = result.FirstOrDefault()?.Id.ToString()
|
||||
});
|
||||
await _userRepository.InsertAsync(new AiUserExtraInfoEntity(userId, userInfo.OpenId));
|
||||
await _sceneCache.SetAsync($"{FuwuhaoConst.SceneCacheKey}:{scene}", new SceneCacheDto
|
||||
{
|
||||
SceneResult = SceneResultEnum.Register
|
||||
|
||||
Reference in New Issue
Block a user