@SuppressWarnings("deprecation") @RequestMapping(params = "p=find") public @ResponseBody Pager find( SYS_Role entity, Pager pager, HttpSession session, HttpServletRequest request, HttpServletResponse response) { try { String w = " RoleName like '%" + pager.getParameters().get("searchText") + "%'" + SQLUtil.getWhereClause(pager); if (pager.getIsExport()) { if (pager.getExportAllData()) { pager.setExportDatas(roleDao.query(SQLUtil.getQuerySQL(entity.getClass()))); } try { ExportUtils.export(request, response, pager); } catch (Exception e) { e.printStackTrace(); } return null; } if (pager.getPageSize() == 0) { String sql = SQLUtil.getQuerySQL(SYS_Role.class) + " where " + w; pager.setExhibitDatas(roleDao.query(SYS_Role.class, sql)); } else { pager.setAdvanceQuerySorts(SortUtil.sortBuild1("InputDate", "1")); roleDao.queryCount(pager, SYS_Role.class, w); roleDao.queryPager(pager, SYS_Role.class, w); pager.setIsSuccess(true); } } catch (Exception e) { e.printStackTrace(); pager.setIsSuccess(false); } pager.setIsSuccess(true); return pager; }
@RequestMapping(params = "p=del") public @ResponseBody Map<String, Object> del( @ModelAttribute SYS_Role entity, HttpSession session) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); try { String sql = SQLUtil.getDeleteSQLByModule(entity); // String querySQL = SQLUtil.getQuerySQL(SYS_Role.class) + " where " // + SQLUtil.getWhereClause(entity); // SYS_Role temp = roleDao.query(SYS_Role.class, querySQL).get(0); // LogVO l = ObjUtil.buildMetaSQL(temp, "第1/1步,删除"); // String table = "SYS_Role:" + entity.getRoleID(); // String oprinfo = "SYS_Role:" + l.getRowid(); // String descriptioin = "删除角色(编码:" + entity.getRoleID(); // sql += LogUtil.getLogSQL(user, table, sql, oprinfo, // descriptioin); // sql += l.getSql(); sql += "delete from SYS_rolemodule where roleID = '" + entity.getRoleID() + "' ;"; roleDao.jdbcTemplate.execute(sql); } catch (Exception e) { return MessageUtil.exception(user, e); } return MessageUtil.success(); }
@RequestMapping(params = "p=eyeView") public ModelAndView showEyeView(@ModelAttribute SYS_Role entity, HttpSession session) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); PageData pd = getPageData(); try { String sql = SQLUtil.getQuerySQL(SYS_Role.class).replace("\n", "") + " where RoleID='" + entity.getRoleID() + "'"; List<SYS_Role> entry = roleDao.query(SYS_Role.class, sql); List<SYS_Role> entrys = roleDao.findByCompanys(user.getOrgID()); for (SYS_Role sys_Role : entrys) { if (!(sys_Role.getCompanyID().equals(entry.get(0).getCompanyID()))) { entry.add(sys_Role); } } pd.put("role", entry); mv.addObject("model", pd); // mv.addObject("model", pd.put("entity", entry)); mv.setViewName("/system/role/system_role_eye"); } catch (Exception e) { return MessageUtil.exception(user, mv, e); } return MessageUtil.success(mv); }
@RequestMapping(params = "p=add") public @ResponseBody Map<String, Object> add(SYS_Role entity, HttpSession session) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); try { checkEntity(entity); entity.setRoleID(UUIDUtil.get32UUID()); entity.setInputName(user.getUserName()); entity.setInputDate(DateUtil.getDateTimeString()); if (CheckUtil.isNullStr(entity.getCompanyID())) { entity.setCompanyID(user.getCompanyID()); entity.setCompanyName(user.getCompanyName()); } SYS_RoleAccess roleCompany = new SYS_RoleAccess(); roleCompany.setRoacID(UUIDUtil.get32UUID()); roleCompany.setDataType("Company"); roleCompany.setDataValue(entity.getCompanyID()); roleCompany.setRoleID(entity.getRoleID()); roleCompany.setRoleName(entity.getRoleName()); roleCompany.setInputDate(DateUtil.getDateTimeString()); roleCompany.setInputName(user.getRealName() + "[" + user.getUserName() + "]"); // 添加跟目录 List<SYS_RoleModule> list = new ArrayList<SYS_RoleModule>(); SYS_RoleModule rm = new SYS_RoleModule(); rm.setRomoID(UUIDUtil.get32UUID()); rm.setRoleID(entity.getRoleID()); rm.setRoleName(entity.getRoleName()); rm.setModuleID("400"); rm.setModuleName(entity.getCompanyName()); rm.setInputDate(DateUtil.getDateTimeString()); rm.setInputName(user.getUserName()); list.add(rm); String s = SQLUtil.getInsertSQL(list); s += SQLUtil.getInsertSQL(entity); roleDao.jdbcTemplate.execute(s); // roleDao.insert(entity); } catch (Exception e) { return MessageUtil.exception(user, e); } return MessageUtil.success(); }
@SuppressWarnings("unchecked") @RequestMapping(params = "p=addrolebutton") public @ResponseBody Map<String, Object> addRoleButton( String str, @ModelAttribute SYS_Role role, String module3, HttpSession session) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); Map<String, Object> result = new HashMap<String, Object>(); try { JSONArray jsonArray = JSONArray.fromObject(unicode(str.replace("p__", "p="))); List<SYS_RoleButton> list = new ArrayList<SYS_RoleButton>(); for (Object obj : jsonArray) { SYS_ModuleButt temp = PropertyUtil.copyMap(SYS_ModuleButt.class, (Map<String, Object>) obj); SYS_RoleButton ra = new SYS_RoleButton(); ra.setRobuID(UUIDUtil.get32UUID()); ra.setRoleID(role.getRoleID()); ra.setRoleName(unicode(role.getRoleName())); ra.setButtonID(temp.getButtonID()); ra.setButtonName(temp.getButtonName()); ra.setRequestMapping(temp.getRequestMapping()); ra.setModuleID(module3); list.add(ra); } String sql = "delete from SYS_RoleButton where ModuleID='" + module3 + "' and RoleID='" + role.getRoleID() + "' ; \n"; sql += SQLUtil.getInsertSQLByRole(list); roleDao.jdbcTemplate.execute(sql); } catch (Exception e) { return MessageUtil.exception(user, e); } return MessageUtil.success(result); }
@SuppressWarnings("unchecked") @RequestMapping(params = "p=addrolemodule") public @ResponseBody Map<String, Object> addRoleModule( @ModelAttribute SYS_Role role, String module1, String module2, String modulestr, HttpSession session, String appPlatform) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); Map<String, Object> result = new HashMap<String, Object>(); try { JSONArray jsonArray = JSONArray.fromObject(unicode(modulestr)); if (CheckUtil.isNullStr(module1)) { throw new CustomerException("请选择子系统"); } if (CheckUtil.isNullStr(module2)) { throw new CustomerException("请选择一级菜单"); } List<SYS_RoleModule> list = new ArrayList<SYS_RoleModule>(); List<SYS_RoleModule> list1 = new ArrayList<SYS_RoleModule>(); // String sql = "select * from SYS_Module where ModuleID in ('" + // module1 + "','" + module2 + "')"+" ;"; String sql = "select * from SYS_Module where ParentID = '" + module2 + "' || ModuleID = '" + module2 + "' ;"; String sql1 = "select * from SYS_Module where ModuleID = '" + module2 + "' ;"; List<SYS_Module> pars = roleDao.query(SYS_Module.class, sql); SYS_Module pars1 = roleDao.query(SYS_Module.class, sql1).get(0); if (pars.size() > 0 || "AIR".equals(appPlatform)) { for (SYS_Module temp : pars) { SYS_RoleModule rm = new SYS_RoleModule(); rm.setRomoID(UUIDUtil.get32UUID()); rm.setRoleID(role.getRoleID()); rm.setRoleName(unicode(role.getRoleName())); rm.setModuleID(temp.getModuleID()); rm.setModuleName(temp.getModuleName()); rm.setInputDate(DateUtil.getDateTimeString()); rm.setInputName(user.getUserName()); list.add(rm); } } sql += SQLUtil.getDeleteSQLByModule(list); for (Object obj : jsonArray) { SYS_Module temp = PropertyUtil.copyMap(SYS_Module.class, (Map<String, Object>) obj); SYS_RoleModule rm = new SYS_RoleModule(); rm.setRomoID(UUIDUtil.get32UUID()); rm.setRoleID(role.getRoleID()); rm.setRoleName(unicode(role.getRoleName())); rm.setModuleID(temp.getModuleID()); rm.setModuleName(temp.getModuleName()); rm.setInputDate(DateUtil.getDateTimeString()); rm.setInputName(user.getUserName()); list1.add(rm); } for (Object obj : jsonArray) { SYS_Module temp = PropertyUtil.copyMap(SYS_Module.class, (Map<String, Object>) obj); SYS_RoleModule rm = new SYS_RoleModule(); if (temp.getParentID().equals(module2)) { rm.setRomoID(UUIDUtil.get32UUID()); rm.setRoleID(role.getRoleID()); rm.setRoleName(unicode(role.getRoleName())); rm.setModuleID(pars1.getModuleID()); rm.setModuleName(pars1.getModuleName()); rm.setInputDate(DateUtil.getDateTimeString()); rm.setInputName(user.getUserName()); list1.add(rm); } break; } // if ("AIR".equals(appPlatform) && CheckUtil.isNullStr(module2)) { // sql = "delete from SYS_RoleModule where ModuleId in ('" + module1 // + "','" + module2 + "') and RoleID='" + role.getRoleID() + "'\n"+ // " ; "; // } else { // sql = "delete from SYS_RoleModule where ModuleId in ('" + module1 // + "','" + module2 + "') and RoleID='" + role.getRoleID() + "'\n" // + " ; "; // } // sql += // "delete a from SYS_RoleModule a, SYS_Module b where "+module1+" = // "+module2+/*a.ModuleID=b.ModuleID*/" and b.ParentID='"+module2+"' and RoleID='" // + role.getRoleID() + "'\n"; sql += SQLUtil.getInsertSQLByRole(list1); roleDao.jdbcTemplate.execute(sql); } catch (Exception e) { return MessageUtil.exception(user, e); } return MessageUtil.success(result); }