fix 人事范围调用处理
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user