Search in sources :

Example 81 with SysSite

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);
    }
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) CmsLottery(com.publiccms.entities.cms.CmsLottery) SysSite(com.publiccms.entities.sys.SysSite)

Example 82 with SysSite

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();
    }
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) IOException(java.io.IOException) SysSite(com.publiccms.entities.sys.SysSite)

Example 83 with SysSite

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();
        }
    }
}
Also used : CmsTag(com.publiccms.entities.cms.CmsTag) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 84 with SysSite

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();
        }
    }
}
Also used : CmsTagType(com.publiccms.entities.cms.CmsTagType) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 85 with SysSite

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();
        }
    }
}
Also used : SysApp(com.publiccms.entities.sys.SysApp) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SysSite (com.publiccms.entities.sys.SysSite)175 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)135 LogOperate (com.publiccms.entities.log.LogOperate)117 IOException (java.io.IOException)33 SysUser (com.publiccms.entities.sys.SysUser)21 LinkedHashMap (java.util.LinkedHashMap)19 TemplateException (freemarker.template.TemplateException)15 File (java.io.File)14 CmsContent (com.publiccms.entities.cms.CmsContent)12 CmsCategory (com.publiccms.entities.cms.CmsCategory)11 MultipartFile (org.springframework.web.multipart.MultipartFile)10 SysTask (com.publiccms.entities.sys.SysTask)9 HashMap (java.util.HashMap)8 LogUpload (com.publiccms.entities.log.LogUpload)7 SysDept (com.publiccms.entities.sys.SysDept)7 SysUserToken (com.publiccms.entities.sys.SysUserToken)7 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)7 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)6 CmsPlace (com.publiccms.entities.cms.CmsPlace)5 SysDomain (com.publiccms.entities.sys.SysDomain)5