use of com.publiccms.views.pojo.entities.CmsContentStatistics in project PublicCMS-preview by sanluan.
the class ContentController method contentRedirect.
/**
* 内容链接重定向并计数
*
* @param id
* @param request
* @param response
* @return view name
*/
@RequestMapping("redirect")
public String contentRedirect(Long id, HttpServletRequest request, HttpServletResponse response) {
CmsContentStatistics contentStatistics = statisticsComponent.clicks(id);
SysSite site = getSite(request);
if (null != contentStatistics && null != contentStatistics.getEntity() && site.getId() == contentStatistics.getEntity().getSiteId()) {
return REDIRECT + contentStatistics.getEntity().getUrl();
} else {
return REDIRECT + site.getDynamicPath();
}
}
use of com.publiccms.views.pojo.entities.CmsContentStatistics in project PublicCMS-preview by sanluan.
the class StatisticsComponent method clicks.
/**
* @param id
* @return content statistics
*/
public CmsContentStatistics clicks(Long id) {
if (CommonUtils.notEmpty(id)) {
CmsContentStatistics contentStatistics = contentCache.get(id);
if (null == contentStatistics) {
contentStatistics = new CmsContentStatistics(id, 1, 0, 0, contentService.getEntity(id));
} else {
contentStatistics.setClicks(contentStatistics.getClicks() + 1);
}
List<CmsContentStatistics> list = contentCache.put(id, contentStatistics);
if (CommonUtils.notEmpty(list)) {
contentService.updateStatistics(list);
}
return contentStatistics;
} else {
return null;
}
}
use of com.publiccms.views.pojo.entities.CmsContentStatistics in project PublicCMS-preview by sanluan.
the class CmsContentService method updateStatistics.
/**
* @param entitys
*/
public void updateStatistics(Collection<CmsContentStatistics> entitys) {
for (CmsContentStatistics entityStatistics : entitys) {
CmsContent entity = getEntity(entityStatistics.getId());
if (null != entity) {
entity.setClicks(entity.getClicks() + entityStatistics.getClicks());
entity.setComments(entity.getComments() + entityStatistics.getComments());
entity.setScores(entity.getScores() + entityStatistics.getScores());
}
}
}
use of com.publiccms.views.pojo.entities.CmsContentStatistics in project PublicCMS-preview by sanluan.
the class ContentClickDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
Long id = handler.getLong("id");
CmsContentStatistics contentStatistics = statisticsComponent.clicks(id);
if (null != contentStatistics && null != contentStatistics.getEntity()) {
handler.put("clicks", contentStatistics.getEntity().getClicks() + contentStatistics.getClicks());
}
}
Aggregations