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();
}
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());
}
}
}
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;
}
}
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;
}
Aggregations