程序优化

main
tamguo 7 years ago
parent 4a191e05af
commit c498229dd5

@ -73,6 +73,18 @@ public class PaperService extends ServiceImpl<PaperMapper, PaperEntity> implemen
public Page<PaperEntity> findList(String subjectId , String courseId,
String paperType, String year, String area , Integer pageNum) {
Page<PaperEntity> 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));
}

@ -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<ChapterEntity> 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));
}
}

@ -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<CourseEntity> courseList = iCourseService.findBySubjectId(subjectId);
SubjectEntity subject = iSubjectService.find(subjectId);
List<AreaEntity> 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);

@ -82,19 +82,19 @@
FROM
tiku_paper p
where 1 = 1
<if test="subjectId != null and subjectId != 0">
<if test="subjectId != null and subjectId != ''">
and p.subject_id = #{subjectId}
</if>
<if test="courseId != null and courseId != 0">
<if test="courseId != null and courseId != ''">
and p.course_id = #{courseId}
</if>
<if test="paperType != null and paperType != 0">
<if test="paperType != null and paperType != ''">
and p.type = #{paperType}
</if>
<if test="year != null and year != 0">
<if test="year != null and year != ''">
and p.year = #{year}
</if>
<if test="area != null and area != 0">
<if test="area != null and area != ''">
and p.area_id = #{area}
</if>
</select>

@ -38,13 +38,13 @@
<a class="curr " th:href="${setting.domain + 'course/'+course.uid+'.html'}">章节学习</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subjectId + '/'+course.uid+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subjectId + '/'+course.uid+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subjectId + '/'+course.uid+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
</li>
</ul>
</div>

@ -106,14 +106,14 @@
<p class="title">试卷资源
<span class="detail">一考知底,高分必刷,全面提分</span>
<span class="area-content">当前位置:
<a class="more-area-link" th:href="${setting.domain+'paperlist/1014440449138954241/0-0-0-1-1.html'}" target="_blank">更多地区 &gt; </a>
<a class="more-area-link" th:href="${setting.domain+'paperlist/1017229051786862594-0-0-0-1-1.html'}" target="_blank">更多地区 &gt; </a>
</span>
</p>
<div class="paper-main">
<div class="paper-box zhenti-box homepage-zhenti-box">
<div class="paper-list-wrap">
<h3 class="paper-title">历年真题
<a class="list-more-link" th:href="${setting.domain+'paperlist/1014440449138954241/0-1-0-0-1.html'}">更多真题试卷 &gt;</a>
<a class="list-more-link" th:href="${setting.domain+'paperlist/1017229051786862594-0-1-0-0-1.html'}">更多真题试卷 &gt;</a>
</h3>
<ul class="paper-list paper-list-zhenti">
<li class="list-item" th:each="p,pStat:${historyPaperList}">
@ -130,7 +130,7 @@
<div class="paper-box moni-box homepage-moni-box">
<div class="paper-list-wrap">
<h3 class="paper-title">模拟试卷
<a class="list-more-link" th:href="${setting.domain+'paperlist/1014440449138954241/0-2-0-0-1.html'}">更多模拟试卷 &gt;</a>
<a class="list-more-link" th:href="${setting.domain+'paperlist/1017229051786862594-0-2-0-0-1.html'}">更多模拟试卷 &gt;</a>
</h3>
<ul class="paper-list paper-list-moni">
<li class="list-item" th:each="p,pStat:${simulationPaperList}">
@ -146,7 +146,7 @@
</div>
<div class="homepage-paper-box shiti-box">
<div class="hotpaper-list-wrap">
<h3 class="hotpaper-title">热门试卷<a class="list-more-link" th:href="${setting.domain+'paperlist/1014440449138954241/0-0-0-1-1.html'}">更多热门试卷 &gt; </a>
<h3 class="hotpaper-title">热门试卷<a class="list-more-link" th:href="${setting.domain+'paperlist/1017229051786862594-0-0-0-1-1.html'}">更多热门试卷 &gt; </a>
</h3>
<ul class="hotpaper-list">
<li class="hotpaper-list-item" th:each="p,pStat:${hotPaperList}">
@ -162,12 +162,12 @@
<div class="school-paper-main">
<div class="school-paper-container homepage-school-container">
<h3 class="school-container-title">名校精品试卷
<a class="school-paper-more-link" th:href="${setting.domain + 'paperlist/1014440449138954241/0-4-0-0-1.html'}">更多名校精品卷 &gt; </a>
<a class="school-paper-more-link" th:href="${setting.domain + 'paperlist/1017229051786862594-0-4-0-0-1.html'}">更多名校精品卷 &gt; </a>
</h3>
<div class="school-list">
<div class="school-list-item " th:each="s,sStat:${eliteSchoolPaperList}">
<div class="school-wrap school-wrap-bg1">
<a class="famous-school-link" th:href="${setting.domain + 'paperlist/1014440449138954241/0-4-0-0-1.html'}" data-schoolid="924cf7ec4afe04a1b071de05">
<a class="famous-school-link" th:href="${setting.domain + 'paperlist/1017229051786862594-0-4-0-0-1.html'}" data-schoolid="924cf7ec4afe04a1b071de05">
<div class="school-info">
<p class="name" th:text="${s.name}">北京大学附属中学</p>
<p class="info">
@ -193,7 +193,7 @@
</div>
<div class="more-school-list">
<a class="more-school-name" th:each="s,sStat:${eliteSchoolList}" th:text="${s.name}" th:href="${setting.domain + 'paperlist/1014440449138954241/0-4-0-0-1.html'}">
<a class="more-school-name" th:each="s,sStat:${eliteSchoolList}" th:text="${s.name}" th:href="${setting.domain + 'paperlist/1017229051786862594-0-4-0-0-1.html'}">
北京市八一学校
</a>
</div>

