优化查询

main
tamguo 7 years ago
parent 81b1685a62
commit 3753dca7ab

@ -16,14 +16,23 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.common.utils.Result; import com.tamguo.common.utils.Result;
import com.tamguo.common.utils.SystemConstant; import com.tamguo.common.utils.SystemConstant;
import com.tamguo.config.redis.CacheService; import com.tamguo.config.redis.CacheService;
import com.tamguo.modules.sys.service.ISysAreaService;
import com.tamguo.modules.tiku.dao.PaperMapper; import com.tamguo.modules.tiku.dao.PaperMapper;
import com.tamguo.modules.tiku.dao.QuestionMapper; import com.tamguo.modules.tiku.dao.QuestionMapper;
import com.tamguo.modules.tiku.model.PaperEntity; import com.tamguo.modules.tiku.model.PaperEntity;
import com.tamguo.modules.tiku.service.ICourseService;
import com.tamguo.modules.tiku.service.IPaperService; import com.tamguo.modules.tiku.service.IPaperService;
import com.tamguo.modules.tiku.service.ISubjectService;
@Service @Service
public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> implements IPaperService{ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> implements IPaperService{
@Autowired
private ISubjectService iSubjectService;
@Autowired
private ICourseService iCourseService;
@Autowired
private ISysAreaService iSysAreaService;
@Autowired @Autowired
private PaperMapper paperMapper; private PaperMapper paperMapper;
@Autowired @Autowired
@ -37,7 +46,13 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HISTORY_PAPER); List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HISTORY_PAPER);
if(paperList == null){ if(paperList == null){
Page<PaperEntity> page = new Page<>(1 , 6); Page<PaperEntity> page = new Page<>(1 , 6);
paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.ZHENGTI_PAPER_ID).eq("area_id", SystemConstant.BEIJING_AREA_ID).orderDesc(Arrays.asList("id"))); paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.ZHENGTI_PAPER_ID).orderDesc(Arrays.asList("id")));
for(int i=0 ; i<paperList.size() ; i++) {
PaperEntity paper = paperList.get(i);
paper.setSubjectName(iSubjectService.selectById(paper.getSubjectId()).getName());
paper.setCourseName(iCourseService.selectById(paper.getCourseId()).getName());
paper.setAreaName(iSysAreaService.selectById(paper.getAreaId()).getAreaName());
}
cacheService.setObject(SystemConstant.HISTORY_PAPER, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.HISTORY_PAPER, paperList , 2 * 60 * 60);
} }
return paperList; return paperList;
@ -49,7 +64,13 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.SIMULATION_PAPER); List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.SIMULATION_PAPER);
if(paperList == null){ if(paperList == null){
Page<PaperEntity> page = new Page<>(1 , 6); Page<PaperEntity> page = new Page<>(1 , 6);
paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.MONI_PAPER_ID).eq("area_id", SystemConstant.BEIJING_AREA_ID).orderDesc(Arrays.asList("id"))); paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.MONI_PAPER_ID).orderDesc(Arrays.asList("id")));
for(int i=0 ; i<paperList.size() ; i++) {
PaperEntity paper = paperList.get(i);
paper.setSubjectName(iSubjectService.selectById(paper.getSubjectId()).getName());
paper.setCourseName(iCourseService.selectById(paper.getCourseId()).getName());
paper.setAreaName(iSysAreaService.selectById(paper.getAreaId()).getAreaName());
}
cacheService.setObject(SystemConstant.SIMULATION_PAPER, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.SIMULATION_PAPER, paperList , 2 * 60 * 60);
} }
return paperList; return paperList;
@ -62,6 +83,12 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
if(paperList == null){ if(paperList == null){
Page<PaperEntity> page = new Page<>(1 , 10); Page<PaperEntity> page = new Page<>(1 , 10);
paperList = paperMapper.selectPage(page, Condition.create().orderDesc(Arrays.asList("id"))); paperList = paperMapper.selectPage(page, Condition.create().orderDesc(Arrays.asList("id")));
for(int i=0 ; i<paperList.size() ; i++) {
PaperEntity paper = paperList.get(i);
paper.setSubjectName(iSubjectService.selectById(paper.getSubjectId()).getName());
paper.setCourseName(iCourseService.selectById(paper.getCourseId()).getName());
paper.setAreaName(iSysAreaService.selectById(paper.getAreaId()).getAreaName());
}
cacheService.setObject(SystemConstant.HOT_PAPER, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.HOT_PAPER, paperList , 2 * 60 * 60);
} }
return paperList; return paperList;
@ -160,4 +187,12 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return Result.result(Result.SUCCESS_CODE, paper, "修改成功"); return Result.result(Result.SUCCESS_CODE, paper, "修改成功");
} }
public ISubjectService getiSubjectService() {
return iSubjectService;
}
public void setiSubjectService(ISubjectService iSubjectService) {
this.iSubjectService = iSubjectService;
}
} }

