Search in sources :

Example 86 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class CmsCategoryTypeDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Integer id = handler.getInteger("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsCategoryType 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<CmsCategoryType> entityList = service.getEntitys(ids);
            Map<String, CmsCategoryType> map = new LinkedHashMap<>();
            for (CmsCategoryType entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsCategoryType(com.publiccms.entities.cms.CmsCategoryType) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 87 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class CmsFacetSearchDirective 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.facetQuery(site.getId(), handler.getStringArray("categoryId"), handler.getStringArray("modelId"), word, tagIds, handler.getDate("startPublishDate"), handler.getDate("endPublishDate", CommonUtils.getDate()), pageIndex, count);
        } catch (Exception e) {
            page = new FacetPageHandler(pageIndex, count, 0, null);
        }
        handler.put("page", page).render();
    }
}
Also used : FacetPageHandler(com.publiccms.common.handler.FacetPageHandler) PageHandler(com.publiccms.common.handler.PageHandler) IOException(java.io.IOException) FacetPageHandler(com.publiccms.common.handler.FacetPageHandler) SysSite(com.publiccms.entities.sys.SysSite)

Example 88 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class CmsModelDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    String id = handler.getString("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsModel entity = modelComponent.getMap(site).get(id);
        if (null != entity) {
            handler.put("object", entity).render();
        }
    } else {
        String[] ids = handler.getStringArray("ids");
        if (CommonUtils.notEmpty(ids)) {
            Map<String, CmsModel> modelMap = modelComponent.getMap(site);
            Map<String, CmsModel> map = new LinkedHashMap<>();
            for (String modelId : ids) {
                map.put(modelId, modelMap.get(modelId));
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsModel(com.publiccms.views.pojo.entities.CmsModel) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 89 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class CmsPlaceDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsPlace 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<CmsPlace> entityList = service.getEntitys(ids);
            Map<String, CmsPlace> map = new LinkedHashMap<>();
            for (CmsPlace entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsPlace(com.publiccms.entities.cms.CmsPlace) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 90 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class LogOperateDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        LogOperate 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<LogOperate> entityList = service.getEntitys(ids);
            Map<String, LogOperate> map = new LinkedHashMap<>();
            for (LogOperate entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) 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