From 4a191e05af55490340841511f64c8cf998cec549 Mon Sep 17 00:00:00 2001 From: tamguo Date: Thu, 12 Jul 2018 18:11:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/js/tiku/question/list.js | 2 +- .../java/com/tamguo/model/CourseEntity.java | 20 +++--- .../java/com/tamguo/model/SubjectEntity.java | 20 ------ .../com/tamguo/web/ChapterController.java | 20 ------ .../java/com/tamguo/web/CourseController.java | 65 +++++++++++++++++++ .../com/tamguo/web/SubjectController.java | 9 +-- .../main/resources/mappers/CourseMapper.xml | 5 +- .../src/main/resources/static/js/subject.js | 2 +- .../src/main/resources/templates/chapter.html | 8 +-- .../main/resources/templates/paperlist.html | 2 +- .../src/main/resources/templates/subject.html | 2 +- 11 files changed, 89 insertions(+), 66 deletions(-) create mode 100644 tamguo/src/main/java/com/tamguo/web/CourseController.java diff --git a/tamguo-admin/src/main/resources/static/js/tiku/question/list.js b/tamguo-admin/src/main/resources/static/js/tiku/question/list.js index 999b61a..601182f 100644 --- a/tamguo-admin/src/main/resources/static/js/tiku/question/list.js +++ b/tamguo-admin/src/main/resources/static/js/tiku/question/list.js @@ -93,7 +93,7 @@ var vm = new Vue({ }, methods: { getChapterTree:function(courseId){ - axios.get(mainHttp + "/chapter/findChapterTreeByCourseId.html?courseId="+courseId).then(function (response) { + axios.get(mainHttp + "course/findChapterTreeByCourseId.html?courseId="+courseId).then(function (response) { ztree = $.fn.zTree.init($("#menuTree"), setting, response.data.result); var node = ztree.getNodeByParam("parentId", "-1"); ztree.selectNode(node); diff --git a/tamguo/src/main/java/com/tamguo/model/CourseEntity.java b/tamguo/src/main/java/com/tamguo/model/CourseEntity.java index e43097b..2fed75f 100644 --- a/tamguo/src/main/java/com/tamguo/model/CourseEntity.java +++ b/tamguo/src/main/java/com/tamguo/model/CourseEntity.java @@ -4,8 +4,6 @@ import java.io.Serializable; import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableName; import com.tamguo.config.dao.SuperEntity; - -import java.math.BigInteger; import java.util.List; @@ -19,11 +17,11 @@ public class CourseEntity extends SuperEntity implements Serializa private String name; - private BigInteger subjectId; + private String subjectId; - private BigInteger pointNum; + private String pointNum; - private BigInteger questionNum; + private String questionNum; private Integer orders; @@ -50,27 +48,27 @@ public class CourseEntity extends SuperEntity implements Serializa this.name = name; } - public BigInteger getSubjectId() { + public String getSubjectId() { return this.subjectId; } - public void setSubjectId(BigInteger subjectId) { + public void setSubjectId(String subjectId) { this.subjectId = subjectId; } - public BigInteger getQuestionNum() { + public String getQuestionNum() { return questionNum; } - public void setQuestionNum(BigInteger questionNum) { + public void setQuestionNum(String questionNum) { this.questionNum = questionNum; } - public BigInteger getPointNum() { + public String getPointNum() { return pointNum; } - public void setPointNum(BigInteger pointNum) { + public void setPointNum(String pointNum) { this.pointNum = pointNum; } diff --git a/tamguo/src/main/java/com/tamguo/model/SubjectEntity.java b/tamguo/src/main/java/com/tamguo/model/SubjectEntity.java index 7c06e88..2f83ae0 100644 --- a/tamguo/src/main/java/com/tamguo/model/SubjectEntity.java +++ b/tamguo/src/main/java/com/tamguo/model/SubjectEntity.java @@ -14,10 +14,6 @@ public class SubjectEntity extends SuperEntity implements Seriali private String name; - private String courseId; - - private String courseName; - @TableField(exist=false) private List courseList; @@ -29,22 +25,6 @@ public class SubjectEntity extends SuperEntity implements Seriali this.name = name; } - public String getCourseId() { - return courseId; - } - - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public String getCourseName() { - return courseName; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - public List getCourseList() { return courseList; } diff --git a/tamguo/src/main/java/com/tamguo/web/ChapterController.java b/tamguo/src/main/java/com/tamguo/web/ChapterController.java index 0154468..dabdc20 100644 --- a/tamguo/src/main/java/com/tamguo/web/ChapterController.java +++ b/tamguo/src/main/java/com/tamguo/web/ChapterController.java @@ -1,19 +1,14 @@ 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 org.springframework.web.servlet.ModelAndView; - import com.tamguo.model.ChapterEntity; import com.tamguo.service.IChapterService; -import com.tamguo.service.ICourseService; -import com.tamguo.service.ISubjectService; import com.tamguo.util.Result; @@ -22,21 +17,6 @@ public class ChapterController { @Autowired private IChapterService iChapterService; - @Autowired - private ICourseService iCourseService; - @Autowired - private ISubjectService iSubjectService; - - @RequestMapping(value = {"/chapter/{subjectId}/{courseId}.html"}, method = RequestMethod.GET) - public ModelAndView indexAction(@PathVariable String subjectId , @PathVariable String courseId, ModelAndView model) { - model.setViewName("chapter"); - model.addObject("chapterList", iChapterService.findCourseChapter(courseId)); - model.addObject("courseList", iCourseService.findBySubjectId(subjectId)); - model.addObject("subjectId", subjectId); - model.addObject("course", iCourseService.find(courseId)); - model.addObject("subject", iSubjectService.find(subjectId)); - return model; - } @RequestMapping(value = {"/chapter/findChapter/{courseId}.html"}, method = RequestMethod.GET) @ResponseBody diff --git a/tamguo/src/main/java/com/tamguo/web/CourseController.java b/tamguo/src/main/java/com/tamguo/web/CourseController.java new file mode 100644 index 0000000..ab296f2 --- /dev/null +++ b/tamguo/src/main/java/com/tamguo/web/CourseController.java @@ -0,0 +1,65 @@ +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; +/** + * Controller - 科目 + * + * @author tamguo + * + */ +import org.springframework.web.servlet.ModelAndView; + +import com.tamguo.model.ChapterEntity; +import com.tamguo.model.CourseEntity; +import com.tamguo.model.SubjectEntity; +import com.tamguo.service.IChapterService; +import com.tamguo.service.ICourseService; +import com.tamguo.service.ISubjectService; +import com.tamguo.util.Result; + +@Controller +public class CourseController { + + @Autowired + IChapterService iChapterService; + @Autowired + ICourseService iCourseService; + @Autowired + ISubjectService iSubjectService; + + @RequestMapping(value = {"course/{uid}"}, method = RequestMethod.GET) + public ModelAndView index(@PathVariable String uid , ModelAndView model) { + CourseEntity course = iCourseService.find(uid); + SubjectEntity subject = iSubjectService.find(course.getSubjectId()); + List chapterList = iChapterService.findCourseChapter(uid); + List courseList = iCourseService.findBySubjectId(course.getSubjectId()); + + model.addObject("chapterList", chapterList); + model.addObject("courseList", courseList); + model.addObject("course", course); + model.addObject("subject", subject); + + model.setViewName("chapter"); + return model; + } + + @RequestMapping(value = {"course/findChapter"}, method = RequestMethod.GET) + @ResponseBody + public List findChapterByCourseId(String courseId){ + return iChapterService.findCourseChapter(courseId); + } + + @RequestMapping(value = {"course/findChapterTreeByCourseId"}, 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/SubjectController.java b/tamguo/src/main/java/com/tamguo/web/SubjectController.java index 59d4a7a..bd011ab 100644 --- a/tamguo/src/main/java/com/tamguo/web/SubjectController.java +++ b/tamguo/src/main/java/com/tamguo/web/SubjectController.java @@ -1,7 +1,6 @@ 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; @@ -16,7 +15,6 @@ import com.tamguo.model.CourseEntity; import com.tamguo.model.SubjectEntity; import com.tamguo.service.IAreaService; import com.tamguo.service.IChapterService; -import com.tamguo.service.ICourseService; import com.tamguo.service.ISubjectService; import com.tamguo.util.Result; @@ -29,8 +27,6 @@ import com.tamguo.util.Result; @Controller public class SubjectController { - @Autowired - private ICourseService iCourseService; @Autowired private IChapterService iChapterService; @Autowired @@ -41,8 +37,9 @@ public class SubjectController { @RequestMapping(value = {"subject/{subjectId}.html"}, method = RequestMethod.GET) public ModelAndView indexAction(@PathVariable String subjectId , ModelAndView model) { SubjectEntity subject = iSubjectService.find(subjectId); - CourseEntity course = iCourseService.find(subject.getCourseId()); - List chapterList = iChapterService.findCourseChapter(subject.getCourseId()); + // 获取第一个科目 + CourseEntity course = subject.getCourseList().get(0); + List chapterList = iChapterService.findCourseChapter(course.getUid()); model.setViewName("subject"); model.addObject("subject", subject); model.addObject("course" , course); diff --git a/tamguo/src/main/resources/mappers/CourseMapper.xml b/tamguo/src/main/resources/mappers/CourseMapper.xml index 84bfdc4..669c3b6 100644 --- a/tamguo/src/main/resources/mappers/CourseMapper.xml +++ b/tamguo/src/main/resources/mappers/CourseMapper.xml @@ -9,7 +9,10 @@ c.orders, c.point_num, c.question_num, - c.subject_id + c.subject_id, + c.seo_title, + c.seo_keywords, + c.seo_description FROM tiku_course c WHERE diff --git a/tamguo/src/main/resources/static/js/subject.js b/tamguo/src/main/resources/static/js/subject.js index 10e598b..b408986 100644 --- a/tamguo/src/main/resources/static/js/subject.js +++ b/tamguo/src/main/resources/static/js/subject.js @@ -17,7 +17,7 @@ $(function(){ var courseId = $(this).attr("courseid"); $.ajax({ type : "get", - url : mainHttp + "chapter/findChapter/" +courseId+".html", + url : mainHttp + "course/findChapter.html?courseId=" +courseId+".html", async : true, dataType : "json", success : function(data) {// 返回数据根据结果进行相应的处理,无论请求成功还是失败,都会走这个方法的 diff --git a/tamguo/src/main/resources/templates/chapter.html b/tamguo/src/main/resources/templates/chapter.html index 1a4aa3e..7a31202 100644 --- a/tamguo/src/main/resources/templates/chapter.html +++ b/tamguo/src/main/resources/templates/chapter.html @@ -32,10 +32,10 @@