/** 新增 */ public void add() { CmsUser cmsuserForSession = getCmsUser(); String cmdAdduser = cmsuserForSession.getCmuName(); // 写日志 CmsLog log = UtilTools.buildLog("菜单管理", CmsLog.Add, "新增菜单", cmdAdduser); serviceDispatcher.getCmsLogService().add(log); // 返回值 ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); net.sf.json.JSONObject js = net.sf.json.JSONObject.fromObject(rows); Integer cmmParentId = js.getInt("cmmParentId"); String cmmName = js.getString("cmmName"); String cmmDesc = js.getString("cmmDesc"); String cmmIcon = "".equals(js.getString("cmmIcon")) ? "workplace/image/icon/xitong.png" : js.getString("cmmIcon"); Integer cmmOrderNum = js.getInt("cmmOrderNum"); String cmmAdminUrl = js.getString("cmmAdminUrl"); Integer cmmType = js.getInt("cmmType"); Date cmmAddTime = UtilTools.getCurrrentDate1(); // 获取当前系统时间 String cmmAddUser = cmsuserForSession.getCmuName(); CmsMenu cm = new CmsMenu(); cm.setCmmParentId(cmmParentId); cm.setCmmName(cmmName); cm.setCmmDesc(cmmDesc); cm.setCmmIcon(cmmIcon); cm.setCmmOrderNum(cmmOrderNum); cm.setCmmAdminUrl(cmmAdminUrl); cm.setCmmType(cmmType); cm.setCmmAddUser(cmmAddUser); cm.setCmmAddTime(cmmAddTime); serviceDispatcher.getCmsMenuService().add(cm); // 获取数据 StringBuffer jsonString = new StringBuffer(); jsonString.append("{"); jsonString.append("success:true"); jsonString.append("}"); PrintWriter out; try { out = ServletActionContext.getResponse().getWriter(); out.print(jsonString); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } }
/** 删除 */ public void del() { CmsUser cmsuserForSession = getCmsUser(); String cmdAdduser = cmsuserForSession.getCmuName(); // 写日志 CmsLog log = UtilTools.buildLog("菜单管理", CmsLog.DELETE, "删除菜单", cmdAdduser); serviceDispatcher.getCmsLogService().add(log); net.sf.json.JSONArray objArr = net.sf.json.JSONArray.fromObject(rows); // 是否存在子目录 Boolean flag = false; for (int i = 0; i < objArr.size(); i++) { net.sf.json.JSONObject js = objArr.getJSONObject(i); // 是否包含子目录,如果包含则不允许删除 cmsMenu.setCmmId(js.getInt("cmmId")); List subList = serviceDispatcher.getCmsMenuService().query(cmsMenu); if (subList != null && subList.size() > 0) { flag = true; break; } else { serviceDispatcher.getCmsMenuService().del(js.getInt("cmmId")); } } // 获取数据 StringBuffer jsonString = new StringBuffer(); if (flag) { jsonString.append("{"); jsonString.append("failure:true,"); jsonString.append("msg:'对不起该目录包含子菜单,请先删除子菜单'"); jsonString.append("}"); } else { jsonString.append("{"); jsonString.append("success:true,"); jsonString.append( "msg:" + ApplicationResources.getText("admin.system.user.msg.deleteSuccess")); // '删除成功' jsonString.append("}"); } PrintWriter out; try { ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); out = ServletActionContext.getResponse().getWriter(); out.print(jsonString.toString()); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } }
/** 更新信息 */ public String update() { ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); CmsUser cmsuserForSession = getCmsUser(); String user = cmsuserForSession.getCmuName(); // 写日志 CmsLog log = UtilTools.buildLog("会员管理", CmsLog.MODIFY, "修改用户的状态", user); serviceDispatcher.getCmsLogService().add(log); net.sf.json.JSONObject js = net.sf.json.JSONObject.fromObject(rows); Long userid = js.getLong("userid"); String status = js.getString("availabilityflag"); TbRegUser tbRegUser = audiServiceDispatcher.getRegUserService().getUserById(userid); if (!CmsUtils.isEmpty(status)) { tbRegUser.setAvailabilityflag(status); } else { tbRegUser.setAvailabilityflag("1"); } boolean isSuc = audiServiceDispatcher.getRegUserService().modify(tbRegUser); this.renderJson("{success:true,msg:'修改成功!',error:" + isSuc + "}"); return null; }