From c498229dd5509b5a38c595e0c850f2a945ccdb23 Mon Sep 17 00:00:00 2001 From: tamguo Date: Thu, 12 Jul 2018 19:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tamguo/service/impl/PaperService.java | 12 ++++++ .../com/tamguo/web/ChapterController.java | 32 -------------- .../java/com/tamguo/web/PaperController.java | 27 ++++++++---- .../main/resources/mappers/PaperMapper.xml | 10 ++--- .../src/main/resources/templates/chapter.html | 6 +-- .../src/main/resources/templates/index.html | 14 +++---- .../main/resources/templates/paperlist.html | 42 +++++++++---------- .../src/main/resources/templates/subject.html | 6 +-- 8 files changed, 71 insertions(+), 78 deletions(-) delete mode 100644 tamguo/src/main/java/com/tamguo/web/ChapterController.java diff --git a/tamguo/src/main/java/com/tamguo/service/impl/PaperService.java b/tamguo/src/main/java/com/tamguo/service/impl/PaperService.java index 5d333a4..c82c531 100644 --- a/tamguo/src/main/java/com/tamguo/service/impl/PaperService.java +++ b/tamguo/src/main/java/com/tamguo/service/impl/PaperService.java @@ -73,6 +73,18 @@ public class PaperService extends ServiceImpl implemen public Page findList(String subjectId , String courseId, String paperType, String year, String area , Integer pageNum) { Page page = new Page<>(pageNum , TamguoConstant.DEFAULT_PAGE_SIZE); + if("0".equals(courseId)) { + courseId = ""; + } + if("0".equals(paperType)) { + paperType = ""; + } + if("0".equals(year)) { + year = ""; + } + if("0".equals(area)) { + area = ""; + } return page.setRecords(paperMapper.findList(subjectId , courseId , paperType , year , area , page)); } diff --git a/tamguo/src/main/java/com/tamguo/web/ChapterController.java b/tamguo/src/main/java/com/tamguo/web/ChapterController.java deleted file mode 100644 index dabdc20..0000000 --- a/tamguo/src/main/java/com/tamguo/web/ChapterController.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.tamguo.web; - -import java.util.List; -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.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import com.tamguo.model.ChapterEntity; -import com.tamguo.service.IChapterService; -import com.tamguo.util.Result; - - -@Controller -public class ChapterController { - - @Autowired - private IChapterService iChapterService; - - @RequestMapping(value = {"/chapter/findChapter/{courseId}.html"}, method = RequestMethod.GET) - @ResponseBody - public List findChapterByCourseId(@PathVariable String courseId){ - return iChapterService.findCourseChapter(courseId); - } - - @RequestMapping(value = {"/chapter/findChapterTreeByCourseId.html"}, method = RequestMethod.GET) - @ResponseBody - public Result findChapterTreeByCourseId(String courseId){ - return Result.successResult(iChapterService.getChapterTree(courseId)); - } -} diff --git a/tamguo/src/main/java/com/tamguo/web/PaperController.java b/tamguo/src/main/java/com/tamguo/web/PaperController.java index 5d5d588..8460d93 100644 --- a/tamguo/src/main/java/com/tamguo/web/PaperController.java +++ b/tamguo/src/main/java/com/tamguo/web/PaperController.java @@ -11,7 +11,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; +import com.tamguo.model.AreaEntity; +import com.tamguo.model.CourseEntity; import com.tamguo.model.PaperEntity; +import com.tamguo.model.SubjectEntity; import com.tamguo.service.IAreaService; import com.tamguo.service.ICourseService; import com.tamguo.service.IPaperService; @@ -40,16 +43,26 @@ public class PaperController { @Autowired private ISubjectService iSubjectService; - @RequestMapping(value = {"/paperlist/{subjectId}/{courseId}-{paperType}-{year}-{area}-{pageNum}.html"}, method = RequestMethod.GET) + @RequestMapping(value = {"paperlist/{subjectId}-{courseId}-{paperType}-{year}-{area}-{pageNum}"}, method = RequestMethod.GET) public ModelAndView indexAction(@PathVariable String subjectId , @PathVariable String courseId , @PathVariable String paperType, @PathVariable String year , @PathVariable String area , @PathVariable Integer pageNum, ModelAndView model) { model.setViewName("paperlist"); - model.addObject("courseList", iCourseService.findBySubjectId(subjectId)); - model.addObject("subject", iSubjectService.find(subjectId)); - model.addObject("course", iCourseService.find(courseId)); - model.addObject("areaList", iAreaService.findRootArea()); - model.addObject("paperPage" , PageUtils.getPage(iPaperService.findList(subjectId , courseId , paperType , year , area , pageNum))); - model.addObject("total" , iPaperService.getPaperTotal()); + + CourseEntity course = iCourseService.find(courseId); + List courseList = iCourseService.findBySubjectId(subjectId); + SubjectEntity subject = iSubjectService.find(subjectId); + List areaList = iAreaService.findRootArea(); + PageUtils page = PageUtils.getPage(iPaperService.findList(subjectId , courseId , paperType , year , area , pageNum)); + if(course == null) { + course = courseList.get(0); + } + Long total = iPaperService.getPaperTotal(); + model.addObject("courseList", courseList); + model.addObject("subject", subject); + model.addObject("course", course); + model.addObject("areaList", areaList); + model.addObject("paperPage" , page); + model.addObject("total" , total); model.addObject("courseId", courseId); model.addObject("paperType", paperType); model.addObject("year", year); diff --git a/tamguo/src/main/resources/mappers/PaperMapper.xml b/tamguo/src/main/resources/mappers/PaperMapper.xml index 92281ea..2b8e2c6 100644 --- a/tamguo/src/main/resources/mappers/PaperMapper.xml +++ b/tamguo/src/main/resources/mappers/PaperMapper.xml @@ -82,19 +82,19 @@ FROM tiku_paper p where 1 = 1 - + and p.subject_id = #{subjectId} - + and p.course_id = #{courseId} - + and p.type = #{paperType} - + and p.year = #{year} - + and p.area_id = #{area} diff --git a/tamguo/src/main/resources/templates/chapter.html b/tamguo/src/main/resources/templates/chapter.html index 7a31202..1450237 100644 --- a/tamguo/src/main/resources/templates/chapter.html +++ b/tamguo/src/main/resources/templates/chapter.html @@ -38,13 +38,13 @@ 章节学习
  • - 真题试卷 + 真题试卷
  • - 模拟试卷 + 模拟试卷
  • - 考前押题 + 考前押题
  • diff --git a/tamguo/src/main/resources/templates/index.html b/tamguo/src/main/resources/templates/index.html index 00bd20f..5f8ed2d 100644 --- a/tamguo/src/main/resources/templates/index.html +++ b/tamguo/src/main/resources/templates/index.html @@ -106,14 +106,14 @@

    试卷资源 一考知底,高分必刷,全面提分 当前位置: - 更多地区 > + 更多地区 >

    历年真题 - 更多真题试卷 > + 更多真题试卷 >