mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 20:03:26 +08:00
# 2022-03-14
### 1.3.9 开源社区版: 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。 ### 0.2.8 专业版: 【新增】增加日历签到功能。实现通过日历签到获得积分,余额。【非破坏性无缝增加功能】 【新增】增加“连续签到周期”定时任务,用于根据后台的设置,实时重置清零用户连续签到计数。 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:52
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则明细 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsContinuousCheckInRuleDetailsRepository : BaseRepository<CoreCmsContinuousCheckInRuleDetails>, ICoreCmsContinuousCheckInRuleDetailsRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsContinuousCheckInRuleDetailsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:58
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsContinuousCheckInRulesRepository : BaseRepository<CoreCmsContinuousCheckInRules>, ICoreCmsContinuousCheckInRulesRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsContinuousCheckInRulesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(List<CoreCmsContinuousCheckInRules> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
//判断是否存在0天数或者0赠送
|
||||
var isHaveEnptyDaysOrNum = entity.Count(p => p.days <= 0);
|
||||
if (isHaveEnptyDaysOrNum > 0)
|
||||
{
|
||||
jm.msg = "【连续签到天数】不能为零";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//判断是否存在相同的天数设置。
|
||||
var isHave = entity.GroupBy(i => i.days).Any(g => g.Count() > 1);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "存在相同的【连续签到天数】。请排查";
|
||||
return jm;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
//先清理掉数据,因为是配置数据,可直接删除添加新的
|
||||
await DbClient.Deleteable<CoreCmsContinuousCheckInRules>().Where(p => p.id > 0).ExecuteCommandAsync();
|
||||
await DbClient.Deleteable<CoreCmsContinuousCheckInRuleDetails>().Where(p => p.id > 0).ExecuteCommandAsync();
|
||||
|
||||
//遍历数据存值
|
||||
foreach (var item in entity)
|
||||
{
|
||||
var continuous = new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
days = item.days
|
||||
};
|
||||
|
||||
var id = await DbClient.Insertable(continuous).ExecuteReturnIdentityAsync();
|
||||
if (id <= 0) continue;
|
||||
foreach (var detail in item.details)
|
||||
{
|
||||
detail.ruleId = id;
|
||||
}
|
||||
await DbClient.Insertable(item.details).ExecuteReturnIdentityAsync();
|
||||
}
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "更新成功";
|
||||
|
||||
await UpdateCaChe();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.code = 1;
|
||||
jm.msg = "更新失败";
|
||||
jm.data = e;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsContinuousCheckInRules>>(GlobalConstVars.CacheCoreCmsContinuousCheckInRules);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
})
|
||||
.Mapper(p => p.details, p => p.details.First().ruleId)
|
||||
.With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsContinuousCheckInRules, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<IPageList<CoreCmsContinuousCheckInRules>> QueryPageAsync(Expression<Func<CoreCmsContinuousCheckInRules, bool>> predicate,
|
||||
Expression<Func<CoreCmsContinuousCheckInRules, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsContinuousCheckInRules> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsContinuousCheckInRules>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:04:05
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计签到规则 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsCumulativeCheckInRulesRepository : BaseRepository<CoreCmsCumulativeCheckInRules>, ICoreCmsCumulativeCheckInRulesRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsCumulativeCheckInRulesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsCumulativeCheckInRules entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(List<CoreCmsCumulativeCheckInRules> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteCommandAsync();
|
||||
jm.code = 0;
|
||||
jm.msg = GlobalConstVars.EditSuccess;
|
||||
await UpdateCaChe();
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsCumulativeCheckInRules entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.days = entity.days;
|
||||
oldModel.num = entity.num;
|
||||
oldModel.type = entity.type;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsCumulativeCheckInRules> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsCumulativeCheckInRules>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsCumulativeCheckInRules>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsCumulativeCheckInRules>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsCumulativeCheckInRules>>(GlobalConstVars.CacheCoreCmsCumulativeCheckInRules);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsCumulativeCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsCumulativeCheckInRules, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<IPageList<CoreCmsCumulativeCheckInRules>> QueryPageAsync(Expression<Func<CoreCmsCumulativeCheckInRules, bool>> predicate,
|
||||
Expression<Func<CoreCmsCumulativeCheckInRules, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsCumulativeCheckInRules> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsCumulativeCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
num = p.num,
|
||||
type = p.type,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsCumulativeCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
num = p.num,
|
||||
type = p.type,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsCumulativeCheckInRules>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/8 23:33:07
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户签到明细表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserCheckInDetailsRepository : BaseRepository<CoreCmsUserCheckInDetails>, ICoreCmsUserCheckInDetailsRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsUserCheckInDetailsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/13 22:21:26
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户日历签到统计 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserCheckInRepository : BaseRepository<CoreCmsUserCheckIn>, ICoreCmsUserCheckInRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsUserCheckInRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<IPageList<CoreCmsUserCheckIn>> QueryPageAsync(Expression<Func<CoreCmsUserCheckIn, bool>> predicate,
|
||||
Expression<Func<CoreCmsUserCheckIn, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsUserCheckIn> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsUserCheckIn>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserCheckIn
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
continuousCheckInCount = p.continuousCheckInCount,
|
||||
cumulativeCheckInCount = p.cumulativeCheckInCount,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsUserCheckIn>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserCheckIn
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
continuousCheckInCount = p.continuousCheckInCount,
|
||||
cumulativeCheckInCount = p.cumulativeCheckInCount,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsUserCheckIn>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user