diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/CourseController.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/CourseController.java new file mode 100644 index 0000000..87627ba --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/CourseController.java @@ -0,0 +1,68 @@ +package com.tamguo.web.tiku; + +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.servlet.ModelAndView; +import com.baomidou.mybatisplus.mapper.Condition; +import com.tamguo.modules.tiku.model.BookEntity; +import com.tamguo.modules.tiku.model.ChapterEntity; +import com.tamguo.modules.tiku.model.CourseEntity; +import com.tamguo.modules.tiku.model.SubjectEntity; +import com.tamguo.modules.tiku.service.IBookService; +import com.tamguo.modules.tiku.service.IChapterService; +import com.tamguo.modules.tiku.service.ICourseService; +import com.tamguo.modules.tiku.service.ISubjectService; + +/** + * Controller - 科目 + * + * @author tamguo + * + */ +@Controller +public class CourseController { + + @Autowired + IChapterService iChapterService; + @Autowired + ICourseService iCourseService; + @Autowired + ISubjectService iSubjectService; + @Autowired + IBookService iBookService; + + @SuppressWarnings("unchecked") + @RequestMapping(value = {"course/{uid}.html"}, method = RequestMethod.GET) + public ModelAndView index(@PathVariable String uid , ModelAndView model) { + try { + CourseEntity course = iCourseService.selectById(uid); + List bookList = iBookService.selectList(Condition.create().eq("course_id", uid)); + List chapterList = null; + BookEntity book = null; + if(bookList.size() > 0) { + book = bookList.get(0); + chapterList = iChapterService.selectList(Condition.create().eq("book_id", book.getId())); + } + SubjectEntity subject = iSubjectService.selectById(course.getSubjectId()); + List courseList = iCourseService.selectList(Condition.create().eq("subject_id", course.getSubjectId())); + + model.addObject("chapterList", chapterList); + model.addObject("courseList", courseList); + model.addObject("course", course); + model.addObject("subject", subject); + model.addObject("bookList", bookList); + model.addObject("book" , book); + + model.setViewName("chapter"); + return model; + } catch (Exception e) { + model.setViewName("404"); + return model; + } + } + +} diff --git a/tamguo-tms/src/main/resources/templates/chapter.html b/tamguo-tms/src/main/resources/templates/chapter.html index 6908613..ef7b34a 100644 --- a/tamguo-tms/src/main/resources/templates/chapter.html +++ b/tamguo-tms/src/main/resources/templates/chapter.html @@ -9,13 +9,13 @@ - - - - - - - + + + + + + + @@ -28,23 +28,23 @@ @@ -75,7 +75,7 @@
-
+

第一章 集合与常用逻辑用语

@@ -87,11 +87,11 @@
-
+