@ -394,7 +394,7 @@ body.filter_show {
<!--房源列表--> <!--房源列表-->
<div class="mod_box house_lists"> <div class="mod_box house_lists">
<!--筛选条--> <!--筛选条-->
<div class="tab_bar flexbox" data-mark="booth"> <!-- <div class="tab_bar flexbox" data-mark="booth">
<div class="tab_tit box_col" data-mark="booth_area"> <div class="tab_tit box_col" data-mark="booth_area">
<h2 class="tit">科目</h2> <h2 class="tit">科目</h2>
<i class="icon_triangle_down"></i> <i class="icon_triangle_down"></i>
@ -408,7 +408,7 @@ body.filter_show {
<h2 class="tit">题目</h2> <h2 class="tit">题目</h2>
<i class="icon_triangle_down"></i> <i class="icon_triangle_down"></i>
</div> </div>
</div> </div> -->
<!--/筛选条--> <!--/筛选条-->
<div class="video-title" th:text="${paper.name}"> <div class="video-title" th:text="${paper.name}">
</div> </div>

@ -385,7 +385,7 @@ body.filter_show {
<!--房源列表--> <!--房源列表-->
<div class="mod_box house_lists"> <div class="mod_box house_lists">
<!--筛选条--> <!--筛选条-->
<div class="tab_bar flexbox" data-mark="booth"> <!-- <div class="tab_bar flexbox" data-mark="booth">
<div class="tab_tit box_col" data-mark="booth_area"> <div class="tab_tit box_col" data-mark="booth_area">
<h2 class="tit">科目</h2> <h2 class="tit">科目</h2>
<i class="icon_triangle_down"></i> <i class="icon_triangle_down"></i>
@ -399,7 +399,7 @@ body.filter_show {
<h2 class="tit">题目</h2> <h2 class="tit">题目</h2>
<i class="icon_triangle_down"></i> <i class="icon_triangle_down"></i>
</div> </div>
</div> </div> -->
<!--/筛选条--> <!--/筛选条-->
<div class="occupy" style="height: 89px; display: none;"></div> <div class="occupy" style="height: 89px; display: none;"></div>

@ -74,11 +74,11 @@
<div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div> <div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div>
<div class="tag_box"> <div class="tag_box">
<span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);" <span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);"
title="北京">北京</span> <span class="tag" th:title="${p.areaName}" th:text="${p.areaName}">北京</span> <span class="tag"
style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);" style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);"
title="真题">真题</span> <span class="tag" title="真题">真题</span> <span class="tag"
style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);" style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);"
title="理科数学">理科数学</span> th:title="${p.courseName}" th:text="${p.courseName}">理科数学</span>
</div> </div>
</div> </div>
</div> </div>
@ -106,11 +106,11 @@
<div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div> <div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div>
<div class="tag_box"> <div class="tag_box">
<span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);" <span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);"
title="北京">北京</span> <span class="tag" th:title="${p.areaName}" th:text="${p.areaName}">北京</span> <span class="tag"
style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);" style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);"
title="真题">真题</span> <span class="tag" title="真题">模拟</span> <span class="tag"
style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);" style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);"
title="理科数学">理科数学</span> th:title="${p.courseName}" th:text="${p.courseName}">理科数学</span>
</div> </div>
</div> </div>
</div> </div>
@ -127,7 +127,7 @@
data-ulog_search="ljweb_id=30001&amp;ljweb_mod=m_pages_homepage_recommend-ershoufang&amp;ljweb_bl=more&amp;ljweb_strategy_id=default" data-ulog_search="ljweb_id=30001&amp;ljweb_mod=m_pages_homepage_recommend-ershoufang&amp;ljweb_bl=more&amp;ljweb_strategy_id=default"
data-evtid_lazyaction="10889" data-evtid_lazyaction="10889"
data-ulog_lazyaction="recommend_module=m_ershou_shouye&amp;fb_service_id=100001&amp;fb_context_id={&quot;req_source_type&quot;:&quot;zhiying_m&quot;}&amp;fb_expo_id=r87474238291230720&amp;fb_strategy_id=10000076&amp;fb_item_type=ershou_house&amp;fb_item_detail=107000203369&amp;fb_item_location=1&amp;fb_ab_test_flag=reco_rule-100001-default-default&amp;fb_response_ts=1535591483&amp;fb_query_id=188971149" data-ulog_lazyaction="recommend_module=m_ershou_shouye&amp;fb_service_id=100001&amp;fb_context_id={&quot;req_source_type&quot;:&quot;zhiying_m&quot;}&amp;fb_expo_id=r87474238291230720&amp;fb_strategy_id=10000076&amp;fb_item_type=ershou_house&amp;fb_item_detail=107000203369&amp;fb_item_location=1&amp;fb_ab_test_flag=reco_rule-100001-default-default&amp;fb_response_ts=1535591483&amp;fb_query_id=188971149"
th:href="${domainName}">为您推荐模拟试卷<span class="gray right">更多</span></a> th:href="${domainName}">为您推荐热门试卷<span class="gray right">更多</span></a>
</h3> </h3>
<div class="mod_cont"> <div class="mod_cont">
<ul class="lists"> <ul class="lists">
@ -138,11 +138,11 @@
<div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div> <div class="item_main" th:text="${p.name}">理科数学 东城区2017年高三上学期期末考试</div>
<div class="tag_box"> <div class="tag_box">
<span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);" <span class="tag" style="color: rgb(242, 161, 47); background-color: rgba(242, 161, 47, 0.15);"
title="北京">北京</span> <span class="tag" th:title="${p.areaName}" th:text="${p.areaName}">北京</span> <span class="tag"
style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);" style="color: rgb(51, 190, 133); background-color: rgba(51, 190, 133, 0.15);"
title="真题">真题</span> <span class="tag" title="热门" th:text>热门</span> <span class="tag"
style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);" style="color: rgb(123, 189, 255); background-color: rgba(123, 189, 255, 0.15);"
title="理科数学">理科数学</span> th:title="${p.courseName}" th:text="${p.courseName}">理科数学</span>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save