【新增】增加商品列表dto类及查询方法,首页【商品组件】【商品tab组】【仿点餐界面】【栏目列表页】【推荐商品列表】进行替换。

【优化】优化普通商品及营销商品内页不同dom之间间距。微调其他页面样式
【调整】移除.net5升级到.net6保留的startup.cs文件,使用program.cs
This commit is contained in:
大灰灰
2022-11-06 05:38:42 +08:00
parent 84fbcfffbd
commit 45877f0d5c
23 changed files with 1316 additions and 819 deletions

View File

@@ -15,6 +15,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.DTO.ComponentsDTO;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
@@ -910,7 +911,7 @@ namespace CoreCms.Net.Services
/// <param name="number"></param>
/// <param name="isRecommend"></param>
/// <returns></returns>
public async Task<List<CoreCmsGoods>> GetGoodsRecommendList(int number, bool isRecommend = false)
public async Task<List<GoodListDTO>> GetGoodsRecommendList(int number, bool isRecommend = false)
{
return await _dal.GetGoodsRecommendList(number, isRecommend);
}
@@ -998,6 +999,24 @@ namespace CoreCms.Net.Services
}
#endregion
#region DTO
/// <summary>
/// 重写根据条件及自定义排序查询分页数据返回DTO
/// </summary>
/// <param name="predicate"></param>
/// <param name="orderBy"></param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<IPageList<GoodListDTO>> QueryPageByDTOAsync(Expression<Func<GoodListDTO, bool>> predicate,
string orderBy = "", int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false)
{
return await _dal.QueryPageByDTOAsync(predicate, orderBy, pageIndex, pageSize, blUseNoLock);
}
#endregion
/// <summary>
/// 根据条件查询代理池商品分页数据
/// </summary>
@@ -1058,5 +1077,46 @@ namespace CoreCms.Net.Services
return await _dal.QueryGoodWithDefaultProductAsync(predicate, orderByPredicate, orderByType, blUseNoLock);
}
/// <summary>
/// 根据条件查询一定数量数据(用于组件)
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="orderByPredicate">排序字段</param>
/// <param name="orderByType">排序顺序</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <param name="isDataCache">是否缓存</param>
/// <param name="cacheTimes">缓存时间(分钟)</param>
/// <returns></returns>
public async Task<List<GoodListDTO>> QueryListByComponentsAsync(Expression<Func<GoodListDTO, bool>> predicate,
int take,
Expression<Func<GoodListDTO, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false,
bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await _dal.QueryListByComponentsAsync(predicate, take, orderByPredicate, orderByType, blUseNoLock,
isDataCache, cacheTimes);
}
/// <summary>
/// 根据条件查询一定数量数据(用于组件)
/// </summary>
/// <param name="predicate">条件表达式树</param>
/// <param name="take">获取数量</param>
/// <param name="orderByPredicate">排序字段</param>
/// <param name="orderByType">排序顺序</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <param name="isDataCache">是否缓存</param>
/// <param name="cacheTimes">缓存时间(分钟)</param>
/// <returns></returns>
public async Task<List<GoodListDTO>> QueryListByComponentsAsync(Expression<Func<GoodListDTO, bool>> predicate,
int take, string orderByType = "", bool blUseNoLock = false,
bool isDataCache = false, int cacheTimes = int.MaxValue)
{
return await _dal.QueryListByComponentsAsync(predicate, take, orderByType, blUseNoLock,
isDataCache, cacheTimes);
}
}
}

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.DTO.ComponentsDTO;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
@@ -26,7 +27,9 @@ using CoreCms.Net.Utility.Extensions;
using Essensoft.Paylink.Alipay.Domain;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using static NPOI.HSSF.Util.HSSFColor;
namespace CoreCms.Net.Services
@@ -267,10 +270,7 @@ namespace CoreCms.Net.Services
foreach (var jToken in list)
{
var child = (JObject)jToken;
var where = PredicateBuilder.True<CoreCmsGoods>();
where = where.And(p => p.isDel == false);
where = where.And(p => p.isMarketable == true);
var where = PredicateBuilder.True<GoodListDTO>();
if (child != null && child.ContainsKey("type") && child["type"].ToString() == "auto")
{
//商品分类,同时取所有子分类
@@ -301,7 +301,8 @@ namespace CoreCms.Net.Services
}
limit = limit > 0 ? limit : 10;
var goods = await _goodsServices.QueryListByClauseAsync(where, limit, p => p.createTime, OrderByType.Desc, true);
var goods = await _goodsServices.QueryListByComponentsAsync(where, limit, p => p.createTime, OrderByType.Desc, true, true, 60);
if (goods != null && goods.Any())
{
var result = JArray.FromObject(goods);
@@ -318,6 +319,7 @@ namespace CoreCms.Net.Services
{
var orderBy = string.Empty;
string goodidsStr;
var count = 0;
if (child != null && child.ContainsKey("list"))
{
var result = JArray.Parse(child["list"].ToString());
@@ -335,9 +337,11 @@ namespace CoreCms.Net.Services
{
orderBy = " find_in_set(id,'" + goodidsStr + "') ";
}
count = goodids.Count;
}
}
var goods = await _goodsServices.QueryListByClauseAsync(where, orderBy, true);
var goods = await _goodsServices.QueryListByComponentsAsync(where, count, orderBy, true, true, 60);
if (goods != null && goods.Any())
{
var result = JArray.FromObject(goods);
@@ -364,9 +368,7 @@ namespace CoreCms.Net.Services
case "goods":
{
var parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
var where = PredicateBuilder.True<CoreCmsGoods>();
where = where.And(p => p.isDel == false);
where = where.And(p => p.isMarketable == true);
var where = PredicateBuilder.True<GoodListDTO>();
if (parameters != null && parameters.ContainsKey("type") && parameters["type"].ToString() == "auto")
{
//商品分类,同时取所有子分类
@@ -397,7 +399,7 @@ namespace CoreCms.Net.Services
}
limit = limit > 0 ? limit : 10;
var goods = await _goodsServices.QueryPageAsync(where, " sort desc,id desc ", 1, limit, true);
var goods = await _goodsServices.QueryListByComponentsAsync(where, limit, " sort desc,id desc ", true, true, 60);
if (goods != null && goods.Any())
{
var result = JArray.FromObject(goods);
@@ -414,9 +416,10 @@ namespace CoreCms.Net.Services
{
var orderBy = string.Empty;
string goodidsStr;
var count = 0;
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
var result = JArray.Parse(parameters["list"].ToString());
var goodids = new List<int>();
foreach (var ss in result) //查找某个字段与值
{
@@ -440,11 +443,12 @@ namespace CoreCms.Net.Services
orderBy = " find_in_set(id,'" + goodidsStr + "') ";
}
}
count = goodids.Count;
}
var goods = await _goodsServices.QueryListByClauseAsync(where, orderBy, true);
var goods = await _goodsServices.QueryListByComponentsAsync(where, count, orderBy, true, true, 60);
if (goods != null && goods.Any())
{
JArray result = JArray.FromObject(goods);
var result = JArray.FromObject(goods);
parameters.Remove("list");
parameters.Add("list", result);
}