diff --git a/src/main/java/com/northtecom/visatrack/api/controller/api/ContentController.java b/src/main/java/com/northtecom/visatrack/api/controller/api/ContentController.java new file mode 100644 index 0000000..9f16810 --- /dev/null +++ b/src/main/java/com/northtecom/visatrack/api/controller/api/ContentController.java @@ -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. + *

Sitemap

+ * 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 = "\n" + + "\n" + + "https://www.ossez.com/sitemap_recent.xml\n" + + "2022-12-15T05:44:41Z\n" + + "\n" + + "\n" + + "https://www.ossez.com/sitemap_1.xml\n" + + "2022-12-15T05:44:41Z\n" + + "\n" + + "\n" + + "https://www.ossez.com/sitemap_2.xml\n" + + "2022-12-12T15:49:36Z\n" + + "\n" + + ""; + + +// return Base64.getEncoder().withoutPadding().encodeToString(bt); + return btx; + } + + +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index e401c40..d684c86 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -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