mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:03:25 +08:00
完成充值功能整体开发。
This commit is contained in:
180
CoreCms.Net.Repository/Shop/CoreCmsTopUpTypeRepository.cs
Normal file
180
CoreCms.Net.Repository/Shop/CoreCmsTopUpTypeRepository.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2023/3/20 21:20:30
|
||||
* 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 CoreCmsTopUpTypeRepository : BaseRepository<CoreCmsTopUpType>, ICoreCmsTopUpTypeRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsTopUpTypeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(CoreCmsTopUpType entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).RemoveDataCache().ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(CoreCmsTopUpType entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsTopUpType>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.title = entity.title;
|
||||
oldModel.description = entity.description;
|
||||
oldModel.defaultMoney = entity.defaultMoney;
|
||||
oldModel.giftMoney = entity.giftMoney;
|
||||
oldModel.giftPoint = entity.giftPoint;
|
||||
oldModel.sortId = entity.sortId;
|
||||
oldModel.isEnable = entity.isEnable;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).RemoveDataCache().ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsTopUpType>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsTopUpType>> GetCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsTopUpType>().With(SqlWith.NoLock).WithCache().ToListAsync();
|
||||
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 async Task<IPageList<CoreCmsTopUpType>> QueryPageAsync(Expression<Func<CoreCmsTopUpType, bool>> predicate,
|
||||
Expression<Func<CoreCmsTopUpType, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsTopUpType> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsTopUpType>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsTopUpType
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
description = p.description,
|
||||
defaultMoney = p.defaultMoney,
|
||||
giftMoney = p.giftMoney,
|
||||
giftPoint = p.giftPoint,
|
||||
sortId = p.sortId,
|
||||
isEnable = p.isEnable,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsTopUpType>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsTopUpType
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
description = p.description,
|
||||
defaultMoney = p.defaultMoney,
|
||||
giftMoney = p.giftMoney,
|
||||
giftPoint = p.giftPoint,
|
||||
sortId = p.sortId,
|
||||
isEnable = p.isEnable,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsTopUpType>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user