【修复】修复后台商品按分类查询,未迭代计算下级分类的问题,同时接口端增加多级判断。

This commit is contained in:
JianWeie
2022-09-16 12:24:16 +08:00
parent ea5d6b14c3
commit 1fc786d39c
3 changed files with 46 additions and 28 deletions

View File

@@ -25,6 +25,7 @@ using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.DTO;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -195,16 +196,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
className = category.name;
}
var childs = await _goodsCategoryServices.QueryListByClauseAsync(p => p.parentId == catId, p => p.sort, OrderByType.Asc, true, true);
if (childs.Any())
{
var ids = childs.Select(p => p.id).ToList();
where = where.And(p => ids.Contains(p.goodsCategoryId) || p.goodsCategoryId == catId);
}
else
{
where = where.And(p => p.goodsCategoryId == catId);
}
var categories = await _goodsCategoryServices.QueryAsync(true, true);
var ids = GoodsHelper.GetChildIds(categories, catId);
where = where.And(p => ids.Contains(p.goodsCategoryId));
}
}
if (!string.IsNullOrWhiteSpace(obj.brandId))