完善商品栏目管理选择模板,商品栏目、商品伪静态地址生成

This commit is contained in:
2024-06-26 17:48:08 +08:00
parent 3328ba055b
commit 48b68889b0
14 changed files with 294 additions and 64 deletions
+39 -1
View File
@@ -75,7 +75,22 @@ namespace COMCMS.Core
/// <returns></returns>
public static string EchoURL(Product model)
{
return $"/product/detail/{model.Id}";
if (model == null)
return "javascript:;";
Category categoty = Category.FindById(model.KId);
if (categoty != null && !string.IsNullOrEmpty(categoty.FilePath))
{
string url = $"{categoty.FilePath}/{model.Id}.html";
if (!string.IsNullOrEmpty(model.FileName))
{
url = $"{categoty.FilePath}/{model.FileName}";
}
return url;
}
else
return $"/product/detail/{model.Id}";
}
/// <summary>
@@ -149,5 +164,28 @@ namespace COMCMS.Core
}
#endregion
#region 生成商品地址
/// <summary>
/// 生成商品分类地址
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static string EchoCategoryURL(int id)
{
Category model = Category.FindById(id);
return EchoURL(model);
}
/// <summary>
/// 生成商品详情地址
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static string EchoProductURL(int id)
{
Product model = Product.FindById(id);
return EchoURL(model);
}
#endregion
}
}