Browse Source

新增网站地图开发

anderx 3 years ago
parent
commit
75b8daaf24

+ 5 - 2
src/main/java/com/kede/activity/service/Impl/ActivityServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import com.kede.activity.bo.InputActivity;
@@ -70,7 +71,9 @@ public class ActivityServiceImpl extends BaseMybatisDao<ActivityMapper> implemen
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<OutActivity> listDetails(InputActivity in, Integer pageSize, Integer pageNo) {Map<String, Object> params = new HashMap<>();
+	@Cacheable(cacheNames="listActivityDetails#600", key = "'listActivityDetails'+':ps='+#pageSize+'pn='+#pageNo")
+	public Pagination<OutActivity> listDetails(InputActivity in, Integer pageSize, Integer pageNo) {
+	Map<String, Object> params = new HashMap<>();
 	if(pageSize==null||pageSize<0)pageSize=10;
 	if(pageNo==null||pageNo<0)pageNo=1;
 	if(in.getTitle()!=null)params.put("title", in.getTitle());
@@ -92,7 +95,7 @@ public class ActivityServiceImpl extends BaseMybatisDao<ActivityMapper> implemen
 				new BusinessException("实体转换异常",e);
 			}
 		}
-		
+
 		return oa;
 	}
 

+ 8 - 6
src/main/java/com/kede/banners/service/impl/BannersServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import com.kede.banners.bo.InputBannerDetails;
@@ -15,19 +16,19 @@ import com.kede.core.mybatis.BaseMybatisDao;
 import com.kede.core.mybatis.page.Pagination;
 @Service
 public class BannersServiceImpl extends BaseMybatisDao<BannerDetailsMapper> implements BannersService {
-	
+
 	@Autowired
-	private BannerDetailsMapper	bannerDetailsMapper; 
-	
+	private BannerDetailsMapper	bannerDetailsMapper;
+
 	@Override
 	public int addBannersDetails(InputBannerDetails ibd) {
-		
+
 		return bannerDetailsMapper.insertSelective(ibd);
 	}
 
 	@Override
 	public int updateBannersDetails(InputBannerDetails ibd) {
-		
+
 		return  bannerDetailsMapper.updateByPrimaryKeySelective(ibd);
 	}
 
@@ -39,6 +40,7 @@ public class BannersServiceImpl extends BaseMybatisDao<BannerDetailsMapper> impl
 
 	@SuppressWarnings("unchecked")
 	@Override
+	@Cacheable(cacheNames="listBannersDetails#600", key = "'listBannersDetails'+':ps='+#pageSize+'pn='+#pageNo")
 	public Pagination<OutBannerDetails> listBannersDetails(InputBannerDetails ibd,Integer pageSize,Integer pageNo) {
 		Map<String, Object> params = new HashMap<>();
 		if(pageSize==null||pageSize<0)pageSize=10;
@@ -49,7 +51,7 @@ public class BannersServiceImpl extends BaseMybatisDao<BannerDetailsMapper> impl
 
 	@Override
 	public OutBannerDetails selectBannersDetails(InputBannerDetails ibd) {
-		
+
 		return bannerDetailsMapper.selectByid(ibd.getId());
 	}
 

+ 4 - 0
src/main/java/com/kede/common/controller/WebpageController.java

@@ -177,8 +177,12 @@ public class WebpageController extends BaseController {
 		o=list.size()>0?list.get(0):null;
 		modelview.addObject("banners",o);
 		InputNews inputNews = new InputNews();
+		inputNews.setHot(1l);
 		List<OutNews> news = (List<OutNews>) newsService.listnewsDetails(inputNews, 5, 1).getList();
 		modelview.addObject("news",news);
+		for (OutNews outNews : news) {
+			outNews.setContent(removeHtmlTag(outNews.getContent()));
+		}
 		return modelview;
 	}
 	/**

+ 74 - 0
src/main/java/com/kede/core/cache/serializer/ExtendedRedisCacheManager.java

@@ -0,0 +1,74 @@
+package com.kede.core.cache.serializer;
+
+import com.kede.common.utils.LoggerUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.springframework.data.redis.cache.RedisCache;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.core.RedisOperations;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+public class ExtendedRedisCacheManager extends RedisCacheManager {
+
+    private static final ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
+
+    private static final Pattern pattern = Pattern.compile("[+\\-*/%]");
+
+    /**
+     * 分隔符
+     */
+    private char separator = '#';
+
+    public ExtendedRedisCacheManager(RedisOperations redisOperations) {
+        super(redisOperations);
+    }
+
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected RedisCache createCache(String cacheName) {
+        // 获取默认时间
+        long expiration = computeExpiration(cacheName);
+        int index = cacheName.indexOf(this.getSeparator());
+        if (index > 0) {
+            expiration = getExpiration(cacheName, index, expiration);
+        }
+        LoggerUtils.debug(this.getClass(),cacheName+",缓存时间="+expiration);
+        return new RedisCache(cacheName, (isUsePrefix() ? getCachePrefix().prefix(cacheName) : null),
+                getRedisOperations(), expiration);
+    }
+
+    /**
+     * 计算缓存时间
+     * @param name 缓存名字 cache#60*60
+     * @param separatorIndex 分隔符位置
+     * @param defalutExp 默认缓存时间
+     * @return
+     */
+    protected long getExpiration(final String name, final int separatorIndex, final long defalutExp) {
+        Long expiration = null;
+        String expirationAsString = name.substring(separatorIndex + 1);
+        try {
+            if (pattern.matcher(expirationAsString).find()) {
+                expiration = NumberUtils.toLong(scriptEngine.eval(expirationAsString).toString(), defalutExp);
+            } else {
+                expiration = NumberUtils.toLong(expirationAsString, defalutExp);
+            }
+        } catch (ScriptException e) {
+            LoggerUtils.fmtError(this.getClass(),e,"缓存时间转换错误:{%s},异常:{%s}",name,e.getMessage());
+        }
+        return Objects.nonNull(expiration) ? expiration.longValue() : defalutExp;
+    }
+
+    public char getSeparator() {
+        return separator;
+    }
+
+    public void setSeparator(char separator) {
+        this.separator = separator;
+    }
+}

