|
|
@@ -11,12 +11,15 @@ import cn.reghao.jutil.jdk.web.db.PageList;
|
|
|
import cn.reghao.tnb.search.app.hibernate.HibernateQuery;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -25,15 +28,15 @@ import java.util.List;
|
|
|
@Tag(name = "博客前台页面")
|
|
|
@RestController
|
|
|
@RequestMapping("/api/blog")
|
|
|
-public class ForegroundController /*extends BaseController */{
|
|
|
+public class BlogController /*extends BaseController */{
|
|
|
private final CategoryService categoryService;
|
|
|
private final ArticleQuery articleQuery;
|
|
|
private final ArticleViewService articleViewService;
|
|
|
private final HibernateQuery hibernateQuery;
|
|
|
private final int pageSize = 10;
|
|
|
|
|
|
- public ForegroundController(CategoryService categoryService, ArticleQuery articleQuery,
|
|
|
- ArticleViewService articleViewService, HibernateQuery hibernateQuery) {
|
|
|
+ public BlogController(CategoryService categoryService, ArticleQuery articleQuery,
|
|
|
+ ArticleViewService articleViewService, HibernateQuery hibernateQuery) {
|
|
|
this.categoryService = categoryService;
|
|
|
this.articleQuery = articleQuery;
|
|
|
this.articleViewService = articleViewService;
|
|
|
@@ -86,9 +89,27 @@ public class ForegroundController /*extends BaseController */{
|
|
|
|
|
|
@Operation(summary = "某个分类/标签下的文章列表页面", description = "N")
|
|
|
@GetMapping("/category/post")
|
|
|
- public String tagPost(@RequestParam("type") String type,
|
|
|
- @RequestParam("name") String name,
|
|
|
- @RequestParam("pn") int pageNumber) {
|
|
|
+ public String tagPost(/*@RequestParam("type") String type1,
|
|
|
+ @RequestParam("name") String name1,
|
|
|
+ @RequestParam("pn") int pageNumber1,*/
|
|
|
+ HttpServletRequest request) {
|
|
|
+ Map<String, String> map = getQuery(request);
|
|
|
+ String type = map.get("type");
|
|
|
+ if (type == null) {
|
|
|
+ return WebResult.failWithMsg("parameter type not exist");
|
|
|
+ }
|
|
|
+
|
|
|
+ String name = map.get("name");
|
|
|
+ if (name == null) {
|
|
|
+ return WebResult.failWithMsg("parameter name not exist");
|
|
|
+ }
|
|
|
+
|
|
|
+ String pn = map.get("pn");
|
|
|
+ if (pn == null) {
|
|
|
+ return WebResult.failWithMsg("parameter pn not exist");
|
|
|
+ }
|
|
|
+ int pageNumber = Integer.parseInt(pn);
|
|
|
+
|
|
|
int typeInt = 0;
|
|
|
if (type.equals("tag")) {
|
|
|
typeInt = CategoryType.Tag.getValue();
|
|
|
@@ -103,6 +124,16 @@ public class ForegroundController /*extends BaseController */{
|
|
|
return WebResult.success(pageList);
|
|
|
}
|
|
|
|
|
|
+ private Map<String, String> getQuery(HttpServletRequest request) {
|
|
|
+ String queryString = request.getQueryString();
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ for (String param : queryString.split("&")) {
|
|
|
+ String[] paramArr = param.split("=");
|
|
|
+ map.put(paramArr[0], paramArr[1]);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
@Operation(summary = "文章归档列表页面", description = "N")
|
|
|
@GetMapping("/archive")
|
|
|
public String archive() {
|