From dda8c4877f8eef48363703c607b3fdc8fdc43be6 Mon Sep 17 00:00:00 2001 From: tamguo Date: Tue, 10 Jul 2018 19:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tamguo/dao/CourseMapper.java | 5 ++ .../com/tamguo/service/ICourseService.java | 11 +++ .../tamguo/service/impl/CourseService.java | 67 +++++++++++++++++++ .../com/tamguo/web/ChapterController.java | 39 ++++++++++- .../main/resources/mappers/CourseMapper.xml | 9 +++ .../main/resources/static/js/chapter/main.js | 30 +++++++++ .../src/main/resources/templates/chapter.html | 30 +++------ 7 files changed, 167 insertions(+), 24 deletions(-) create mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java create mode 100644 tamguo-mobile/src/main/resources/static/js/chapter/main.js diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java b/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java index 37674d3..ed54626 100644 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java @@ -2,11 +2,16 @@ package com.tamguo.dao; import java.util.List; +import org.apache.ibatis.annotations.Param; + import com.tamguo.config.dao.SuperMapper; +import com.tamguo.model.ChapterEntity; import com.tamguo.model.CourseEntity; public interface CourseMapper extends SuperMapper{ List findBySubjectId(String uid); + List findByCourseId(@Param(value="courseId") String courseId); + } diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java b/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java new file mode 100644 index 0000000..b65d96e --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java @@ -0,0 +1,11 @@ +package com.tamguo.service; + +import java.util.List; +import com.tamguo.model.ChapterEntity; + +public interface ICourseService { + + // 获取科目章节 + public List findCourseChapter(String courseId); + +} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java b/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java new file mode 100644 index 0000000..52368ec --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java @@ -0,0 +1,67 @@ +package com.tamguo.service.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.tamguo.dao.CourseMapper; +import com.tamguo.model.ChapterEntity; +import com.tamguo.service.ICourseService; + +@Service +public class CourseService implements ICourseService{ + + @Autowired + private CourseMapper courseMapper; + + @Override + public List findCourseChapter(String courseId) { + List chapterList = courseMapper.findByCourseId(courseId); + + // 获取根chapter UID + String rootUid = StringUtils.EMPTY; + for(int i=0 ; i entitys = new ArrayList<>(); + for(int i=0 ; i childs = new ArrayList<>(); + for(int k=0 ; k childs = entitys.get(i).getChildChapterList(); + for(int k=0 ; k tmpChilds = new ArrayList<>(); + for(int n=0 ; n courseList = iSubjectService.findCourseList(subjectId); + return Result.successResult(courseList); + } catch (Exception e) { + return ExceptionSupport.resolverResult("查询科目", this.getClass(), e); + } + } + + @RequestMapping(path="chapter/findChapterList",method=RequestMethod.POST) + @ResponseBody + public Result findChapterList(String courseId) { + try { + List chapterList = iCourseService.findCourseChapter(courseId); + return Result.successResult(chapterList); + } catch (Exception e) { + return ExceptionSupport.resolverResult("查询章节", this.getClass(), e); + } + } + } diff --git a/tamguo-mobile/src/main/resources/mappers/CourseMapper.xml b/tamguo-mobile/src/main/resources/mappers/CourseMapper.xml index 84bfdc4..451d633 100644 --- a/tamguo-mobile/src/main/resources/mappers/CourseMapper.xml +++ b/tamguo-mobile/src/main/resources/mappers/CourseMapper.xml @@ -17,4 +17,13 @@ ORDER BY orders ASC + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/static/js/chapter/main.js b/tamguo-mobile/src/main/resources/static/js/chapter/main.js new file mode 100644 index 0000000..064ad94 --- /dev/null +++ b/tamguo-mobile/src/main/resources/static/js/chapter/main.js @@ -0,0 +1,30 @@ +var vm = new Vue({ + el:'#app', + data : { + courseList:[], + chapterList:[], + docked: false, + open: true, + position: 'left', + panel: '' + }, + methods:{ + findCourseList(subjectId){ + axios({method: 'post',url: mainHttp + 'chapter/findCourseList.html?subjectId='+subjectId}).then(function(response){ + if(response.data.code == 0){ + vm.courseList = response.data.result; + } + }); + }, + findChapterList(courseId){ + axios({method: 'post',url: mainHttp + 'chapter/findChapterList.html?courseId='+courseId}).then(function(response){ + if(response.data.code == 0){ + vm.courseList = response.data.result; + } + }); + } + } +}); + +vm.findCourseList(subjectId); +vm.findChapterList(courseId); \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/chapter.html b/tamguo-mobile/src/main/resources/templates/chapter.html index 6daab54..460f2c8 100644 --- a/tamguo-mobile/src/main/resources/templates/chapter.html +++ b/tamguo-mobile/src/main/resources/templates/chapter.html @@ -1,5 +1,5 @@ - + @@ -29,7 +29,6 @@ 当前位置 理科数学 - 第一章 社会工作概述 @@ -90,18 +89,10 @@ - - 理科数学 - - - 文科数学 - - - 物理 - - - 英语 + + {{course.name}} + 关闭 @@ -113,16 +104,11 @@ - + + \ No newline at end of file