添加授权鉴权模块
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Application.Student.StudentService.GetToken">
|
||||
<summary>
|
||||
测试token
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.Application.Student.StudentService.PostUow">
|
||||
<summary>
|
||||
Uow
|
||||
|
||||
@@ -16,6 +16,11 @@ using Yi.Framework.Ddd.Services;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Uow;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yi.Framework.Auth.JwtBearer.Authentication;
|
||||
using Yi.Framework.Core.Const;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Auth.JwtBearer.Authorization;
|
||||
using Yi.Framework.Domain.Shared.Student.ConstClasses;
|
||||
|
||||
namespace Yi.Framework.Application.Student
|
||||
{
|
||||
@@ -29,22 +34,37 @@ namespace Yi.Framework.Application.Student
|
||||
{
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
private readonly StudentManager _studentManager;
|
||||
//private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
public StudentService(IStudentRepository studentRepository, StudentManager studentManager, IUnitOfWorkManager unitOfWorkManager)
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
private readonly JwtTokenManager _jwtTokenManager;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
public StudentService(IStudentRepository studentRepository, StudentManager studentManager, IUnitOfWorkManager unitOfWorkManager, JwtTokenManager jwtTokenManager, ICurrentUser currentUser)
|
||||
{
|
||||
_studentRepository = studentRepository;
|
||||
_studentManager = studentManager;
|
||||
_unitOfWorkManager = unitOfWorkManager;
|
||||
_jwtTokenManager = jwtTokenManager;
|
||||
_currentUser=currentUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试token
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetToken()
|
||||
{
|
||||
var claimDic = new Dictionary<string, object>() { { TokenTypeConst.Id, "123" }, { TokenTypeConst.UserName, "cc" } };
|
||||
return _jwtTokenManager.CreateToken(claimDic);
|
||||
}
|
||||
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
/// <summary>
|
||||
/// Uow
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[Permission(AuthStudentConst.查询)]
|
||||
public async Task<StudentGetOutputDto> PostUow()
|
||||
{
|
||||
var o= _currentUser;
|
||||
StudentGetOutputDto res = new();
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Auth.JwtBearer\Yi.Framework.Auth.JwtBearer.csproj" />
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Application.Contracts\Yi.Framework.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using Yi.Framework.Application.Contracts;
|
||||
using Yi.Framework.Application.Contracts.Student;
|
||||
using Yi.Framework.Application.Student;
|
||||
using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Domain;
|
||||
|
||||
@@ -16,7 +17,8 @@ namespace Yi.Framework.Application
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiFrameworkApplicationContractsModule),
|
||||
typeof(YiFrameworkDomainModule)
|
||||
typeof(YiFrameworkDomainModule),
|
||||
typeof(YiFrameworkAuthJwtBearerModule)
|
||||
)]
|
||||
public class YiFrameworkApplicationModule : IStartupModule
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user