use of com.publiccms.views.pojo.entities.CmsModel 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();
}
}
}
use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.
the class ModelComponent method getList.
/**
* @param site
* @param parentId
* @param hasChild
* @param onlyUrl
* @param hasImages
* @param hasFiles
* @return models list
*/
public List<CmsModel> getList(SysSite site, String parentId, Boolean hasChild, Boolean onlyUrl, Boolean hasImages, Boolean hasFiles) {
List<CmsModel> modelList = new ArrayList<>();
Map<String, CmsModel> map = getMap(site);
for (CmsModel model : map.values()) {
if ((CommonUtils.empty(parentId) && CommonUtils.empty(model.getParentId()) || CommonUtils.notEmpty(parentId) && parentId.equals(model.getParentId())) || (null != hasChild && hasChild.equals(model.isHasChild())) || (null != onlyUrl && onlyUrl.equals(model.isOnlyUrl())) || (null != hasImages && hasImages.equals(model.isHasImages())) || (null != hasFiles && hasFiles.equals(model.isHasFiles()))) {
modelList.add(model);
}
}
return modelList;
}
use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.
the class CmsModelAdminController method delete.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(String id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
Map<String, CmsModel> modelMap = modelComponent.getMap(site);
CmsModel entity = modelMap.remove(id);
if (null != entity) {
List<CmsModel> modelList = modelComponent.getList(site, entity.getId(), null, null, null, null);
for (CmsModel m : modelList) {
m.setParentId(null);
modelMap.put(m.getId(), m);
}
modelComponent.save(site, modelMap);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.views.pojo.entities.CmsModel in project PublicCMS-preview by sanluan.
the class CmsModelAdminController method save.
/**
* @param entity
* @param modelId
* @param request
* @param session
* @return view name
*/
@RequestMapping("save")
public String save(@ModelAttribute CmsModel entity, String modelId, HttpServletRequest request, HttpSession session) {
SysSite site = getSite(request);
modelComponent.clear(site.getId());
if (CommonUtils.notEmpty(modelId)) {
Map<String, CmsModel> modelMap = modelComponent.getMap(site);
modelMap.remove(modelId);
modelMap.put(entity.getId(), entity);
modelComponent.save(site, modelMap);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
} else {
Map<String, CmsModel> modelMap = modelComponent.getMap(site);
modelMap.put(entity.getId(), entity);
modelComponent.save(site, modelMap);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.model", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
Aggregations