fix 人事范围调用处理
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
using Dlhis.User.Api.Response;
|
||||
using Kurisu.AspNetCore.MVC;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -27,7 +28,7 @@ public class WerksController : ControllerBase
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<List<WerkResponse>> GetListAsync()
|
||||
public async Task<List<TenantResponse>> GetListAsync()
|
||||
{
|
||||
return await _werkService.GetListAsync();
|
||||
}
|
||||
@@ -37,7 +38,7 @@ public class WerksController : ControllerBase
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("current")]
|
||||
public async Task<WerkResponse> GetCurrentAsync()
|
||||
public async Task<TenantResponse> GetCurrentAsync()
|
||||
{
|
||||
return await _werkService.GetCurrentAsync();
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Response;
|
||||
|
||||
public class WerkResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代号
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可见
|
||||
/// </summary>
|
||||
public bool Visible { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.User.Api.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IWerkService : IScopeDependency
|
||||
{
|
||||
Task<List<WerkResponse>> GetListAsync();
|
||||
Task<List<TenantResponse>> GetListAsync();
|
||||
|
||||
Task<WerkResponse> GetCurrentAsync();
|
||||
Task<TenantResponse> GetCurrentAsync();
|
||||
}
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.User.Api;
|
||||
using Dlhis.User.Api.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.Result;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class WerkService : IWerkService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
|
||||
public WerkService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
public WerkService(ICurrentUser currentUser, ITenantApi tenantApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
_tenantApi = tenantApi;
|
||||
}
|
||||
|
||||
public async Task<List<WerkResponse>> GetListAsync()
|
||||
public async Task<List<TenantResponse>> GetListAsync()
|
||||
{
|
||||
return await _dbContext.Queryable<WerkEntity>()
|
||||
.Select<WerkResponse>()
|
||||
.ToListAsync();
|
||||
var tenantResult = await _tenantApi.GetTenantsAsync();
|
||||
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
|
||||
|
||||
var tenants = tenantResult.Data;
|
||||
return tenants;
|
||||
}
|
||||
|
||||
public async Task<WerkResponse> GetCurrentAsync()
|
||||
public async Task<TenantResponse> GetCurrentAsync()
|
||||
{
|
||||
var tenant = _currentUser.GetStringTenantId();
|
||||
return await _dbContext.Queryable<WerkEntity>()
|
||||
.Where(x => x.Code == tenant)
|
||||
.Select<WerkResponse>()
|
||||
.FirstAsync();
|
||||
var tenantResult = await _tenantApi.GetTenantsAsync();
|
||||
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
|
||||
|
||||
var tenants = tenantResult.Data;
|
||||
return tenants.FirstOrDefault(x => x.Code == tenant);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user