43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
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();
|
|
}
|
|
|
|
public async Task<TenantResponse> GetTenantByCode(string code)
|
|
{
|
|
return await _dbContext.Queryable<TenantEntity>()
|
|
.Where(x => x.Code == code)
|
|
.Select<TenantResponse>()
|
|
.FirstAsync();
|
|
}
|
|
}
|