use of com.publiccms.views.pojo.entities.CmsPlaceStatistics in project PublicCMS-preview by sanluan.
the class PlaceController method click.
/**
* @param id
* @param request
* @param response
* @return view name
*/
@RequestMapping("click")
public String click(Long id, HttpServletRequest request, HttpServletResponse response) {
SysSite site = getSite(request);
CmsPlaceStatistics placeStatistics = statisticsComponent.placeClicks(id);
if (null != placeStatistics && null != placeStatistics.getEntity() && site.getId() == placeStatistics.getEntity().getSiteId() && CommonUtils.notEmpty(placeStatistics.getEntity().getUrl())) {
return REDIRECT + placeStatistics.getEntity().getUrl();
} else {
return REDIRECT + site.getDynamicPath();
}
}
use of com.publiccms.views.pojo.entities.CmsPlaceStatistics in project PublicCMS-preview by sanluan.
the class PlaceController method redirect.
/**
* @param id
* @param request
* @param response
*/
@RequestMapping("redirect")
public void redirect(Long id, HttpServletRequest request, HttpServletResponse response) {
SysSite site = getSite(request);
CmsPlaceStatistics placeStatistics = statisticsComponent.placeClicks(id);
if (null != placeStatistics && null != placeStatistics.getEntity() && site.getId() == placeStatistics.getEntity().getSiteId() && CommonUtils.notEmpty(placeStatistics.getEntity().getUrl())) {
ControllerUtils.redirectPermanently(response, placeStatistics.getEntity().getUrl());
} else {
ControllerUtils.redirectPermanently(response, site.getDynamicPath());
}
}
use of com.publiccms.views.pojo.entities.CmsPlaceStatistics in project PublicCMS-preview by sanluan.
the class StatisticsComponent method placeClicks.
/**
* @param id
* @return place statistics
*/
public CmsPlaceStatistics placeClicks(Long id) {
if (CommonUtils.notEmpty(id)) {
CmsPlaceStatistics placeStatistics = placeCache.get(id);
if (null == placeStatistics) {
placeStatistics = new CmsPlaceStatistics(id, 1, placeService.getEntity(id));
} else {
placeStatistics.setClicks(placeStatistics.getClicks() + 1);
}
List<CmsPlaceStatistics> list = placeCache.put(id, placeStatistics);
if (CommonUtils.notEmpty(list)) {
placeService.updateStatistics(list);
}
return placeStatistics;
} else {
return null;
}
}
Aggregations