+ 4 - 0
src/main/java/com/kede/core/cache/serializer/FastJsonRedisSerializer.java

@@ -11,6 +11,10 @@ public class FastJsonRedisSerializer implements RedisSerializer<Object> {
 	public FastJsonRedisSerializer() {
 		ParserConfig pc = ParserConfig.getGlobalInstance();
 		pc.addAccept("com.kede.linksAndHot.bo");
+		pc.addAccept("com.kede.core.mybatis.page.Pagination");
+		pc.addAccept("com.kede.news.bo.OutNews");
+		pc.addAccept("com.kede.banners.bo.OutBannerDetails");
+		pc.addAccept("com.kede.activity.bo.OutActivity");
 	}
 
 	@Override

+ 46 - 1
src/main/java/com/kede/core/shiro/cache/ShiroRedisCacheManager.java

@@ -1,21 +1,66 @@
 package com.kede.core.shiro.cache;
 
+import com.kede.common.utils.LoggerUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.shiro.cache.AbstractCacheManager;
 import org.apache.shiro.cache.Cache;
 import org.apache.shiro.cache.CacheException;
 import org.springframework.data.redis.core.RedisTemplate;
 
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import java.util.Objects;
+import java.util.regex.Pattern;
+
 public class ShiroRedisCacheManager extends AbstractCacheManager {
 
 	private RedisTemplate<String, Object>	redisTemplate;
 
-	private long							expire	= -1l;	// 秒
+	private long							expire	= 2592000l;	// 秒
+
+	private static final ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
+
+	private static final Pattern pattern = Pattern.compile("[+\\-*/%]");
+
+	/**
+	 * 分隔符
+	 */
+	private char separator = '#';
 
 	@Override
 	protected Cache<String, Object> createCache(String name) throws CacheException {
+		// 获取默认时间
+		long expiration = getExpire();
+		int index = name.indexOf(separator);
+		if (index > 0) {
+			expiration = getExpiration(name, index, expiration);
+		}
 		return new ShiroRedisCache(redisTemplate, name, expire);
 	}
 
+	/**
+	 * 计算缓存时间
+	 * @param name 缓存名字 cache#60*60
+	 * @param separatorIndex 分隔符位置
+	 * @param defalutExp 默认缓存时间
+	 * @return
+	 */
+	protected long getExpiration(final String name, final int separatorIndex, final long defalutExp) {
+		Long expiration = null;
+		String expirationAsString = name.substring(separatorIndex + 1);
+		try {
+			if (pattern.matcher(expirationAsString).find()) {
+				expiration = NumberUtils.toLong(scriptEngine.eval(expirationAsString).toString(), defalutExp);
+			} else {
+				expiration = NumberUtils.toLong(expirationAsString, defalutExp);
+			}
+		} catch (ScriptException e) {
+			LoggerUtils.fmtError(ShiroRedisCacheManager.class,e,"缓存时间转换错误:{},异常:{}", name, e.getMessage());
+		}
+		return Objects.nonNull(expiration) ? expiration.longValue() : defalutExp;
+	}
+
 	public RedisTemplate<String, Object> getRedisTemplate() {
 		return redisTemplate;
 	}

+ 10 - 4
src/main/java/com/kede/news/service/impl/NewsServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import com.kede.common.constant.AFTConstants;
@@ -67,6 +68,8 @@ public class NewsServiceImpl extends BaseMybatisDao<NewsMapper> implements NewsS
 
 	@SuppressWarnings("unchecked")
 	@Override
+	@Cacheable(cacheNames="listnewsDetails#600", key = "'listnewsDetails'+':ps='+#pageSize+'pn='+#pageNo+'hot='+#in.hot+'type" +
+			"='+#in.type+'title'+#in.title")
 	public Pagination<OutNews> listnewsDetails(InputNews in, Integer pageSize, Integer pageNo) {
 		Map<String, Object> params = new HashMap<>();
 		if(pageSize==null||pageSize<0)pageSize=10;
@@ -82,10 +85,13 @@ public class NewsServiceImpl extends BaseMybatisDao<NewsMapper> implements NewsS
 
 	@Override
 	public OutNews addHotelectNews(InputNews in) {
-		OutNews outNews = newsMapper.selectByid(in.getId());
-		outNews.setHot(outNews.getHot()+1);
-		newsMapper.updateByPrimaryKeySelective(outNews);
-		return outNews;
+		OutNews use = newsMapper.selectByid(in.getId());
+		OutNews newNews=new OutNews();
+		newNews.setId(use.getId());
+		newNews.setHot(use.getHot()+1);
+		newsMapper.updateByPrimaryKeySelective(newNews);
+		use.setHot(use.getHot()+1);
+		return use;
 	}
 
 }

+ 1 - 1
src/main/resources/spring/spring-shiro.xml

@@ -33,7 +33,7 @@
 		<constructor-arg index="0" ref="redisConnectionFactory" />
 	</bean>
 
-	<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
+	<bean id="cacheManager" class="com.kede.core.cache.serializer.ExtendedRedisCacheManager">
 		<constructor-arg index="0" ref="redisTemplate" />
 		<property name="defaultExpiration" value="86400" />
 	</bean>

+ 6 - 0
src/main/webapp/WEB-INF/views/portal/about.html

@@ -970,6 +970,12 @@
                 $(".about-kede-secodn > div > ul > li").eq(1).click()
             }else if(window.location.search == "?qggs") {
                 $(".about-kede-secodn > div > ul > li").eq(4).click()
+            }else if(window.location.search == "?tdhd") {
+                $(".about-kede-secodn > div > ul > li").eq(2).click()
+            }else if(window.location.search == "?kdjj") {
+                $(".about-kede-secodn > div > ul > li").eq(0).click()
+            }else if(window.location.search == "?jrwm") {
+                $(".about-kede-secodn > div > ul > li").eq(6).click()
             }
             jobs()
         </script>

+ 132 - 23
src/main/webapp/WEB-INF/views/portal/htmlmap.html

@@ -27,41 +27,150 @@
     </header>
 
     <!-- 主体内容 -->
-    <div class="news main">
+    <div class="htmlmap main">
       <div class="container">
-        <div class="newmain">
-          <!-- 新闻列表 -->
-          <ul class="newslist" style="width: 100%;">
-            <li th:each="y:${news}">
-              <a target='_blank' th:href="${'/news/'+y.id}">
-                <div class=news-item>
-                  <div>
-                    <img th:src="${avatarUploadHost+y.pictureUrl}" />
-                  </div>
-                  <div>
-                    <h6 th:text="${y.title}">咨询行业2020迎来新转机!!!</h6>
-                    <span th:text="${y.releaseTimeConvert}">11-07</span>
-                    <div th:utext="${y.content}"></div>
-                  </div>
-                </div>
-              </a>
-            </li>
+        <div class="product-map">
+          <h4>科德集团</h4>
+          <div class="mapbutton">
+            <a th:href="${basePath+ '/'}">
+              <div class="mbitems">首页</div>
+            </a>
+            <a th:href="${basePath+'/service/gqpy?0'}">
+              <div class="mbitems">产品中心</div>
+            </a>
+            <a th:href="${basePath+'/strategic'}">
+              <div class="mbitems">战略合作</div>
+            </a>
+            <a th:href="${basePath+'/client'}">
+              <div class="mbitems">服务客户</div>
+            </a>
+            <a th:href="${basePath+'/news'}">
+              <div class="mbitems">新闻动态</div>
+            </a>
+            <a th:href="${basePath+'/about'}">
+              <div class="mbitems">关于科德</div>
+            </a>
+            <a th:href="${basePath+'/contactUs'}">
+              <div class="mbitems">联系我们</div>
+            </a>
+          </div>
+        </div>
+        <div class="product-map">
+          <h4>产品中心</h4>
+          <ul>
+            <a th:href="${basePath+'/service/jszy?0'}">
+              <li>
+                <span class="iconfont icon-dc-icon-jishuzhuanyi m-fontsiz"></span>
+                <h6>技术转移</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/gqpy?1'}">
+              <li>
+                <span class="iconfont icon-diannao-shuju m-fontsiz"></span>
+                <h6>高企认定</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/zscq?0'}">
+              <li>
+                <span class="iconfont icon-zhishichanquan m-fontsiz"></span>
+                <h6>知识产权</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/zczx?0'}">
+              <li>
+                <span class="iconfont icon-V m-fontsiz"></span>
+                <h6>政策咨询</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/csfw?0'}">
+              <li>
+                <span class="iconfont icon-caiwu m-fontsiz"></span>
+                <h6>财务管理体系</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/txrz?0'}">
+              <li>
+                <span class="iconfont icon-renzhengpeizhi m-fontsiz"></span>
+                <h6>体系认证</h6>
+              </li>
+            </a>
+            <a th:href="${basePath+'/service/kfpt?0'}">
+              <li>
+                <span class="iconfont icon-pingtaiguanlizhujiguanli m-fontsiz"></span>
+                <h6>平台开发建设</h6>
+              </li>
+            </a>
           </ul>
         </div>
+        <div class="product-map">
+          <h4>关于科德</h4>
+          <div class="aboutlist">
+            <a th:href="${basePath+ '/about?kdjj'}">
+              <div class="aitems">科德简介</div>
+            </a>
+            <a th:href="${basePath+ '/about?qywh'}">
+              <div class="aitems">科德文化</div>
+            </a>
+            <a th:href="${basePath+ '/about/tdhd'}">
+              <div class="aitems">团队活动</div>
+            </a>
+            <a th:href="${basePath+ '/about?ryzz'}">
+              <div class="aitems">科德资质</div>
+            </a>
+            <a th:href="${basePath+ '/about?qggs'}">
+              <div class="aitems">科德子公司</div>
+            </a>
+            <a th:href="${basePath+ '/about?fzlc'}">
+              <div class="aitems">发展历程</div>
+            </a>
+            <a th:href="${basePath+ '/about?jrwm'}">
+              <div class="aitems">加入我们</div>
+            </a>
+          </div>
+        </div>
+        <div class="maptext">
+          <a th:href="${basePath+ '/'}">科德集团</a>
+          致力于帮助企业客户提供
+          <a th:href="${basePath+ '/service/gqpy?2'}">高新认定服务</a>、
+          <a th:href="${basePath+ '/service/jszy?0'}">技术转移</a>、
+          <a th:href="${basePath+ '/service/zscq?0'}">知识产权运营</a>、
+          <a th:href="${basePath+ '/service/zczx?0'}">政策咨询</a>、
+          <a th:href="${basePath+ '/service/csfw?0'}">财务管理体系咨询</a>、
+          <a th:href="${basePath+ '/service/kfpt?0'}">平台开发建设</a>、
+          <a th:href="${basePath+ '/service/jmkj?0'}">武器装备资质咨询</a>、
+          服务等全面解决方案。
+        </div>
+        <div class="product-map">
+          <h4>新闻动态</h4>
+          <div class="newmain">
+            <!-- 新闻列表 -->
+            <ul class="newslist" style="width: 100%;">
+              <li th:each="y:${news}">
+                <a target='_blank' th:href="${'/news/'+y.id}">
+                  <div class=news-item>
+                    <div style="width: 30%;">
+                      <img th:src="${avatarUploadHost+y.pictureUrl}" />
+                    </div>
+                    <div style="width: 70%;">
+                      <h6 th:text="${y.title}">咨询行业2020迎来新转机!!!</h6>
+                      <span th:text="${y.releaseTimeConvert}">11-07</span>
+                      <div th:utext="${y.content}"></div>
+                    </div>
+                  </div>
+                </a>
+              </li>
+            </ul>
+          </div>
+        </div>
       </div>
     </div>
 
-
-
     <!-- 底部 -->
     <footer>
       <div th:replace="common::copyright('')"></div>
     </footer>
     <!-- 底部  end -->
   </div>
-<!--  <div th:replace="common::footer({},'')">-->
-
-<!--  </div>-->
 </body>
 
 </html>

+ 1 - 1
src/main/webapp/WEB-INF/views/portal/index.html

@@ -51,7 +51,7 @@
                 <div class="tp-banner-item">
                     <em class="iconfont icon-loufang"></em>
                     <div>
-                        <span>科德华咨</span>
+                        <span>科德集团</span>
                         <p>创建于2001年</p>
                     </div>
                 </div>