use of com.publiccms.entities.sys.SysSite 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);
}
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsSearchDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
String word = handler.getString("word");
Long[] tagIds = handler.getLongArray("tagId");
if (CommonUtils.notEmpty(word) || CommonUtils.notEmpty(tagIds)) {
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(word)) {
statisticsComponent.search(site.getId(), word);
}
if (CommonUtils.notEmpty(tagIds)) {
for (Long tagId : tagIds) {
statisticsComponent.searchTag(tagId);
}
}
PageHandler page;
Integer pageIndex = handler.getInteger("pageIndex", 1);
Integer count = handler.getInteger("count", 30);
try {
page = service.query(site.getId(), word, tagIds, handler.getInteger("categoryId"), handler.getBoolean("containChild"), handler.getIntegerArray("categoryIds"), handler.getStringArray("modelIds"), handler.getDate("startPublishDate"), CommonUtils.getMinuteDate(), pageIndex, count);
} catch (Exception e) {
page = new PageHandler(pageIndex, count, 0, null);
}
handler.put("page", page).render();
}
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsTagDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Long id = handler.getLong("id");
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(id)) {
CmsTag entity = service.getEntity(id);
if (null != entity && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
} else {
Long[] ids = handler.getLongArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<CmsTag> entityList = service.getEntitys(ids);
Map<String, CmsTag> map = new LinkedHashMap<>();
for (CmsTag entity : entityList) {
if (site.getId() == entity.getSiteId()) {
map.put(String.valueOf(entity.getId()), entity);
}
}
handler.put("map", map).render();
}
}
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsTagTypeDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Integer id = handler.getInteger("id");
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(id)) {
CmsTagType entity = service.getEntity(id);
if (null != entity && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
} else {
Integer[] ids = handler.getIntegerArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<CmsTagType> entityList = service.getEntitys(ids);
Map<String, CmsTagType> map = new LinkedHashMap<>();
for (CmsTagType entity : entityList) {
if (site.getId() == entity.getSiteId()) {
map.put(String.valueOf(entity.getId()), entity);
}
}
handler.put("map", map).render();
}
}
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class SysAppDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Integer id = handler.getInteger("id");
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(id)) {
SysApp entity = service.getEntity(id);
if (null != entity && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
} else {
Integer[] ids = handler.getIntegerArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<SysApp> entityList = service.getEntitys(ids);
Map<String, SysApp> map = new LinkedHashMap<>();
for (SysApp entity : entityList) {
if (site.getId() == entity.getSiteId()) {
map.put(String.valueOf(entity.getId()), entity);
}
}
handler.put("map", map).render();
}
}
}
Aggregations