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();
}
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();
}
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;
}
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);
}
}
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);
}
}
Aggregations