更新 变量管理-上传设备筛选功能

This commit is contained in:
Kimdiego2098
2023-08-31 08:58:30 +08:00
parent a6b874d160
commit f7756bccef
3 changed files with 9 additions and 5 deletions

View File

@@ -12,6 +12,8 @@
using SqlSugar;
using System.Linq.Expressions;
namespace ThingsGateway.Admin.Core;
/// <summary>
@@ -55,12 +57,14 @@ public static class SqlSugarPageExtension
/// <param name="whereExpression"></param>
/// <returns></returns>
public static async Task<SqlSugarPagedList<TEntity>> ToPagedListAsync<TEntity>(this ISugarQueryable<TEntity> queryable,
int pageIndex, int pageSize, Func<TEntity, bool> whereExpression = null)
int pageIndex, int pageSize, Expression<Func<TEntity, bool>> whereExpression = null)
{
RefAsync<int> totalCount = 0;
if (whereExpression != null)
queryable = queryable.Where(whereExpression);
var records = await queryable.ToPageListAsync(pageIndex, pageSize, totalCount);
records = whereExpression != null ? records.Where(whereExpression).ToList() : records;
//records = whereExpression != null ? records.Where(whereExpression).ToList() : records;
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
return new SqlSugarPagedList<TEntity>
{

View File

@@ -1495,7 +1495,7 @@
<param name="size"></param>
<returns></returns>
</member>
<member name="M:ThingsGateway.Admin.Core.SqlSugarPageExtension.ToPagedListAsync``1(SqlSugar.ISugarQueryable{``0},System.Int32,System.Int32,System.Func{``0,System.Boolean})">
<member name="M:ThingsGateway.Admin.Core.SqlSugarPageExtension.ToPagedListAsync``1(SqlSugar.ISugarQueryable{``0},System.Int32,System.Int32,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
<summary>
SqlSugar分页扩展
</summary>

View File

@@ -129,11 +129,11 @@ public class VariableService : DbRepository<DeviceVariable>, IVariableService
{
uploadDevid = _uploadDeviceService.GetIdByName(input.UploadDeviceName);
}
if (!string.IsNullOrEmpty(input.UploadDeviceName))
{
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size, a => a.VariablePropertys.ContainsKey(uploadDevid ?? 0));//分页
var pageInfo = await query.ToPagedListAsync(input.Current, input.Size, a => SqlFunc.JsonLike(a.VariablePropertys, uploadDevid.ToString()));//分页
return pageInfo;
}
else
{