Search in sources :

Example 1 with CmsCategoryQuery

use of com.publiccms.views.pojo.query.CmsCategoryQuery in project PublicCMS-preview by sanluan.

the class CmsCategoryListDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    CmsCategoryQuery queryEntity = new CmsCategoryQuery();
    queryEntity.setQueryAll(handler.getBoolean("queryAll"));
    if (handler.getBoolean("advanced", false)) {
        queryEntity.setDisabled(handler.getBoolean("disabled", false));
        queryEntity.setHidden(handler.getBoolean("hidden"));
    } else {
        queryEntity.setDisabled(false);
        queryEntity.setHidden(false);
    }
    queryEntity.setSiteId(getSite(handler).getId());
    queryEntity.setParentId(handler.getInteger("parentId"));
    queryEntity.setTypeId(handler.getInteger("typeId"));
    queryEntity.setAllowContribute(handler.getBoolean("allowContribute"));
    PageHandler page = service.getPage(queryEntity, handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
    handler.put("page", page).render();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) CmsCategoryQuery(com.publiccms.views.pojo.query.CmsCategoryQuery)

Example 2 with CmsCategoryQuery

use of com.publiccms.views.pojo.query.CmsCategoryQuery 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 3 with CmsCategoryQuery

use of com.publiccms.views.pojo.query.CmsCategoryQuery 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 4 with CmsCategoryQuery

use of com.publiccms.views.pojo.query.CmsCategoryQuery in project PublicCMS-preview by sanluan.

the class CmsCategoryTypeAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    CmsCategoryType entity = service.getEntity(id);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model) || ControllerUtils.verifyNotGreaterThen("category", categoryService.getPage(new CmsCategoryQuery(site.getId(), null, true, id, null, null, false), null, null).getTotalCount(), 1, model)) {
            return TEMPLATE_ERROR;
        }
        service.delete(id);
        extendService.delete(entity.getExtendId());
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.categoryType", RequestUtils.getIpAddress(request), CommonUtils.getDate(), id.toString()));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsCategoryQuery(com.publiccms.views.pojo.query.CmsCategoryQuery) CmsCategoryType(com.publiccms.entities.cms.CmsCategoryType) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CmsCategoryQuery (com.publiccms.views.pojo.query.CmsCategoryQuery)4 CmsCategory (com.publiccms.entities.cms.CmsCategory)2 List (java.util.List)2 PageHandler (com.publiccms.common.handler.PageHandler)1 CmsCategoryType (com.publiccms.entities.cms.CmsCategoryType)1 LogOperate (com.publiccms.entities.log.LogOperate)1 SysSite (com.publiccms.entities.sys.SysSite)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1