From 7a3a4f8012a72f80d8dd62064a76655c803da864 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期三, 29 五月 2024 12:42:45 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/baifenbaishop
---
CoreCms.Net.Repository/baifenbingfa/PuhuoRepository.cs | 324 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 324 insertions(+), 0 deletions(-)
diff --git a/CoreCms.Net.Repository/baifenbingfa/PuhuoRepository.cs b/CoreCms.Net.Repository/baifenbingfa/PuhuoRepository.cs
new file mode 100644
index 0000000..bc78e62
--- /dev/null
+++ b/CoreCms.Net.Repository/baifenbingfa/PuhuoRepository.cs
@@ -0,0 +1,324 @@
+/***********************************************************************
+ * Project: baifenBinfa
+ * ProjectName: 鐧惧垎鍏垫硶绠$悊绯荤粺
+ * Web: http://chuanyin.com
+ * Author:
+ * Email:
+ * CreateTime: 2024/5/24 11:11:45
+ * 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;
+using CoreCms.Net.Model.Entities.baifenbingfa.puhuo;
+
+namespace CoreCms.Net.Repository
+{
+ /// <summary>
+ /// 閾鸿揣 鎺ュ彛瀹炵幇
+ /// </summary>
+ public class PuhuoRepository : BaseRepository<Puhuo>, IPuhuoRepository
+ {
+ private readonly IUnitOfWork _unitOfWork;
+ public PuhuoRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ #region 瀹炵幇閲嶅啓澧炲垹鏀规煡鎿嶄綔==========================================================
+
+ /// <summary>
+ /// 閲嶅啓寮傛鎻掑叆鏂规硶
+ /// </summary>
+ /// <param name="entity">瀹炰綋鏁版嵁</param>
+ /// <returns></returns>
+ public async Task<AdminUiCallBack> InsertAsync(Puhuo 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;
+
+ return jm;
+ }
+
+ /// <summary>
+ /// 閲嶅啓寮傛鏇存柊鏂规硶
+ /// </summary>
+ /// <param name="entity"></param>
+ /// <returns></returns>
+ public async Task<AdminUiCallBack> UpdateAsync(Puhuo entity)
+ {
+ var jm = new AdminUiCallBack();
+
+ var oldModel = await DbClient.Queryable<Puhuo>().In(entity.id).SingleAsync();
+ if (oldModel == null)
+ {
+ jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
+ return jm;
+ }
+ //浜嬬墿澶勭悊杩囩▼寮�濮�
+ oldModel.id = entity.id;
+ oldModel.distributionId = entity.distributionId;
+ oldModel.distributionName = entity.distributionName;
+ oldModel.areaCode = entity.areaCode;
+ oldModel.areaCodeName = entity.areaCodeName;
+ oldModel.CategoryId = entity.CategoryId;
+ oldModel.CategoryName = entity.CategoryName;
+ oldModel.goodsId = entity.goodsId;
+ oldModel.goodsName = entity.goodsName;
+ oldModel.productsId = entity.productsId;
+ oldModel.productsName = entity.productsName;
+ oldModel.spesDesc = entity.spesDesc;
+ oldModel.price = entity.price;
+ oldModel.nums = entity.nums;
+ oldModel.amount = entity.amount;
+ oldModel.createTime = entity.createTime;
+ oldModel.upDataTime = entity.upDataTime;
+ oldModel.createBy = entity.createBy;
+ oldModel.upDataBy = entity.upDataBy;
+ oldModel.isdelete = entity.isdelete;
+
+ //浜嬬墿澶勭悊杩囩▼缁撴潫
+ var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
+ jm.code = bl ? 0 : 1;
+ jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
+
+ return jm;
+ }
+
+ /// <summary>
+ /// 閲嶅啓寮傛鏇存柊鏂规硶
+ /// </summary>
+ /// <param name="entity"></param>
+ /// <returns></returns>
+ public async Task<AdminUiCallBack> UpdateAsync(List<Puhuo> entity)
+ {
+ var jm = new AdminUiCallBack();
+
+ var bl = await DbClient.Updateable(entity).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<Puhuo>(id).ExecuteCommandHasChangeAsync();
+ jm.code = bl ? 0 : 1;
+ jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
+
+ return jm;
+ }
+
+ /// <summary>
+ /// 閲嶅啓鍒犻櫎鎸囧畾ID闆嗗悎鐨勬暟鎹�(鎵归噺鍒犻櫎)
+ /// </summary>
+ /// <param name="ids"></param>
+ /// <returns></returns>
+ public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
+ {
+ var jm = new AdminUiCallBack();
+
+ var bl = await DbClient.Deleteable<Puhuo>().In(ids).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<Puhuo>> GetCaChe()
+ {
+ var list = await DbClient.Queryable<Puhuo>().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<Puhuo>> QueryPageAsync(Expression<Func<Puhuo, bool>> predicate,
+ Expression<Func<Puhuo, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
+ int pageSize = 20, bool blUseNoLock = false)
+ {
+ RefAsync<int> totalCount = 0;
+ List<Puhuo> page;
+ if (blUseNoLock)
+ {
+ page = await DbClient.Queryable<Puhuo>()
+ .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
+ .WhereIF(predicate != null, predicate).Select(p => new Puhuo
+ {
+ id = p.id,
+ distributionId = p.distributionId,
+ distributionName = p.distributionName,
+ areaCode = p.areaCode,
+ areaCodeName = p.areaCodeName,
+ CategoryId = p.CategoryId,
+ CategoryName = p.CategoryName,
+ goodsId = p.goodsId,
+ goodsName = p.goodsName,
+ productsId = p.productsId,
+ productsName = p.productsName,
+ spesDesc = p.spesDesc,
+ price = p.price,
+ nums = p.nums,
+ amount = p.amount,
+ createTime = p.createTime,
+ upDataTime = p.upDataTime,
+ createBy = p.createBy,
+ upDataBy = p.upDataBy,
+ isdelete = p.isdelete,
+
+ }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
+ }
+ else
+ {
+ page = await DbClient.Queryable<Puhuo>()
+ .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
+ .WhereIF(predicate != null, predicate).Select(p => new Puhuo
+ {
+ id = p.id,
+ distributionId = p.distributionId,
+ distributionName = p.distributionName,
+ areaCode = p.areaCode,
+ areaCodeName = p.areaCodeName,
+ CategoryId = p.CategoryId,
+ CategoryName = p.CategoryName,
+ goodsId = p.goodsId,
+ goodsName = p.goodsName,
+ productsId = p.productsId,
+ productsName = p.productsName,
+ spesDesc = p.spesDesc,
+ price = p.price,
+ nums = p.nums,
+ amount = p.amount,
+ createTime = p.createTime,
+ upDataTime = p.upDataTime,
+ createBy = p.createBy,
+ upDataBy = p.upDataBy,
+ isdelete = p.isdelete,
+
+ }).ToPageListAsync(pageIndex, pageSize, totalCount);
+ }
+ var list = new PageList<Puhuo>(page, pageIndex, pageSize, totalCount);
+ 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<Puhuo>> QueryPageGroupAsync(Expression<Func<Puhuo, bool>> predicate,
+ Expression<Func<Puhuo, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
+ int pageSize = 20, bool blUseNoLock = false)
+ {
+ RefAsync<int> totalCount = 0;
+ List<Puhuo> page;
+ if (blUseNoLock)
+ {
+ page = await DbClient.Queryable<Puhuo>()
+ .GroupBy(it => new { it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price })
+ .WhereIF(predicate != null, predicate)
+ .Select(p => new Puhuo
+ {
+
+
+ CategoryId = p.CategoryId,
+ CategoryName = p.CategoryName,
+ goodsId = p.goodsId,
+ goodsName = p.goodsName,
+ productsId = p.productsId,
+ productsName = p.productsName,
+ price = p.price,
+ tiaozhengnums =SqlFunc.AggregateCount(p.id),
+ nums = SqlFunc.AggregateSum(p.nums),
+ amount = SqlFunc.AggregateSum(p.amount),
+
+
+ })
+ .MergeTable()//闇�瑕佸姞MergeTable鎵嶈兘鎺掑簭缁熻杩囩殑鍒�
+ .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
+ .With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
+ }
+ else
+ {
+ page = await DbClient.Queryable<Puhuo>()
+ .GroupBy(it => new { it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price })
+ .WhereIF(predicate != null, predicate)
+ .Select(p => new Puhuo
+ {
+
+ CategoryId = p.CategoryId,
+ CategoryName = p.CategoryName,
+ goodsId = p.goodsId,
+ goodsName = p.goodsName,
+ productsId = p.productsId,
+ productsName = p.productsName,
+ price = p.price,
+ tiaozhengnums = SqlFunc.AggregateCount(p.id),
+ nums = SqlFunc.AggregateSum(p.nums),
+ amount = SqlFunc.AggregateSum(p.amount),
+
+
+ })
+ .MergeTable()//闇�瑕佸姞MergeTable鎵嶈兘鎺掑簭缁熻杩囩殑鍒�
+ .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
+ .ToPageListAsync(pageIndex, pageSize, totalCount);
+ }
+ var list = new PageList<Puhuo>(page, pageIndex, pageSize, totalCount);
+ return list;
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.9.1