完善登录

This commit is contained in:
陈淳
2023-01-31 18:08:27 +08:00
parent b7260ed982
commit 5fb09c1c4a
77 changed files with 2333 additions and 288 deletions

View File

@@ -3,6 +3,9 @@ using NET.AutoWebApi.Setting;
using Yi.RBAC.Application.Contracts.Identity.Dtos;
using Yi.RBAC.Domain.Identity.Entities;
using Yi.Framework.Ddd.Services;
using Yi.RBAC.Domain.Shared.Identity.ConstClasses;
using Yi.RBAC.Domain.Identity;
using Yi.Framework.Uow;
namespace Yi.RBAC.Application.Identity
{
@@ -13,5 +16,41 @@ namespace Yi.RBAC.Application.Identity
public class UserService : CrudAppService<UserEntity, UserGetOutputDto, UserGetListOutputDto, long, UserGetListInputVo, UserCreateInputVo, UserUpdateInputVo>,
IUserService, IAutoApiService
{
[Autowired]
private UserManager _userManager { get; set; }
[Autowired]
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
/// <summary>
/// 添加用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
public async override Task<UserGetOutputDto> CreateAsync(UserCreateInputVo input)
{
if (string.IsNullOrEmpty(input.Password))
{
throw new UserFriendlyException(UserConst._密码为空);
}
if (await _repository.IsAnyAsync(u => input.UserName.Equals(u.UserName)))
{
throw new UserFriendlyException(UserConst._用户存在);
}
var entities = await MapToEntityAsync(input);
entities.BuildPassword();
using (var uow = _unitOfWorkManager.CreateContext())
{
var returnEntity = await _repository.InsertReturnEntityAsync(entities);
await _userManager.GiveUserSetRoleAsync(new List<long> { returnEntity.Id }, input.RoleIds);
await _userManager.GiveUserSetPostAsync(new List<long> { returnEntity.Id }, input.PostIds);
uow.Commit();
var result = await MapToGetOutputDtoAsync(returnEntity);
return result;
}
}
}
}