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

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

@@ -80,6 +80,37 @@ namespace CoreCms.Net.Utility.Helper
#endregion
#region
/// <summary>
/// 递归获取下级所有序列
/// </summary>
/// <returns></returns>
[Description("递归获取下级所有序列")]
public static List<int> GetChildIds(List<CoreCmsGoodsCategory> categories, int parentId)
{
var ids = new List<int> { parentId };
ids = GetChildrenIds(categories, parentId, ids);
return ids;
}
/// <summary>
/// 迭代方法
/// </summary>
/// <param name="oldNavs"></param>
/// <param name="parentId"></param>
/// <param name="ids"></param>
/// <returns></returns>
private static List<int> GetChildrenIds(List<CoreCmsGoodsCategory> oldNavs, int parentId, List<int> ids)
{
var model = oldNavs.Where(p => p.parentId == parentId).ToList();
foreach (var item in model)
{
ids.Add(item.id);
GetChildrenIds(oldNavs, item.id, ids);
}
return ids;
}
#endregion
#region
/// <summary>
@@ -120,16 +151,9 @@ namespace CoreCms.Net.Utility.Helper
return url;
}
}
#endregion
#region
#endregion
#region -/
/// <summary>
/// 判断内容,只允许中文,字母,数字,和-/
/// </summary>
@@ -139,17 +163,7 @@ namespace CoreCms.Net.Utility.Helper
public static bool FilterChar(string inputValue)
{
return Regex.IsMatch(inputValue, "[`.~!@#$^&*()=|\"{}':;',\\[\\]<>?~@#¥……&*&;|{}。*-+]+");
//return Regex.IsMatch(inputValue, "[`.~!@#$^&*()=|\"{}':;',\\[\\]<>?~@#¥……&*&;|{}。*-+]+");
//if (Regex.IsMatch(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+"))
//{
// return Regex.Match(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+").Value;
//}
//return "";
//return Regex.IsMatch(inputValue, "[~!@#$%^&*()_+|<>,.?:;'\\[\\]{}\"]+");
//return Regex.IsMatch(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-/]+");
}
#endregion