Search in sources :

Example 6 with PageHandler

use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.

the class SysModuleListDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Boolean menu = null;
    if (!handler.getBoolean("advanced", false)) {
        menu = handler.getBoolean("menu", true);
    }
    PageHandler page = service.getPage(handler.getInteger("parentId"), menu, handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
    handler.put("page", page).render();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler)

Example 7 with PageHandler

use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.

the class SysSiteListDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Boolean disabled = false;
    if (handler.getBoolean("advanced", false)) {
        disabled = handler.getBoolean("disabled", false);
    }
    PageHandler page = service.getPage(disabled, handler.getString("name"), handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
    handler.put("page", page).render();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler)

Example 8 with PageHandler

use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.

the class UeditorAdminController method listfile.

/**
 * @param start
 * @param request
 * @param session
 * @return view name
 */
@SuppressWarnings("unchecked")
@RequestMapping(params = "action=" + ACTION_LISTFILE)
@ResponseBody
public Map<String, Object> listfile(Integer start, HttpServletRequest request, HttpSession session) {
    if (CommonUtils.empty(start)) {
        start = 0;
    }
    PageHandler page = logUploadService.getPage(getSite(request).getId(), getAdminFromSession(session).getId(), null, null, null, null, null, start / 20 + 1, 20);
    Map<String, Object> map = getResultMap(true);
    List<Map<String, Object>> list = new ArrayList<>();
    for (LogUpload logUpload : ((List<LogUpload>) page.getList())) {
        Map<String, Object> tempMap = getResultMap(true);
        tempMap.put("url", logUpload.getFilePath());
        list.add(tempMap);
    }
    map.put("list", list);
    map.put("start", start);
    map.put("total", page.getTotalCount());
    return map;
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) ArrayList(java.util.ArrayList) LogUpload(com.publiccms.entities.log.LogUpload) HashMap(java.util.HashMap) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with PageHandler

use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.

the class ClusterComponent method heartbeat.

/**
 * 每分钟心跳一次
 */
@SuppressWarnings("unchecked")
@Scheduled(fixedDelay = THEARTBEAT_INTERVAL)
public void heartbeat() {
    if (CmsVersion.isInitialized()) {
        SysCluster entity = service.getEntity(CmsVersion.getClusterId());
        Date now = CommonUtils.getDate();
        Date lastHeartbeatDate = null;
        if (null == entity) {
            entity = new SysCluster(CmsVersion.getClusterId(), now, now, false, CmsVersion.getVersion());
            service.save(entity);
        } else {
            lastHeartbeatDate = entity.getHeartbeatDate();
        }
        service.updateHeartbeatDate(CmsVersion.getClusterId(), now);
        if (CmsVersion.isMaster() != entity.isMaster()) {
            CmsVersion.setMaster(entity.isMaster());
        }
        Date acceptTeartbeatDate = new Date(now.getTime() - (2 * THEARTBEAT_INTERVAL));
        if (entity.isMaster()) {
            PageHandler page = service.getPage(null, acceptTeartbeatDate, false, null, null, null, null);
            for (SysCluster cluster : (List<SysCluster>) page.getList()) {
                service.delete(cluster.getUuid());
            }
        } else {
            PageHandler page = service.getPage(null, null, true, "heartbeatDate", "desc", null, null);
            if (page.getTotalCount() == 0) {
                upgrade();
            } else if (page.getTotalCount() == 1) {
                SysCluster master = (SysCluster) page.getList().get(0);
                if (acceptTeartbeatDate.after(master.getHeartbeatDate())) {
                    upgrade();
                    service.delete(master.getUuid());
                }
            } else {
                boolean skip = false;
                for (SysCluster cluster : (List<SysCluster>) page.getList()) {
                    if (skip) {
                        service.updateMaster(cluster.getUuid(), false);
                    } else {
                        skip = true;
                    }
                }
            }
        }
        scheduledTask.init(lastHeartbeatDate);
    }
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) List(java.util.List) Date(java.util.Date) SysCluster(com.publiccms.entities.sys.SysCluster) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 10 with PageHandler

use of com.publiccms.common.handler.PageHandler in project PublicCMS-preview by sanluan.

the class LotteryStatusDirective method execute.

@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
    Long lotteryId = handler.getLong("lotteryId");
    CmsLottery lottery = lotteryService.getEntity(lotteryId);
    SysSite site = getSite(handler);
    if (null != lottery && site.getId() == lottery.getSiteId() && !lottery.isDisabled()) {
        if (lotteryUserService.getPage(lotteryId, user.getId(), true, null, null, null, null, null).getTotalCount() == 0) {
            handler.put("winning", false);
            PageHandler page = lotteryUserService.getPage(lotteryId, user.getId(), null, null, null, null, null, null);
            handler.put("lastCount", lottery.getLotteryCount() - page.getTotalCount());
        } else {
            handler.put("winning", true);
        }
    } else {
        handler.put("error", true);
    }
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) CmsLottery(com.publiccms.entities.cms.CmsLottery) SysSite(com.publiccms.entities.sys.SysSite)

Aggregations

PageHandler (com.publiccms.common.handler.PageHandler)65 FacetPageHandler (com.publiccms.common.handler.FacetPageHandler)3 SysSite (com.publiccms.entities.sys.SysSite)3 IOException (java.io.IOException)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 CmsContentQuery (com.publiccms.views.pojo.query.CmsContentQuery)2 CmsContentAttribute (com.publiccms.entities.cms.CmsContentAttribute)1 CmsLottery (com.publiccms.entities.cms.CmsLottery)1 LogUpload (com.publiccms.entities.log.LogUpload)1 SysCluster (com.publiccms.entities.sys.SysCluster)1 CmsCategoryQuery (com.publiccms.views.pojo.query.CmsCategoryQuery)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 ModelMap (org.springframework.ui.ModelMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1