* @throws \think\exception\DbException
*/
public function siteMap(Request $request)
{
$newsList = News::where('domain_id', $this->domainId)->order('create_time', 'desc')->select();
$xml = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><urlset xmlns=\'http://www.sitemaps.org/schemas/sitemap/0.9\'>';
$day = date('Y-m-d');
$xml .= '<url><loc>' . 'http://www.' . $this->url . '</loc><priority>1.0</priority><lastmod>' . $day . '</lastmod><changefreq>Always</changefreq></url>';
$list = array_filter(cache('area'));
foreach ($list as $v) {
$url = "http://" . $v . '.' . $this->url;
$xml .= '<url><loc>' . $url . '</loc><priority>1.0</priority><lastmod>' . $day . '</lastmod><changefreq>Always</changefreq></url>';
}
if (!empty($newsList)) {
foreach ($newsList as $item) {
$local = 'http://www.' . $this->url . '/news/' . $item['id'] . '.html';
$xml .= '<url><loc>' . $local . '</loc><priority>0.9</priority><lastmod>' . date('Y-m-d', $item['create_time']) . '</lastmod><changefreq>Always</changefreq></url>';
}