Search in sources :

Example 11 with CmsCategory

use of com.publiccms.entities.cms.CmsCategory in project PublicCMS-preview by sanluan.

the class CmsCategoryService method delete.

/**
 * @param siteId
 * @param ids
 */
public void delete(short siteId, Integer[] ids) {
    for (CmsCategory entity : getEntitys(ids)) {
        if (siteId == entity.getSiteId() && !entity.isDisabled()) {
            @SuppressWarnings("unchecked") List<CmsCategory> list = (List<CmsCategory>) getPage(new CmsCategoryQuery(siteId, entity.getId(), false, null, null, null, null), null, null).getList();
            for (CmsCategory child : list) {
                child.setParentId(entity.getParentId());
            }
            entity.setDisabled(true);
            generateChildIds(entity.getSiteId(), entity.getParentId());
        }
    }
}
Also used : CmsCategoryQuery(com.publiccms.views.pojo.query.CmsCategoryQuery) List(java.util.List) CmsCategory(com.publiccms.entities.cms.CmsCategory)

Example 12 with CmsCategory

use of com.publiccms.entities.cms.CmsCategory in project PublicCMS-preview by sanluan.

the class CmsCategoryService method getChildIds.

private String getChildIds(short siteId, Integer parentId) {
    StringBuilder childIds = new StringBuilder();
    @SuppressWarnings("unchecked") List<CmsCategory> list = (List<CmsCategory>) getPage(new CmsCategoryQuery(siteId, parentId, false, null, null, null, false), null, null).getList();
    if (0 < list.size()) {
        for (CmsCategory category : list) {
            childIds.append(category.getId());
            childIds.append(COMMA_DELIMITED);
            String childChildIds = getChildIds(siteId, category.getId());
            if (CommonUtils.notEmpty(childChildIds)) {
                childIds.append(childChildIds);
                childIds.append(COMMA_DELIMITED);
            }
        }
        if (0 < childIds.length()) {
            childIds.setLength(childIds.length() - 1);
        }
    }
    if (0 < childIds.length()) {
        return childIds.toString();
    } else {
        return null;
    }
}
Also used : CmsCategoryQuery(com.publiccms.views.pojo.query.CmsCategoryQuery) List(java.util.List) CmsCategory(com.publiccms.entities.cms.CmsCategory)

Example 13 with CmsCategory

use of com.publiccms.entities.cms.CmsCategory in project PublicCMS-preview by sanluan.

the class CmsCategoryService method generateChildIds.

/**
 * @param siteId
 * @param parentId
 */
public void generateChildIds(short siteId, Integer parentId) {
    if (null != parentId) {
        updateChildIds(parentId, getChildIds(siteId, parentId));
        CmsCategory parent = getEntity(parentId);
        if (null != parent) {
            generateChildIds(siteId, parent.getParentId());
        }
    }
}
Also used : CmsCategory(com.publiccms.entities.cms.CmsCategory)

Example 14 with CmsCategory

use of com.publiccms.entities.cms.CmsCategory in project PublicCMS-preview by sanluan.

the class CmsCategoryService method addChildIds.

/**
 * @param parentId
 * @param id
 */
public void addChildIds(Serializable parentId, Serializable id) {
    if (null != parentId) {
        CmsCategory parent = getEntity(parentId);
        if (null != parent) {
            addChildIds(parent.getParentId(), id);
            String childIds;
            if (CommonUtils.notEmpty(parent.getChildIds())) {
                childIds = parent.getChildIds() + COMMA_DELIMITED + String.valueOf(id);
            } else {
                childIds = String.valueOf(id);
            }
            updateChildIds(parent.getId(), childIds);
        }
    }
}
Also used : CmsCategory(com.publiccms.entities.cms.CmsCategory)

Example 15 with CmsCategory

use of com.publiccms.entities.cms.CmsCategory in project PublicCMS-preview by sanluan.

the class CmsCategoryDirective method execute.

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

Aggregations

CmsCategory (com.publiccms.entities.cms.CmsCategory)17 SysSite (com.publiccms.entities.sys.SysSite)11 LogOperate (com.publiccms.entities.log.LogOperate)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 CmsContent (com.publiccms.entities.cms.CmsContent)6 SysExtendField (com.publiccms.entities.sys.SysExtendField)3 TemplateException (freemarker.template.TemplateException)3 IOException (java.io.IOException)3 CmsCategoryModel (com.publiccms.entities.cms.CmsCategoryModel)2 CmsCategoryModelId (com.publiccms.entities.cms.CmsCategoryModelId)2 SysUser (com.publiccms.entities.sys.SysUser)2 CmsModel (com.publiccms.views.pojo.entities.CmsModel)2 ExtendField (com.publiccms.views.pojo.entities.ExtendField)2 CmsCategoryQuery (com.publiccms.views.pojo.query.CmsCategoryQuery)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 CmsCategoryType (com.publiccms.entities.cms.CmsCategoryType)1 SysDept (com.publiccms.entities.sys.SysDept)1 SysDeptCategoryId (com.publiccms.entities.sys.SysDeptCategoryId)1