You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
5.2 KiB
164 lines
5.2 KiB
using Shentun.Peis.Models;
|
|
using Shentun.Peis.Units;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TencentCloud.Cme.V20191029.Models;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.Domain.Entities;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Users;
|
|
|
|
namespace Shentun.Peis
|
|
{
|
|
public class PageHelper
|
|
{
|
|
|
|
|
|
//public static async Task UpdateSort<TEntity>(IRepository<TEntity, Guid> repository, Guid id, Guid targetid)
|
|
// where TEntity : class, IEntity<Guid>, IDisplayOrder
|
|
|
|
/// <summary>
|
|
/// 分页加搜索
|
|
/// </summary>
|
|
/// <typeparam name="TEntity"></typeparam>
|
|
/// <typeparam name="TKey"></typeparam>
|
|
/// <param name="repository"></param>
|
|
/// <param name="userrepository"></param>
|
|
/// <param name="input"></param>
|
|
/// <param name="orderby">排序方式 0、升序 1、降序 </param>
|
|
/// <returns></returns>
|
|
public static async Task<List<TEntity>> GetPageListInFitler<TEntity, TKey>
|
|
(IRepository<TEntity, TKey> repository,
|
|
IRepository<IdentityUser, Guid> userrepository,
|
|
GetListInFilterDto input, int orderby = 0)
|
|
where TEntity : class, IEntity<TKey>, IDisplayName, IDisplayOrder
|
|
{
|
|
List<TEntity> entlist = new List<TEntity>();
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter))
|
|
entlist = (await repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).ToList();
|
|
else
|
|
entlist = await repository.GetListAsync();
|
|
|
|
if (orderby == 1)
|
|
{
|
|
//分页
|
|
entlist = entlist.OrderByDescending(m => m.DisplayOrder).Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
|
|
}
|
|
else
|
|
{
|
|
entlist = entlist.OrderBy(m => m.DisplayOrder).Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
|
|
}
|
|
|
|
return entlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 分页加搜索 不带GUID主键
|
|
/// </summary>
|
|
/// <typeparam name="TEntity"></typeparam>
|
|
/// <param name="repository"></param>
|
|
/// <param name="userrepository"></param>
|
|
/// <param name="input"></param>
|
|
/// <param name="orderby">排序方式 0、升序 1、降序 </param>
|
|
/// <returns></returns>
|
|
public static async Task<List<TEntity>> GetPageListInFitlerNoGuid<TEntity>
|
|
(IRepository<TEntity> repository,
|
|
IRepository<IdentityUser, Guid> userrepository,
|
|
GetListInFilterDto input, int orderby = 0)
|
|
where TEntity : class, IEntity, IDisplayName, IDisplayOrder
|
|
{
|
|
List<TEntity> entlist = new List<TEntity>();
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter))
|
|
entlist = (await repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).ToList();
|
|
else
|
|
entlist = await repository.GetListAsync();
|
|
|
|
|
|
if (orderby == 1)
|
|
{
|
|
//分页
|
|
entlist = entlist.OrderByDescending(m => m.DisplayOrder).Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
|
|
}
|
|
else
|
|
{
|
|
entlist = entlist.OrderBy(m => m.DisplayOrder).Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
|
|
}
|
|
|
|
return entlist;
|
|
|
|
}
|
|
|
|
public static async Task<List<TEntity>> GetPageListInFitlerNotOrder<TEntity, TKey>
|
|
(IRepository<TEntity, TKey> repository,
|
|
IRepository<IdentityUser, Guid> userrepository,
|
|
GetListInFilterDto input)
|
|
where TEntity : class, IEntity<TKey>, IDisplayName
|
|
{
|
|
List<TEntity> entlist = new List<TEntity>();
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter))
|
|
entlist = (await repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).ToList();
|
|
else
|
|
entlist = await repository.GetListAsync();
|
|
|
|
//分页
|
|
entlist = entlist.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
|
|
|
|
|
|
return entlist;
|
|
|
|
}
|
|
|
|
public static DateOnly? ConvertDate(string? dateTime)
|
|
{
|
|
if (string.IsNullOrEmpty(dateTime))
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
return DateOnly.Parse(dateTime);
|
|
}
|
|
}
|
|
|
|
|
|
public static DateTime? ConvertDatetimeV(string dateTime)
|
|
{
|
|
if (string.IsNullOrEmpty(dateTime))
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
return DateTime.Parse(dateTime);
|
|
}
|
|
}
|
|
|
|
public static byte[] Base64DecodeString(string inputStr)
|
|
{
|
|
byte[] decodedByteArray = Convert.FromBase64String(inputStr);
|
|
return (decodedByteArray);
|
|
}
|
|
|
|
public static string Base64EncodeBytes(byte[] inBytes)
|
|
{
|
|
return (Convert.ToBase64String(inBytes));
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|