@RequestMapping(params = "reqItems") @ResponseBody public AjaxJson reqItems(String parentId) { AjaxJson j = new AjaxJson(); j.setObj(commonItemService.findItemsCanEnitByParentId(parentId)); j.setSuccess(commonItemService.itemCanEdit(parentId)); return j; }
@RequestMapping(params = "treegried") @ResponseBody public List<Map<String, Object>> loadItem(HttpServletRequest request) { CommonAdminSession common = (CommonAdminSession) request.getSession().getAttribute(Constant.COMMON_ADMIN_SESSION); return commonItemService.queryTreeGridTree(common.getDistrict().getDistrictCode()); }
@RequestMapping(params = "addArticle") public ModelAndView addArticle(HttpServletRequest req, ItemEntity item) { List<ItemEntity> listEntity = commonItemService.findItemsByParentId("0"); if (StringUtil.isNotEmpty(item.getId())) { item = commonItemService.getEntity(ItemEntity.class, item.getId()); req.setAttribute("itemPage", item); if (item.getLevel() == 3) { // 说明有三级菜单 /* req.setAttribute("secondPage", commonItemService .findItemsByParentId(commonItemService.findParticalItemById( item.getParentId()).getParentId()));*/ req.setAttribute( "secondPage", commonItemService.findItemsCanEnitByParentId( commonItemService.findParticalItemById(item.getParentId()).getParentId())); req.setAttribute("second", item.getParentId()); req.setAttribute( "first", commonItemService.findParticalItemById(item.getParentId()).getParentId()); } else if (item.getLevel() == 2) { req.setAttribute("first", item.getParentId()); req.setAttribute("secondPage", commonItemService.findItemsByParentId(item.getParentId())); } } else { if (listEntity.size() > 0) { req.setAttribute( "secondPage", commonItemService.findItemsCanEnitByParentId(listEntity.get(0).getId())); /*req.setAttribute("secondPage", commonItemService.findItemsCanEnitByParentId(commonItemService.findParticalItemById( listEntity.get(0).getParentId()).getParentId()));*/ } else { return new ModelAndView("upperadmin/item/error"); } } /*List<ItemEntity> listEntity = commonItemService.findItemsByParentId("0");*/ req.setAttribute("itemReplace", listEntity); return new ModelAndView("commonadmin/item/article2"); }
/** * 删除类目基本信息 * * @return */ @RequestMapping(params = "del") @ResponseBody public AjaxJson del(ItemEntity item, HttpServletRequest request) { AjaxJson j = new AjaxJson(); item = systemService.getEntity(ItemEntity.class, item.getId()); message = "类目基本信息删除成功"; commonItemService.delete(item); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); j.setMsg(message); return j; }
@RequestMapping(params = "articleSave") @ResponseBody public AjaxJson articleSave( ItemEntity item, String content, String contentTxt, HttpServletRequest req) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(item.getId())) { message = "内容信息添加成功"; ItemEntity t = commonItemService.get(ItemEntity.class, item.getId()); ArticleEntity a = t.getArticle(); a.setContent(content); a.setContentTxt(contentTxt); t.setArticle(a); if (item.getParentId().equals("0")) { item.setLevel(1); // 设置为目录级 } else { item.setLevel( commonItemService.findParticalItemById(item.getParentId()).getLevel() + 1); // 设置为内容级别 } try { MyBeanUtils.copyBeanNotNull2Bean(item, t); commonItemService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); message = "类目基本信息更新失败"; } } else { CommonAdminSession sessionAdmin = (CommonAdminSession) req.getSession().getAttribute(Constant.COMMON_ADMIN_SESSION); Date curDate = new Date(System.currentTimeMillis()); message = "内容信息添加成功"; item.setCreateTime(curDate); item.setUpdateTime(curDate); item.setBelongs(sessionAdmin.getDistrict().getDistrictCode()); item.setCreator(sessionAdmin.getId()); item.setType(Constant.Article); item.setStatus(DictionaryBean.keyDict.get("item_status_normal").getValue()); if (item.getParentId().equals("0")) { item.setLevel(1); // 设置为目录级 } else { item.setLevel( commonItemService.findParticalItemById(item.getParentId()).getLevel() + 1); // 设置为内容级别 } ArticleEntity article = new ArticleEntity(); article.setContent(content); article.setContentTxt(contentTxt); article.setParentId(item.getParentId()); article.setBelongId(DictionaryBean.keyDict.get("item_belongs_private").getValue()); commonItemService.save(article); item.setArticle(article); commonItemService.save(item); } j.setMsg(message); return j; }
@RequestMapping(params = "preview") public ModelAndView preview(String id, HttpServletRequest req) { req.setAttribute("article", commonItemService.findArticleByItemId(id)); return new ModelAndView("upperadmin/item/preview"); }