测试下站点地图的动态化处理

This commit is contained in:
YuCheng Hu 2022-12-15 14:29:46 -05:00
parent 488ea037a8
commit 6ff4b4b3d1
2 changed files with 77 additions and 3 deletions

View File

@ -0,0 +1,74 @@
package com.northtecom.visatrack.api.controller.api;
import com.northtecom.visatrack.api.service.impl.BlogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.io.IOException;
import java.util.Base64;
/**
* The API related to website content.
* <h2>Sitemap</h2>
* To increase website index, we need to submit sitemap to search engine, sitemap is the file to let search engine know
* which links they should get indexed.
*
* @Author: YuCheng
*/
@RestController
@RequestMapping(ContentController.BASE_URL)
@Tag(name = ContentController.TAG_NAME, description = ContentController.TAG_DESCRIPTION)
public class ContentController {
protected static final String BASE_URL = "/api/content";
protected static final String DATA_NAME = "Content";
protected static final String TAG_NAME = "Content";
protected static final String TAG_DESCRIPTION = "Content management API";
private final BlogService blogService;
public ContentController(BlogService blogService) {
this.blogService = blogService;
}
/**
* This API will provide sitemap as sitemap.xml file
*
* @return a File with Spring MVC
*/
@GetMapping("/sitemap")
@Operation(summary = "Get Sitemap xml file", description = "This API will get sitemap xml file")
public String querySitemap() {
byte[] bt = null;
String btx = null;
// bt = FileUtils.readFileToByteArray(new File("D:\\home\\sitemap.xml"));
btx = "<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" +
"<sitemap>\n" +
"<loc>https://www.ossez.com/sitemap_recent.xml</loc>\n" +
"<lastmod>2022-12-15T05:44:41Z</lastmod>\n" +
"</sitemap>\n" +
"<sitemap>\n" +
"<loc>https://www.ossez.com/sitemap_1.xml</loc>\n" +
"<lastmod>2022-12-15T05:44:41Z</lastmod>\n" +
"</sitemap>\n" +
"<sitemap>\n" +
"<loc>https://www.ossez.com/sitemap_2.xml</loc>\n" +
"<lastmod>2022-12-12T15:49:36Z</lastmod>\n" +
"</sitemap>\n" +
"</sitemapindex>";
// return Base64.getEncoder().withoutPadding().encodeToString(bt);
return btx;
}
}

View File

@ -1,10 +1,10 @@
app:
database:
host: 54.39.157.60
host: 158.69.254.99
port: 3306
name: usvisatrack
username: root
password: ETNN0sqc1qMbgQaeGKWL
username: yhu
password: hulinghyc
web:
host: 8282