General.Web/Controllers/Admin/SiteMapController.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using General.Core.Common.SEO;
using General.Core.Data;
using General.Entities.Models;
using General.Framework;
using General.Mvc.Filters;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace General.Mvc.Controllers.Admin
{
[Route("api/admin/[controller]/[action]")]
[ApiController]
[ServiceFilter(typeof(ResponseLogTimeFilter))]
public class SiteMapController : Controller
{
private readonly IMemoryCache memoryCache;
private readonly IRepository<tc_article> tc_ArticleRepository;
private readonly IRepository<tc_articlecate> tc_ArticleCateRepository;
private readonly IRepository<tc_diypage> tc_DiyPageRepository;
public SiteMapController(IMemoryCache memoryCache,
IRepository<tc_article> tc_articleRepository,
IRepository<tc_articlecate> tc_articleCateRepository,
IRepository<tc_diypage> tc_diyPageRepository)
{
this.memoryCache = memoryCache;
tc_ArticleRepository = tc_articleRepository;
tc_ArticleCateRepository = tc_articleCateRepository;
tc_DiyPageRepository = tc_diyPageRepository;
}
/// <summary>
/// 生成网站地图
/// </summary>
[HttpPost]
[ServiceFilter(typeof(AdminCheckFilter))]
public async Task<IActionResult> CreateMapFile([FromServices] IWebHostEnvironment environment,int urlCount=30000)
{
List<PageInfo> dataList = new List<PageInfo>();
var indexUrl = memoryCache.Get("WebSite_Url").ToString();
// 首页 文章分类 单页 文章
dataList.Add(new PageInfo() { loc= indexUrl , lastmod = DateTime.Now });
var cateList = await tc_ArticleCateRepository.Table.Where(x => x.status == 1).OrderBy(x => x.id).ToListAsync();
foreach (var item in cateList)
{
dataList.Add(new PageInfo() {
lastmod = item.updateTime,
loc = (indexUrl + "/List/" + item.id.ToString() + ".html")
});
}
后面还有 34 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