@ -35,13 +35,13 @@
<a class="" th:href="${setting.domain + 'course/'+courseId+'.html'}">章节学习</a>
</li>
<li class="contain-li">
<a th:class="${paperType == setting.PAPER_TYPE_ZHENTI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
<a th:class="${paperType == setting.PAPER_TYPE_ZHENTI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '-' +courseId+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
</li>
<li class="contain-li">
<a th:class="${paperType == setting.PAPER_TYPE_MONI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
<a th:class="${paperType == setting.PAPER_TYPE_MONI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '-' +courseId+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
</li>
<li class="contain-li">
<a th:class="${paperType == setting.PAPER_TYPE_YATI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
<a th:class="${paperType == setting.PAPER_TYPE_YATI} ? 'curr' : '' " th:href="${setting.domain + 'paperlist/' + subjectId + '-' +courseId+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
</li>
</ul>
</div>
@ -59,13 +59,13 @@
<span class="sub">科目:</span>
<ul class="sc-list clearfix">
<li th:class="${courseId == '0'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/0-' + paperType + '-' + year + '-' + area + '-1.html'}">
<a th:href="${setting.domain + 'paperlist' + '/' + subjectId + '-0-' + paperType + '-' + year + '-' + area + '-1.html'}">
全部
</a>
</li>
<li th:class="${c.uid == courseId} ? 'selected' : ''" th:each="c,cStat:${courseList}">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+c.uid+'-' + paperType + '-' + year + '-' + area + '-1.html'}" th:text="${c.name}">
<a th:href="${setting.domain + 'paperlist' + '/' + subjectId + '-' + c.uid+'-' + paperType + '-' + year + '-' + area + '-1.html'}" th:text="${c.name}">
理科数学
</a>
</li>
@ -75,19 +75,19 @@
<span class="sub">类型:</span>
<ul class="sc-list clearfix">
<li th:class="${paperType == '0'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-0-' + year + '-' + area + '-1.html'}">全部</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-0-' + year + '-' + area + '-1.html'}">全部</a>
</li>
<li th:class="${paperType == setting.PAPER_TYPE_ZHENTI} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_ZHENTI+'-' + year + '-' + area + '-1.html'}">真题试卷</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+setting.PAPER_TYPE_ZHENTI+'-' + year + '-' + area + '-1.html'}">真题试卷</a>
</li>
<li th:class="${paperType == setting.PAPER_TYPE_MONI} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_MONI+'-' + year + '-' + area + '-1.html'}">模拟试卷</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+setting.PAPER_TYPE_MONI+'-' + year + '-' + area + '-1.html'}">模拟试卷</a>
</li>
<li th:class="${paperType == setting.PAPER_TYPE_YATI} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_YATI+'-' + year + '-' + area + '-1.html'}">押题预测</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+setting.PAPER_TYPE_YATI+'-' + year + '-' + area + '-1.html'}">押题预测</a>
</li>
<li th:class="${paperType == setting.PAPER_TYPE_MINGXIAO} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+setting.PAPER_TYPE_MINGXIAO+'-' + year + '-' + area + '-1.html'}">名校精品</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+setting.PAPER_TYPE_MINGXIAO+'-' + year + '-' + area + '-1.html'}">名校精品</a>
</li>
</ul>
@ -96,22 +96,22 @@
<span class="sub">年份:</span>
<ul class="sc-list clearfix">
<li th:class="${year == '0'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-0-' + area + '-1.html'}">全部</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-0-' + area + '-1.html'}">全部</a>
</li>
<li th:class="${year == '2017'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-2017-' + area + '-1.html'}">2017</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-2017-' + area + '-1.html'}">2017</a>
</li>
<li th:class="${year == '2016'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-2016-' + area + '-1.html'}">2016</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-2016-' + area + '-1.html'}">2016</a>
</li>
<li th:class="${year == '2015'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-2015-' + area + '-1.html'}">2015</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-2015-' + area + '-1.html'}">2015</a>
</li>
<li th:class="${year == '2014'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-2014-' + area + '-1.html'}">2014</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-2014-' + area + '-1.html'}">2014</a>
</li>
<li th:class="${year == '2013'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-2013-' + area + '-1.html'}">2013</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-2013-' + area + '-1.html'}">2013</a>
</li>
</ul>
</div>
@ -119,11 +119,11 @@
<span class="sub">地区:</span>
<ul class="sc-list clearfix">
<li th:class="${area == '0'} ? 'selected' : ''">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-'+year+'-0-1.html'}">全部</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-'+year+'-0-1.html'}">全部</a>
</li>
<li th:class="${area == a.uid} ? 'selected' : ''" th:each="a,aStat:${areaList}">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-'+year+'-'+a.uid+'-1.html'}" th:text="${a.name}">北京</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-'+year+'-'+a.uid+'-1.html'}" th:text="${a.name}">北京</a>
</li>
</ul>
@ -159,15 +159,15 @@
<ul class="page-list">
<li class="page-num pre" th:if="${paperPage.isShowPreBtn}">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-'+year+'-' + area +'-1.html'}">&lt;</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-'+year+'-' + area +'-1.html'}">&lt;</a>
</li>
<li th:class="${paperPage.currPageNum == num} ? 'selected page-num' : 'page-num'" th:each="num,numStat:${paperPage.pageNums}">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-'+year+'-' + area +'-'+num+'.html'}" th:text="${num}">1</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId + '-' + courseId+'-'+paperType+'-'+year+'-' + area +'-'+num+'.html'}" th:text="${num}">1</a>
</li>
<li class="page-num next" th:if="${paperPage.isShowNextBtn}">
<a th:href="${setting.domain + 'paperlist/' + subjectId + '/'+courseId+'-'+paperType+'-'+year+'-' + area +'-'+(paperPage.currPageNum+1)+'.html'}">&gt;</a>
<a th:href="${setting.domain + 'paperlist/' + subjectId +'-' + courseId+'-'+paperType+'-'+year+'-' + area +'-'+(paperPage.currPageNum+1)+'.html'}">&gt;</a>
</li>
</ul>

@ -40,13 +40,13 @@
<a class="" th:href="${setting.domain + 'course/' +course.uid+ '.html'}">章节学习</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '/'+course.uid+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_ZHENTI+'-0-0-1.html'}">真题试卷</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '/'+course.uid+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_MONI+'-0-0-1.html'}">模拟试卷</a>
</li>
<li class="contain-li">
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '/'+course.uid+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
<a class="" th:href="${setting.domain + 'paperlist/' + subject.uid + '-'+course.uid+'-'+setting.PAPER_TYPE_YATI+'-0-0-1.html'}">考前押题</a>
</li>
</ul>
</div>

Loading…
Cancel
Save