fix 人事范围调用处理
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
|
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
|
||||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||||
|
<ProjectReference Include="..\Dlhis.User.Api\Dlhis.User.Api.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Dlhis.Basic.Organization.Services;
|
using Dlhis.Basic.Organization.Services;
|
||||||
|
using Dlhis.User.Api.Response;
|
||||||
using Kurisu.AspNetCore.MVC;
|
using Kurisu.AspNetCore.MVC;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -27,7 +28,7 @@ public class WerksController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<List<WerkResponse>> GetListAsync()
|
public async Task<List<TenantResponse>> GetListAsync()
|
||||||
{
|
{
|
||||||
return await _werkService.GetListAsync();
|
return await _werkService.GetListAsync();
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ public class WerksController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("current")]
|
[HttpGet("current")]
|
||||||
public async Task<WerkResponse> GetCurrentAsync()
|
public async Task<TenantResponse> GetCurrentAsync()
|
||||||
{
|
{
|
||||||
return await _werkService.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;
|
namespace Dlhis.Basic.Organization.Services;
|
||||||
|
|
||||||
public interface IWerkService : IScopeDependency
|
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.User.Api;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.User.Api.Response;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using Kurisu.Core.Result;
|
||||||
using Kurisu.Core.User.Abstractions;
|
using Kurisu.Core.User.Abstractions;
|
||||||
using Kurisu.SqlSugar.Services;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||||
|
|
||||||
public class WerkService : IWerkService
|
public class WerkService : IWerkService
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
|
||||||
private readonly ICurrentUser _currentUser;
|
private readonly ICurrentUser _currentUser;
|
||||||
|
private readonly ITenantApi _tenantApi;
|
||||||
|
|
||||||
public WerkService(IDbContext dbContext, ICurrentUser currentUser)
|
public WerkService(ICurrentUser currentUser, ITenantApi tenantApi)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
|
||||||
_currentUser = currentUser;
|
_currentUser = currentUser;
|
||||||
|
_tenantApi = tenantApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<WerkResponse>> GetListAsync()
|
public async Task<List<TenantResponse>> GetListAsync()
|
||||||
{
|
{
|
||||||
return await _dbContext.Queryable<WerkEntity>()
|
var tenantResult = await _tenantApi.GetTenantsAsync();
|
||||||
.Select<WerkResponse>()
|
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
|
||||||
.ToListAsync();
|
|
||||||
|
var tenants = tenantResult.Data;
|
||||||
|
return tenants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WerkResponse> GetCurrentAsync()
|
public async Task<TenantResponse> GetCurrentAsync()
|
||||||
{
|
{
|
||||||
var tenant = _currentUser.GetStringTenantId();
|
var tenant = _currentUser.GetStringTenantId();
|
||||||
return await _dbContext.Queryable<WerkEntity>()
|
var tenantResult = await _tenantApi.GetTenantsAsync();
|
||||||
.Where(x => x.Code == tenant)
|
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
|
||||||
.Select<WerkResponse>()
|
|
||||||
.FirstAsync();
|
var tenants = tenantResult.Data;
|
||||||
|
return tenants.FirstOrDefault(x => x.Code == tenant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
using var scope = app.ApplicationServices.CreateScope();
|
using var scope = app.ApplicationServices.CreateScope();
|
||||||
var db = scope.ServiceProvider.GetService<ISqlSugarClient>();
|
var db = scope.ServiceProvider.GetService<ISqlSugarClient>();
|
||||||
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false)).ToArray();
|
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
|
||||||
|
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
db.DbMaintenance.CreateDatabase();
|
db.DbMaintenance.CreateDatabase();
|
||||||
db.CodeFirst.InitTables(tables);
|
db.CodeFirst.InitTables(tables);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"InternalRequest": {
|
"InternalRequest": {
|
||||||
"CommonRequestUrl": "http://localhost:5001"
|
"CommonRequestUrl": "http://localhost:5001",
|
||||||
|
"UserRequestUrl": "http://localhost:5004"
|
||||||
},
|
},
|
||||||
"SwaggerOptions": {
|
"SwaggerOptions": {
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"InternalRequest": {
|
"InternalRequest": {
|
||||||
"CommonRequestUrl": "http://common"
|
"CommonRequestUrl": "http://common",
|
||||||
|
"UserRequestUrl": "http://user"
|
||||||
},
|
},
|
||||||
"SqlSugarOptions": {
|
"SqlSugarOptions": {
|
||||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||||
|
|||||||
@@ -6,14 +6,6 @@
|
|||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"applicationUrl": "http://localhost:5010"
|
"applicationUrl": "http://localhost:5010"
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_URLS": "http://+:80"
|
|
||||||
},
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"InternalRequest": {
|
"InternalRequest": {
|
||||||
"CommonRequestUrl": "http://common",
|
"CommonRequestUrl": "http://localhost:5001",
|
||||||
"UserRequestUrl": "http://localhost:5010"
|
"UserRequestUrl": "http://localhost:5004"
|
||||||
},
|
},
|
||||||
"SwaggerOptions": {
|
"SwaggerOptions": {
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
|
|||||||
14
Src/Dlhis.User.Api/ITenantApi.cs
Normal file
14
Src/Dlhis.User.Api/ITenantApi.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Dlhis.User.Api.Response;
|
||||||
|
using Kurisu.Core.Result;
|
||||||
|
using Kurisu.RemoteCall.Attributes;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Api;
|
||||||
|
|
||||||
|
|
||||||
|
[EnableRemoteClient(Name = "user-service", BaseUrl = "${InternalRequest:UserRequestUrl}")]
|
||||||
|
public interface ITenantApi
|
||||||
|
{
|
||||||
|
[Auth]
|
||||||
|
[Get("/api/tenants/list")]
|
||||||
|
Task<DefaultApiResult<List<TenantResponse>>> GetTenantsAsync();
|
||||||
|
}
|
||||||
10
Src/Dlhis.User.Api/Response/TenantResponse.cs
Normal file
10
Src/Dlhis.User.Api/Response/TenantResponse.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Dlhis.User.Api.Response;
|
||||||
|
|
||||||
|
public class TenantResponse
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<DockerfileContext>..\..</DockerfileContext>
|
<DockerfileContext>..\..</DockerfileContext>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
42
Src/Dlhis.User/Identity/Controllers/TenantsController.cs
Normal file
42
Src/Dlhis.User/Identity/Controllers/TenantsController.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Dlhis.User.Identity.Request;
|
||||||
|
using Dlhis.User.Identity.Response;
|
||||||
|
using Dlhis.User.Identity.Services;
|
||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Identity.Controllers;
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TenantsController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ITenantService _tenantService;
|
||||||
|
|
||||||
|
public TenantsController(ITenantService tenantService)
|
||||||
|
{
|
||||||
|
_tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取租户分页
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("page")]
|
||||||
|
public async Task<Pagination<TenantResponse>> GetPageAsync([FromQuery] TenantPageRequest request)
|
||||||
|
{
|
||||||
|
return await _tenantService.GetPageAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有租户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("list")]
|
||||||
|
public async Task<List<TenantResponse>> GetListAsync()
|
||||||
|
{
|
||||||
|
return await _tenantService.GetListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Src/Dlhis.User/Identity/Request/TenantPageRequest.cs
Normal file
8
Src/Dlhis.User/Identity/Request/TenantPageRequest.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Identity.Request
|
||||||
|
{
|
||||||
|
public class TenantPageRequest : PageDto
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Src/Dlhis.User/Identity/Response/TenantResponse.cs
Normal file
10
Src/Dlhis.User/Identity/Response/TenantResponse.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Dlhis.User.Identity.Response;
|
||||||
|
|
||||||
|
public class TenantResponse
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
12
Src/Dlhis.User/Identity/Services/ITenantService.cs
Normal file
12
Src/Dlhis.User/Identity/Services/ITenantService.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Dlhis.User.Identity.Request;
|
||||||
|
using Dlhis.User.Identity.Response;
|
||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Identity.Services;
|
||||||
|
|
||||||
|
public interface ITenantService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task<Pagination<TenantResponse>> GetPageAsync(TenantPageRequest request);
|
||||||
|
|
||||||
|
Task<List<TenantResponse>> GetListAsync();
|
||||||
|
}
|
||||||
27
Src/Dlhis.User/Identity/Services/Implements/RoleService.cs
Normal file
27
Src/Dlhis.User/Identity/Services/Implements/RoleService.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Dlhis.Entity.Sys.Entities;
|
||||||
|
using Dlhis.User.Identity.Request;
|
||||||
|
using Dlhis.User.Identity.Response;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
using Kurisu.SqlSugar.Extensions;
|
||||||
|
using Kurisu.SqlSugar.Services;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Identity.Services.Implements;
|
||||||
|
|
||||||
|
public class RoleService : IRoleService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public RoleService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Pagination<RoleRespone>> GetPageAsync(RolePageRequest request)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<RoleEntity>()
|
||||||
|
.WhereIF(request.Search.IsPresent(), x => x.Name.Contains(request.Search) || x.NormalizedName.Contains(request.Search))
|
||||||
|
.Select<RoleRespone>()
|
||||||
|
.ToPageListAsync(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Src/Dlhis.User/Identity/Services/Implements/TenantService.cs
Normal file
34
Src/Dlhis.User/Identity/Services/Implements/TenantService.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Dlhis.Entity.Sys.Entities;
|
||||||
|
using Dlhis.User.Identity.Request;
|
||||||
|
using Dlhis.User.Identity.Response;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
using Kurisu.SqlSugar.Extensions;
|
||||||
|
using Kurisu.SqlSugar.Services;
|
||||||
|
|
||||||
|
namespace Dlhis.User.Identity.Services.Implements;
|
||||||
|
|
||||||
|
public class TenantService : ITenantService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public TenantService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Pagination<TenantResponse>> GetPageAsync(TenantPageRequest request)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<TenantEntity>()
|
||||||
|
.WhereIF(request.Search.IsPresent(), (tenant) => tenant.Name.Contains(request.Search))
|
||||||
|
.Select<TenantResponse>()
|
||||||
|
.ToPageListAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<TenantResponse>> GetListAsync()
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<TenantEntity>()
|
||||||
|
.Select<TenantResponse>()
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"applicationUrl": "http://localhost:5010"
|
"applicationUrl": "http://localhost:5004"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
"Scopes": {
|
"Scopes": {
|
||||||
"openid": "openid",
|
"openid": "openid",
|
||||||
"profile": "profile",
|
"profile": "profile",
|
||||||
"role": "role",
|
|
||||||
"yikatong": "yikatong"
|
"yikatong": "yikatong"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
"Scopes": {
|
"Scopes": {
|
||||||
"openid": "openid",
|
"openid": "openid",
|
||||||
"profile": "profile",
|
"profile": "profile",
|
||||||
"role": "role",
|
|
||||||
"yikatong": "yikatong"
|
"yikatong": "yikatong"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user