Permalink
Browse files

新增内容推荐统计,将所有统计重定向http状态改为301永久重定向

  • Loading branch information...
1 parent 3255118 commit 1cb8d4c30315b68164cad61d2d2ff9e7a74176f4 kerneler committed Apr 6, 2016
View
@@ -0,0 +1 @@
+*.js linguist-language=Java
View
@@ -1,17 +1,50 @@
#PublicCMS 2016
-请注意这是个还未完善的版本,请暂时不要用于正式项目,请等待正式发布的版本。
-
-该版本仅用于技术人员测试、学习与完善PublicCMS新版本
-
-欢迎各位参与到PublicCMS后面的开发中,目前有以下主要工作需要做:
-
-1. 前台站点的建设
-
-2. 文档的完善与更新
-
-3. 后台模板编辑在线帮助文档与示例
-
-4. 后台bug发现与修复
-
-其他需求请参考Issues
+请注意这是个还未完善的版本,请暂时不要用于正式项目,请等待正式发布的版本。该版本仅用于技术人员测试、学习与完善PublicCMS新版本
+
+欢迎各位参与到PublicCMS后面的开发中:
+
+新增功能:
+1. 新增动态模板在线编辑功能
+1. 新增内容推荐
+1. 新增内容附件列表
+1. 新增内容移动功能
+1. 新增内容刷新功能
+1. 新增分类移动功能
+1. 新增分类生成多页功能
+1. 新增分类标签类型管理
+1. 新增分类SEO优化设置
+1. 新增页面元数据扩展功能
+1. 新增支持FreeMarker与HTML语法混合的模板编辑器
+1. 新增动态页面管理功能
+1. 新增推荐位数据扩展功能
+1. 新增动态模板可接受参数配置功能
+1. 新增用户登录授权管理功能
+1. 新增部门数据权限功能:页面权限,分类权限
+1. 新增角色只读权功能,修复权限授权bug
+1. 新FTP服务、FTP用户在线管理功能
+1. 新增动态域名绑定管理功能
+1. 新增站点管理功能
+1. 新增分类,模块等排序功能
+1. 新增应用授权功能
+1. 新增定制接口及测试页面
+1. 新增客户端管理
+
+优化修改:
+1. 任务计划脚本改为文件
+1. 推荐位数据改为数据库存储
+1. UI列表样式修改,性能优化
+1. UI美观度提升,图标优化
+1. 模板与工程彻底分离
+1. 登陆超时改为弹出登陆对话框
+1. 指令简化
+
+待完成任务:
+1. 插件管理
+1. 抽奖管理
+1. 抽奖用户管理
+1. 投票管理
+1. 推荐位前台投稿
+1. 内容前台投稿
+1. 用户注册
+1. 用户评论集成
@@ -14,7 +14,7 @@ <h2 class="contentTitle">已推荐到</h2>
</#list>
<@_content ids=t.contentIds!><#assign contentMap=map!/></@_content>
<#list page.list as a>
- <a href="${contentMap[a.contentId?string].url!}" target="_blank">${contentMap[a.contentId?string].title}</a><br/>
+ <a href="${contentMap[a.contentId?string].url!}" target="_blank">${contentMap[a.contentId?string].title}</a> (${a.clicks})<br/>
</#list>
</p>
</@_contentRelatedList>
@@ -30,8 +30,7 @@ <h2 class="contentTitle">已推荐到</h2>
</p>
<p>
<#list page.list as a>
-
- ${a.path?a.path?last_index_of('/')} <@_metadata path='include'+a.path type='static'>${(object.alias)!}</@_metadata><br/>
+ ${a.path[0..a.path?last_index_of('/')]}<@_metadata path='include'+a.path type='static'>${(object.alias)!}</@_metadata> (${a.clicks})<br/>
</#list>
</p>
</@_pageDataList>
@@ -47,7 +46,7 @@ <h2 class="contentTitle">已推荐到</h2>
</p>
<p>
<#list page.list as a>
- ${a.path} <@_metadata path='include'+a.path type='dynamic'>${(object.alias)!}</@_metadata><br/>
+ ${a.path[0..a.path?last_index_of('/')]}<@_metadata path='include'+a.path type='dynamic'>${(object.alias)!}</@_metadata> (${a.clicks})<br/>
</#list>
</p>
</@_pageDataList>
@@ -51,7 +51,7 @@
<#list page.list>
<ul>
<#items as a>
- <li><a href="${a.url!}" target="_blank">${a.title}</a></li>
+ <li><a href="${site.dynamicPath}page/redirect.do?id=${a.id!}" target="_blank">${a.title}</a></li>
</#items>
</ul>
</#list>
@@ -8,8 +8,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.publiccms.logic.service.cms.CmsContentRelatedService;
import com.publiccms.logic.service.cms.CmsContentService;
import com.publiccms.logic.service.cms.CmsPageDataService;
+import com.publiccms.views.pojo.CmsContentRelatedStatistics;
import com.publiccms.views.pojo.CmsContentStatistics;
import com.publiccms.views.pojo.CmsPageDataStatistics;
import com.sanluan.common.base.Base;
@@ -21,9 +23,13 @@
private static Map<Integer, CmsContentStatistics> cachedMap = new HashMap<Integer, CmsContentStatistics>();
private static List<Integer> placeCachedlist = new ArrayList<Integer>();
private static Map<Integer, CmsPageDataStatistics> placeCachedMap = new HashMap<Integer, CmsPageDataStatistics>();
+ private static List<Integer> relatedCachedlist = new ArrayList<Integer>();
+ private static Map<Integer, CmsContentRelatedStatistics> relatedCachedMap = new HashMap<Integer, CmsContentRelatedStatistics>();
@Autowired
private CmsContentService contentService;
@Autowired
+ private CmsContentRelatedService contentRelatedService;
+ @Autowired
private CmsPageDataService pageDataService;
private void clearCache(int size) {
@@ -46,6 +52,29 @@ private void clearPlaceCache(int size) {
}
}
+ private void clearRelatedCache(int size) {
+ if (size < relatedCachedlist.size()) {
+ List<CmsContentRelatedStatistics> list = new ArrayList<CmsContentRelatedStatistics>();
+ for (int i = 0; i < size / 10; i++) {
+ list.add(relatedCachedMap.remove(relatedCachedlist.remove(0)));
+ }
+ contentRelatedService.updateStatistics(list);
+ }
+ }
+
+ public CmsContentRelatedStatistics relatedClicks(Integer id) {
+ CmsContentRelatedStatistics contentRelatedStatistics = relatedCachedMap.get(id);
+ if (empty(contentRelatedStatistics)) {
+ clearRelatedCache(100);
+ contentRelatedStatistics = new CmsContentRelatedStatistics(id, 1, contentRelatedService.getEntity(id));
+ relatedCachedlist.add(id);
+ } else {
+ contentRelatedStatistics.setClicks(contentRelatedStatistics.getClicks() + 1);
+ }
+ relatedCachedMap.put(id, contentRelatedStatistics);
+ return contentRelatedStatistics;
+ }
+
public CmsPageDataStatistics placeClicks(Integer id) {
CmsPageDataStatistics pageDataStatistics = placeCachedMap.get(id);
if (empty(pageDataStatistics)) {
@@ -103,6 +132,9 @@ public void clear() {
pageDataService.updateStatistics(placeCachedMap.values());
placeCachedlist.clear();
placeCachedMap.clear();
+ contentRelatedService.updateStatistics(relatedCachedMap.values());
+ relatedCachedlist.clear();
+ relatedCachedMap.clear();
contentService.updateStatistics(cachedMap.values());
cachedlist.clear();
cachedMap.clear();
@@ -22,11 +22,6 @@
@Transactional
public class CmsCategoryModelService extends BaseService<CmsCategoryModel> {
- @Autowired
- private CmsCategoryModelDao dao;
- @Autowired
- private CmsModelDao modelDao;
-
@Transactional(readOnly = true)
public PageHandler getPage(Integer modelId, Integer categoryId, Integer pageIndex, Integer pageSize) {
return dao.getPage(modelId,categoryId, pageIndex, pageSize);
@@ -65,4 +60,9 @@ public void updateCategoryModel(boolean flag, Integer categoryId, CmsModel model
public CmsCategoryModel getEntity(int modelId, int categoryId) {
return dao.getEntity(modelId, categoryId);
}
+
+ @Autowired
+ private CmsCategoryModelDao dao;
+ @Autowired
+ private CmsModelDao modelDao;
}
@@ -18,11 +18,6 @@
@Transactional
public class CmsCategoryService extends BaseService<CmsCategory> {
- @Autowired
- private CmsCategoryDao dao;
- @Autowired
- private LogOperateDao logOperateDao;
-
@Transactional(readOnly = true)
public PageHandler getPage(Integer siteId, Integer parentId, Integer typeId, Boolean allowContribute, Boolean hidden,
Boolean disabled, Integer pageIndex, Integer pageSize) {
@@ -140,4 +135,9 @@ public void updateContents(Serializable id, int num) {
entity.setContents(entity.getContents() + num);
}
}
+
+ @Autowired
+ private CmsCategoryDao dao;
+ @Autowired
+ private LogOperateDao logOperateDao;
}
@@ -15,9 +15,6 @@
@Transactional
public class CmsContentAttributeService extends BaseService<CmsContentAttribute> {
- @Autowired
- private CmsContentAttributeDao dao;
-
@Transactional(readOnly = true)
public PageHandler getPage(Integer pageIndex, Integer pageSize) {
return dao.getPage(pageIndex, pageSize);
@@ -38,4 +35,7 @@ public void updateAttribute(Integer contentId, CmsContentAttribute entity) {
}
}
}
+
+ @Autowired
+ private CmsContentAttributeDao dao;
}
@@ -19,9 +19,6 @@
@Transactional
public class CmsContentFileService extends BaseService<CmsContentFile> {
- @Autowired
- private CmsContentFileDao dao;
-
@Transactional(readOnly = true)
public PageHandler getPage(Integer contentId, Integer userId, Boolean image, String orderField, String orderType,
Integer pageIndex, Integer pageSize) {
@@ -60,4 +57,7 @@ public void update(int contentId, List<CmsContentFile> files, List<CmsContentFil
}
}
}
+
+ @Autowired
+ private CmsContentFileDao dao;
}
@@ -2,6 +2,7 @@
// Generated 2016-1-25 10:53:21 by com.sanluan.common.source.SourceMaker
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -12,22 +13,29 @@
import com.publiccms.entities.cms.CmsContentRelated;
import com.publiccms.logic.dao.cms.CmsContentRelatedDao;
+import com.publiccms.views.pojo.CmsContentRelatedStatistics;
import com.sanluan.common.base.BaseService;
import com.sanluan.common.handler.PageHandler;
@Service
@Transactional
public class CmsContentRelatedService extends BaseService<CmsContentRelated> {
- @Autowired
- private CmsContentRelatedDao dao;
-
@Transactional(readOnly = true)
public PageHandler getPage(Integer contentId, Integer relatedContentId, Integer userId, String orderField, String orderType,
Integer pageIndex, Integer pageSize) {
return dao.getPage(contentId, relatedContentId, userId, orderField, orderType, pageIndex, pageSize);
}
+ public void updateStatistics(Collection<CmsContentRelatedStatistics> entitys) {
+ for (CmsContentRelatedStatistics contentRelatedStatistics : entitys) {
+ CmsContentRelated entity = getEntity(contentRelatedStatistics.getId());
+ if (notEmpty(entity)) {
+ entity.setClicks(entity.getClicks() + contentRelatedStatistics.getClicks());
+ }
+ }
+ }
+
@SuppressWarnings("unchecked")
public void update(int contentId, List<CmsContentRelated> entitys) {
Set<Integer> idList = new HashSet<Integer>();
@@ -49,4 +57,7 @@ public void update(int contentId, List<CmsContentRelated> entitys) {
}
}
}
+
+ @Autowired
+ private CmsContentRelatedDao dao;
}
@@ -11,6 +11,7 @@
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,7 @@
import com.publiccms.logic.service.sys.SysExtendFieldService;
import com.publiccms.logic.service.sys.SysExtendService;
import com.publiccms.views.pojo.CmsContentParamters;
+import com.publiccms.views.pojo.CmsContentRelatedStatistics;
import com.publiccms.views.pojo.CmsContentStatistics;
/**
@@ -184,19 +186,36 @@ public MappingJacksonValue save(CmsContent entity, CmsContentAttribute attribute
}
/**
+ * 内容推荐重定向并计数
+ *
+ * @param id
+ * @return
+ */
+ @RequestMapping("related/redirect")
+ public void relatedRedirect(Integer id, HttpServletRequest request, HttpServletResponse response) {
+ CmsContentRelatedStatistics contentRelatedStatistics = statisticsComponent.relatedClicks(id);
+ SysSite site = getSite(request);
+ if (notEmpty(contentRelatedStatistics.getEntity())) {
+ redirectPermanently(response, contentRelatedStatistics.getEntity().getUrl());
+ } else {
+ redirectPermanently(response, site.getSitePath());
+ }
+ }
+
+ /**
* 内容链接重定向并计数
*
* @param id
* @return
*/
@RequestMapping("redirect")
- public String clicks(Integer id, HttpServletRequest request) {
+ public void redirect(Integer id, HttpServletRequest request, HttpServletResponse response) {
CmsContentStatistics contentStatistics = statisticsComponent.clicks(id);
SysSite site = getSite(request);
if (notEmpty(contentStatistics.getEntity()) && site.getId() == contentStatistics.getEntity().getSiteId()) {
- return REDIRECT + contentStatistics.getEntity().getUrl();
+ redirectPermanently(response, contentStatistics.getEntity().getUrl());
} else {
- return REDIRECT + site.getSitePath();
+ redirectPermanently(response, site.getSitePath());
}
}
@@ -4,6 +4,7 @@
import static com.sanluan.common.tools.RequestUtils.getIpAddress;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
@@ -81,13 +82,13 @@ public MappingJacksonValue save(CmsPageData entity, @ModelAttribute CmsPageDataP
* @return
*/
@RequestMapping("redirect")
- public String clicks(Integer id, HttpServletRequest request) {
+ public void clicks(Integer id, HttpServletRequest request, HttpServletResponse response) {
SysSite site = getSite(request);
CmsPageDataStatistics pageDataStatistics = statisticsComponent.placeClicks(id);
if (notEmpty(pageDataStatistics.getEntity()) && site.getId() == pageDataStatistics.getEntity().getSiteId()) {
- return REDIRECT + pageDataStatistics.getEntity().getUrl();
+ redirectPermanently(response, pageDataStatistics.getEntity().getUrl());
} else {
- return REDIRECT + site.getSitePath();
+ redirectPermanently(response, site.getSitePath());
}
}
}
Oops, something went wrong.

0 comments on commit 1cb8d4c

Please sign in to comment.