|
@@ -14,25 +14,31 @@
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
|
|
|
-package com.firerock.webttkuaiban.demos.web;
|
|
|
+package com.firerock.webttkuaiban.demos.controller;
|
|
|
|
|
|
+import com.firerock.webttkuaiban.demos.pojo.Article;
|
|
|
+import com.firerock.webttkuaiban.demos.service.ArticleService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
|
|
*/
|
|
|
@Controller
|
|
|
+@RequestMapping("article")
|
|
|
public class ArticleController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ArticleService articleService;
|
|
|
+
|
|
|
// http://127.0.0.1:8080/user/123/roles/222
|
|
|
@RequestMapping(value = "/articleList", method = RequestMethod.GET)
|
|
|
public String articleList(Model model) {
|
|
@@ -48,4 +54,32 @@ public class ArticleController {
|
|
|
return "articleList";
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/pageList") // 这里的 PageBean 是事先定义好的实体类
|
|
|
+ public Object PageList(Integer pageIndex, Integer pageSize,
|
|
|
+ @RequestParam(required = false) String info)
|
|
|
+ {
|
|
|
+ List<Article> articleList= articleService.PageList(pageIndex,pageSize,info);
|
|
|
+ Integer total=articleService.getTotal(info);
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("data", articleList);
|
|
|
+ map.put("total", total);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping ("/latestList")
|
|
|
+ public Object latestList() {
|
|
|
+ List<Article> latestList =articleService.latestList();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("data", latestList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping ("/relatedList")
|
|
|
+ public Object relatedList(@RequestParam("id") Integer id) {
|
|
|
+ List<Article> relatedList =articleService.relatedList(id);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("data", relatedList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|