Search in sources :

Example 1 with CmsPlaceStatistics

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();
    }
}
Also used : CmsPlaceStatistics(com.publiccms.views.pojo.entities.CmsPlaceStatistics) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CmsPlaceStatistics

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());
    }
}
Also used : CmsPlaceStatistics(com.publiccms.views.pojo.entities.CmsPlaceStatistics) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CmsPlaceStatistics

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;
    }
}
Also used : CmsPlaceStatistics(com.publiccms.views.pojo.entities.CmsPlaceStatistics)

Aggregations

CmsPlaceStatistics (com.publiccms.views.pojo.entities.CmsPlaceStatistics)3 SysSite (com.publiccms.entities.sys.SysSite)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2