diff --git a/src/BasicAbility/Masa.Contrib.BasicAbility.Auth/Service/UserService.cs b/src/BasicAbility/Masa.Contrib.BasicAbility.Auth/Service/UserService.cs index ef9ce0cd4..bd60bebb8 100644 --- a/src/BasicAbility/Masa.Contrib.BasicAbility.Auth/Service/UserService.cs +++ b/src/BasicAbility/Masa.Contrib.BasicAbility.Auth/Service/UserService.cs @@ -93,6 +93,13 @@ public async Task GetCurrentUserAsync() return await _callerProvider.GetAsync(requestUri, new { id }) ?? new(); } + public async Task GetCurrentStaffAsync() + { + var userId = _userContext.GetUserId(); + var requestUri = $"api/staff/getExternalByUserId"; + return await _callerProvider.GetAsync(requestUri, new { userId }); + } + public async Task VisitedAsync(string url) { var userId = _userContext.GetUserId(); diff --git a/src/BuildingBlocks/MASA.BuildingBlocks b/src/BuildingBlocks/MASA.BuildingBlocks index 1c3f57d31..1200f8c06 160000 --- a/src/BuildingBlocks/MASA.BuildingBlocks +++ b/src/BuildingBlocks/MASA.BuildingBlocks @@ -1 +1 @@ -Subproject commit 1c3f57d3168a7cb0c4f4e1b87cf10811778ddd11 +Subproject commit 1200f8c060f977a4a1c4cd8c25f7e495e99f8708 diff --git a/test/Masa.Contrib.BasicAbility.Auth.Tests/UserServiceTest.cs b/test/Masa.Contrib.BasicAbility.Auth.Tests/UserServiceTest.cs index 23bb3a8e1..87629a2dc 100644 --- a/test/Masa.Contrib.BasicAbility.Auth.Tests/UserServiceTest.cs +++ b/test/Masa.Contrib.BasicAbility.Auth.Tests/UserServiceTest.cs @@ -214,6 +214,22 @@ public async Task TestGetCurrentUserAsync() Assert.IsTrue(result is not null); } + [TestMethod] + public async Task TestGetCurrentStaffAsync() + { + var userId = Guid.NewGuid(); + var data = new StaffDetailModel(); + var requestUri = $"api/staff/getExternalByUserId"; + var callerProvider = new Mock(); + callerProvider.Setup(provider => provider.GetAsync(requestUri, It.IsAny(), default)).ReturnsAsync(data).Verifiable(); + var userContext = new Mock(); + userContext.Setup(user => user.GetUserId()).Returns(userId).Verifiable(); + var userService = new UserService(callerProvider.Object, userContext.Object); + var result = await userService.GetCurrentStaffAsync(); + callerProvider.Verify(provider => provider.GetAsync(requestUri, It.IsAny(), default), Times.Once); + Assert.IsTrue(result is not null); + } + [TestMethod] [DataRow("https://www.baidu.com/")] public async Task TestVisitedAsync(string url)