main
tamguo 7 years ago
parent a62b954ea2
commit f54f6d0f50

@ -24,8 +24,7 @@ public class AdServiceService extends ServiceImpl<AdMapper, AdEntity> implements
@Override @Override
public List<AdEntity> findAll() { public List<AdEntity> findAll() {
List<AdEntity> adList = (List<AdEntity>) cacheService.getObject(SystemConstant.ALL_AD); List<AdEntity> adList = (List<AdEntity>) cacheService.getObject(SystemConstant.ALL_AD);
adList = null; if(adList == null){
if(adList == null || adList.isEmpty()){
adList = adMapper.selectList(Condition.EMPTY); adList = adMapper.selectList(Condition.EMPTY);
cacheService.setObject(SystemConstant.ALL_AD, adList , 2 * 60 * 60); cacheService.setObject(SystemConstant.ALL_AD, adList , 2 * 60 * 60);
} }

@ -25,7 +25,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
@Override @Override
public List<MenuEntity> findMenus() { public List<MenuEntity> findMenus() {
List<MenuEntity> menuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.INDEX_MENU)); List<MenuEntity> menuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.INDEX_MENU));
if (menuList == null || menuList.isEmpty()) { if (menuList == null) {
menuList = menuMapper.selectList(Condition.create().eq("parent_id", 1).eq("is_show", 1).orderDesc(Arrays.asList("orders"))); menuList = menuMapper.selectList(Condition.create().eq("parent_id", 1).eq("is_show", 1).orderDesc(Arrays.asList("orders")));
for(MenuEntity menu : menuList){ for(MenuEntity menu : menuList){
List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders"))); List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders")));
@ -40,7 +40,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
@Override @Override
public List<MenuEntity> findAllMenus() { public List<MenuEntity> findAllMenus() {
List<MenuEntity> allMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.ALL_INDEX_MENU)); List<MenuEntity> allMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.ALL_INDEX_MENU));
if(allMenuList == null || allMenuList.isEmpty()){ if(allMenuList == null){
allMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 1).orderDesc(Arrays.asList("orders"))); allMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 1).orderDesc(Arrays.asList("orders")));
for(MenuEntity menu : allMenuList){ for(MenuEntity menu : allMenuList){
List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders"))); List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders")));
@ -55,7 +55,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
@Override @Override
public List<MenuEntity> findLeftMenus() { public List<MenuEntity> findLeftMenus() {
List<MenuEntity> leftMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.LEFT_INDEX_MENU)); List<MenuEntity> leftMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.LEFT_INDEX_MENU));
if(leftMenuList == null || leftMenuList.isEmpty()){ if(leftMenuList == null){
leftMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 2).orderDesc(Arrays.asList("orders"))); leftMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 2).orderDesc(Arrays.asList("orders")));
for(MenuEntity menu : leftMenuList){ for(MenuEntity menu : leftMenuList){
List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders"))); List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders")));
@ -71,7 +71,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
@Override @Override
public List<MenuEntity> findChapterMenus() { public List<MenuEntity> findChapterMenus() {
List<MenuEntity> chapterMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.CHAPTER_INDEX_MENU)); List<MenuEntity> chapterMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.CHAPTER_INDEX_MENU));
if(chapterMenuList == null || chapterMenuList.isEmpty()){ if(chapterMenuList == null){
chapterMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 4).orderDesc(Arrays.asList("orders"))); chapterMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 4).orderDesc(Arrays.asList("orders")));
for(MenuEntity menu : chapterMenuList){ for(MenuEntity menu : chapterMenuList){
List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders"))); List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders")));
@ -87,8 +87,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
@Override @Override
public List<MenuEntity> findFooterMenus() { public List<MenuEntity> findFooterMenus() {
List<MenuEntity> footerMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.FOOTER_INDEX_MENU)); List<MenuEntity> footerMenuList = ((List<MenuEntity>) cacheService.getObject(SystemConstant.FOOTER_INDEX_MENU));
footerMenuList = null; if(footerMenuList == null){
if(footerMenuList == null || footerMenuList.isEmpty()){
footerMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 3).orderDesc(Arrays.asList("orders"))); footerMenuList = menuMapper.selectList(Condition.create().eq("parent_id", 3).orderDesc(Arrays.asList("orders")));
for(MenuEntity menu : footerMenuList){ for(MenuEntity menu : footerMenuList){
List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders"))); List<MenuEntity> childSubjects = menuMapper.selectList(Condition.create().eq("parent_id", menu.getId()).orderDesc(Arrays.asList("orders")));

@ -24,10 +24,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
@Override @Override
public List<PaperEntity> findHistoryPaper() { public List<PaperEntity> findHistoryPaper() {
List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HISTORY_PAPER); List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HISTORY_PAPER);
if(paperList == null || paperList.isEmpty()){ 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)); paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.HISTORY_PAPER).eq("area_id", SystemConstant.BEIJING_AREA_ID));
cacheService.setObject(SystemConstant.ZHENGTI_PAPER_ID, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.HISTORY_PAPER, paperList , 2 * 60 * 60);
} }
return paperList; return paperList;
} }
@ -36,9 +36,9 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
@Override @Override
public List<PaperEntity> findSimulationPaper() { public List<PaperEntity> findSimulationPaper() {
List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.SIMULATION_PAPER); List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.SIMULATION_PAPER);
if(paperList == null || paperList.isEmpty()){ 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)); paperList = paperMapper.selectPage(page, Condition.create().eq("type", SystemConstant.SIMULATION_PAPER).eq("area_id", SystemConstant.BEIJING_AREA_ID));
cacheService.setObject(SystemConstant.SIMULATION_PAPER, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.SIMULATION_PAPER, paperList , 2 * 60 * 60);
} }
return paperList; return paperList;
@ -48,8 +48,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
@Override @Override
public List<PaperEntity> findHotPaper(String areaId) { public List<PaperEntity> findHotPaper(String areaId) {
List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HOT_PAPER); List<PaperEntity> paperList = (List<PaperEntity>) cacheService.getObject(SystemConstant.HOT_PAPER);
paperList = null; if(paperList == null){
if(paperList == null || paperList.isEmpty()){
Page<PaperEntity> page = new Page<>(1 , 10); Page<PaperEntity> page = new Page<>(1 , 10);
paperList = paperMapper.selectPage(page, Condition.create().eq("area_id", areaId)); paperList = paperMapper.selectPage(page, Condition.create().eq("area_id", areaId));
cacheService.setObject(SystemConstant.HOT_PAPER, paperList , 2 * 60 * 60); cacheService.setObject(SystemConstant.HOT_PAPER, paperList , 2 * 60 * 60);

@ -34,7 +34,7 @@ public class SchoolService extends ServiceImpl<SchoolMapper, SchoolEntity> imple
public List<SchoolEntity> findEliteSchoolPaper(String shcoolId) { public List<SchoolEntity> findEliteSchoolPaper(String shcoolId) {
List<SchoolEntity> schoolList = (List<SchoolEntity>) cacheService.getObject(SystemConstant.ELITE_SCHOOL_PAPER); List<SchoolEntity> schoolList = (List<SchoolEntity>) cacheService.getObject(SystemConstant.ELITE_SCHOOL_PAPER);
// 获取名校试卷 // 获取名校试卷
if(schoolList == null || schoolList.isEmpty()){ if(schoolList == null){
Page<SchoolEntity> page = new Page<>(1 , 3); Page<SchoolEntity> page = new Page<>(1 , 3);
schoolList = schoolMapper.selectPage(page, Condition.create().eq("id", shcoolId)); schoolList = schoolMapper.selectPage(page, Condition.create().eq("id", shcoolId));
for(SchoolEntity school : schoolList){ for(SchoolEntity school : schoolList){
@ -51,7 +51,7 @@ public class SchoolService extends ServiceImpl<SchoolMapper, SchoolEntity> imple
@Override @Override
public List<SchoolEntity> findEliteSchool() { public List<SchoolEntity> findEliteSchool() {
List<SchoolEntity> schoolList = (List<SchoolEntity>) cacheService.getObject(SystemConstant.ELITE_PAPER); List<SchoolEntity> schoolList = (List<SchoolEntity>) cacheService.getObject(SystemConstant.ELITE_PAPER);
if(schoolList == null || schoolList.isEmpty()){ if(schoolList == null){
RowBounds row = new RowBounds(1 , 6); RowBounds row = new RowBounds(1 , 6);
schoolList = schoolMapper.selectPage(row, Condition.EMPTY); schoolList = schoolMapper.selectPage(row, Condition.EMPTY);
cacheService.setObject(SystemConstant.ELITE_PAPER, schoolList , 2 * 60 * 60); cacheService.setObject(SystemConstant.ELITE_PAPER, schoolList , 2 * 60 * 60);

@ -3,18 +3,30 @@ package com.tamguo.config.web;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.thymeleaf.spring5.view.ThymeleafViewResolver; import org.thymeleaf.spring5.view.ThymeleafViewResolver;
@Configuration @Component
public class ThymeleafConfig { public class ThymeleafConfig implements EnvironmentAware{
@Resource
private Environment env;
@Resource @Resource
private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) { private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) {
if(viewResolver != null) { if(viewResolver != null) {
Map<String, Object> vars = new HashMap<>(); Map<String, Object> vars = new HashMap<>();
vars.put("domainName", "http://localhost:8081/"); vars.put("domainName", env.getProperty("domain.name"));
viewResolver.setStaticVariables(vars); viewResolver.setStaticVariables(vars);
} }
} }
@Override
public void setEnvironment(Environment environment) {
env = environment;
}
} }

@ -32,7 +32,7 @@
</div> </div>
<div class="clearfix submenu-container" data-id="submenu"> <div class="clearfix submenu-container" data-id="submenu">
<div class="submenu clearfix" id="submenu" data-id="submenu"> <div class="submenu clearfix" id="submenu" data-id="submenu">
<ul th:class="${m.pinyin + ' subm-ul dis-none'}" th:each="m,mStat:${menuList}" data-id="submenu"> <ul th:class="${m.pinyin + ' subm-ul dis-none'}" th:each="m,mStat:${application.menuList}" data-id="submenu">
<li class="subm-li" th:each="c,cmStat:${m.childSubjects}"><a th:href="${domainName + c.url}" target="_blank" th:text="${c.name}">高考</a></li> <li class="subm-li" th:each="c,cmStat:${m.childSubjects}"><a th:href="${domainName + c.url}" target="_blank" th:text="${c.name}">高考</a></li>
</ul> </ul>
<div class="all-exm all dis-none" data-id="submenu"> <div class="all-exm all dis-none" data-id="submenu">

Loading…
Cancel
Save