From f7191c7c19fa1b6cbc5db6dc24e6e2535a875c35 Mon Sep 17 00:00:00 2001 From: tamguo Date: Thu, 6 Dec 2018 10:52:46 +0800 Subject: [PATCH] fix bug --- .../tamguo/web/BookCategoryController.java | 48 +++++ .../java/com/tamguo/web/IndexController.java | 8 + .../main/resources/templates/category.html | 184 ++++++++++++++++++ .../src/main/resources/templates/index.html | 3 + 4 files changed, 243 insertions(+) create mode 100644 tamguo-bms/src/main/java/com/tamguo/web/BookCategoryController.java create mode 100644 tamguo-bms/src/main/resources/templates/category.html diff --git a/tamguo-bms/src/main/java/com/tamguo/web/BookCategoryController.java b/tamguo-bms/src/main/java/com/tamguo/web/BookCategoryController.java new file mode 100644 index 0000000..cb43126 --- /dev/null +++ b/tamguo-bms/src/main/java/com/tamguo/web/BookCategoryController.java @@ -0,0 +1,48 @@ +package com.tamguo.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.baomidou.mybatisplus.plugins.Page; +import com.tamguo.modules.book.model.BookEntity; +import com.tamguo.modules.book.service.IBookCategoryService; +import com.tamguo.modules.book.service.IBookService; +import com.tamguo.modules.member.model.MemberEntity; +import com.tamguo.modules.member.service.IMemberService; + +@Controller +public class BookCategoryController { + + @Autowired + IBookService iBookService; + @Autowired + IMemberService iMemberService; + @Autowired + IBookCategoryService iBookCategoryService; + + @SuppressWarnings("unchecked") + @RequestMapping(value="category/{id}.html") + public ModelAndView bookCategory(@PathVariable String id , Integer current , ModelAndView model) { + if(current == null) { + current = 1; + } + model.setViewName("category"); + Page bookPage = iBookService.selectPage(new Page<>(current, 18)); + for(BookEntity book : bookPage.getRecords()) { + MemberEntity member = iMemberService.selectById(book.getOwner()); + if(member != null) { + book.setMemberName(member.getUsername()); + } + } + // 查询分类 + model.addObject("bookCategoryList", iBookCategoryService.selectList(Condition.create().eq("parent_id", "0"))); + model.addObject("categoryId", id); + model.addObject("bookPage", bookPage); + return model; + } + +} diff --git a/tamguo-bms/src/main/java/com/tamguo/web/IndexController.java b/tamguo-bms/src/main/java/com/tamguo/web/IndexController.java index 83a015d..c3e1bc2 100644 --- a/tamguo-bms/src/main/java/com/tamguo/web/IndexController.java +++ b/tamguo-bms/src/main/java/com/tamguo/web/IndexController.java @@ -6,8 +6,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; +import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.plugins.Page; import com.tamguo.modules.book.model.BookEntity; +import com.tamguo.modules.book.service.IBookCategoryService; import com.tamguo.modules.book.service.IBookService; import com.tamguo.modules.member.model.MemberEntity; import com.tamguo.modules.member.service.IMemberService; @@ -25,7 +27,10 @@ public class IndexController { IBookService iBookService; @Autowired IMemberService iMemberService; + @Autowired + IBookCategoryService iBookCategoryService; + @SuppressWarnings("unchecked") @RequestMapping(path= {"index" , "/" , "index.html"}) public ModelAndView index(Integer current , ModelAndView model) { if(current == null) { @@ -40,6 +45,9 @@ public class IndexController { } } model.addObject("bookPage", bookPage); + + // 查询分类 + model.addObject("bookCategoryList", iBookCategoryService.selectList(Condition.create().eq("parent_id", "0"))); model.setViewName("index"); return model; diff --git a/tamguo-bms/src/main/resources/templates/category.html b/tamguo-bms/src/main/resources/templates/category.html new file mode 100644 index 0000000..78dec55 --- /dev/null +++ b/tamguo-bms/src/main/resources/templates/category.html @@ -0,0 +1,184 @@ + + + + 专业的高中书籍托管平台_探书网 + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+
+
+ + + +
+
+ 运行支持组 +
+
+ + 作者 + - + mayun12 + +
+
+
+
+
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/tamguo-bms/src/main/resources/templates/index.html b/tamguo-bms/src/main/resources/templates/index.html index b54d70b..526c51b 100644 --- a/tamguo-bms/src/main/resources/templates/index.html +++ b/tamguo-bms/src/main/resources/templates/index.html @@ -29,6 +29,9 @@
  • 首页
  • +
  • + 文章 +