using System; using Sozsoft.Platform.Entities; using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using System.Threading.Tasks; using System.Linq; namespace Sozsoft.Platform.AiBots; [Authorize] public class AiBotAppService : CrudAppService< AiBot, AiBotDto, Guid, PagedAndSortedResultRequestDto> { public AiBotAppService(IRepository repo) : base(repo) { } public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) { await CheckGetListPolicyAsync(); var query = await CreateFilteredQueryAsync(input); if (CurrentTenant.IsAvailable && !string.IsNullOrWhiteSpace(CurrentTenant.Name)) { var tenantName = CurrentTenant.Name; query = query.Where(aiBot => string.IsNullOrWhiteSpace(aiBot.Tenants) || aiBot.Tenants.Contains($"\"{tenantName}\"")); } var totalCount = await AsyncExecuter.CountAsync(query); query = ApplySorting(query, input); query = ApplyPaging(query, input); var entities = await AsyncExecuter.ToListAsync(query); var dtos = await MapToGetListOutputDtosAsync(entities); return new PagedResultDto(totalCount, dtos); } }