@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=showAddView") public ModelAndView showAddView(@ModelAttribute SYS_User user, HttpSession session) { user = (SYS_User) session.getAttribute(Const.SESSION_USER); PageData pd = getPageData(); try { pd.put("role", roleDao.findByCompanys(user.getOrgID())); mv.addObject("model", pd); mv.setViewName("/system/role/system_role_add"); } 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(); }
@RequestMapping(params = "p=view") public ModelAndView showListView(HttpSession session, @RequestParam("moduleID") String moduleID) { SYS_User user = (SYS_User) session.getAttribute(Const.SESSION_USER); PageData pd = getPageData(); try { // 获取用户权限按钮 String sql = "select * " + " from SYS_RoleButton " + " where ModuleID= '" + moduleID + "' and roleID = '" + user.getRoleID() + "' ;"; pd.put("userbutton", roleDao.query(SYS_RoleButton.class, sql)); mv.addObject("model", pd); mv.setViewName("/system/role/system_role_view"); /* * String sql = * "select * from BOSS_Store where StoreID='37108300001'"; * * List<SYS_Role> rols = new ArrayList<SYS_Role>(); List<BOSS_Store> * list = roleDao.query(BOSS_Store.class, sql); for (BOSS_Store * store : list) { SYS_Role role = new SYS_Role(); * role.setRoleID(UUIDUtil.get32UUID()); * role.setRoleName(store.getStoreName()+"企业负责人"); * role.setCompanyID(store.getCompanyID()); * role.setCompanyName(store.getCompanyName()); * role.setInputDate(DateUtil.getDateString()); * role.setInputName("Jimmy Toy"); * * SYS_Role role1 = new SYS_Role(); * role1.setRoleID(UUIDUtil.get32UUID()); * role1.setRoleName(store.getStoreName()+"质量负责人"); * role1.setCompanyID(store.getCompanyID()); * role1.setCompanyName(store.getCompanyName()); * role1.setInputDate(DateUtil.getDateString()); * role1.setInputName("Jimmy Toy"); * * SYS_Role role2 = new SYS_Role(); * role2.setRoleID(UUIDUtil.get32UUID()); * role2.setRoleName(store.getStoreName()+"销售员"); * role2.setCompanyID(store.getCompanyID()); * role2.setCompanyName(store.getCompanyName()); * role2.setInputDate(DateUtil.getDateString()); * role2.setInputName("Jimmy Toy"); * * rols.add(role); rols.add(role1); rols.add(role2); } * roleDao.insert(rols); * * sql = * "select * from SYS_Role where CompanyID in ('1435295347218')"; * rols = roleDao.query(SYS_Role.class, sql); * * sql = * "select * from SYS_RoleModule where RoleID='b8c90c7227b74f8db72800f2300dcba3'" * ; List<SYS_RoleModule> rm1 = roleDao.query(SYS_RoleModule.class, * sql); * * sql = * "select * from SYS_RoleModule where RoleID='b8c90c7227b74f8db72800f2300dcba4'" * ; List<SYS_RoleModule> rm2 = roleDao.query(SYS_RoleModule.class, * sql); * * List<SYS_RoleAccess> access = new ArrayList<>(); for (int i=0; * i<rols.size(); i++) { SYS_Role role = rols.get(i); if * (role.getRoleName().indexOf("企业负责人") >= 0) { List<SYS_RoleModule> * temp = new ArrayList<SYS_RoleModule>(); for (SYS_RoleModule rm : * rm1) { rm.setRomoID(UUIDUtil.get32UUID()); * rm.setRoleID(role.getRoleID()); * rm.setRoleName(role.getRoleName()); * rm.setInputDate(DateUtil.getDateString()); * rm.setInputName("Jimmy Toy"); temp.add(rm); } * roleDao.insert(temp); } else if * (role.getRoleName().indexOf("质量负责人") >= 0) { List<SYS_RoleModule> * temp = new ArrayList<SYS_RoleModule>(); for (SYS_RoleModule rm : * rm2) { rm.setRomoID(UUIDUtil.get32UUID()); * rm.setRoleID(role.getRoleID()); * rm.setRoleName(role.getRoleName()); * rm.setInputDate(DateUtil.getDateString()); * rm.setInputName("Jimmy Toy"); temp.add(rm); } * roleDao.insert(temp); } * * SYS_RoleAccess ra= new SYS_RoleAccess(); * ra.setRoacID(UUIDUtil.get32UUID()); * ra.setRoleID(role.getRoleID()); * ra.setRoleName(role.getRoleName()); ra.setDataType("Store"); * ra.setDataValue(role.getCompanyID()); * ra.setInputDate(DateUtil.getDateString()); * ra.setInputName("Jimmy Toy"); * * access.add(ra); * * SYS_RoleAccess ra1= new SYS_RoleAccess(); * ra1.setRoacID(UUIDUtil.get32UUID()); * ra1.setRoleID(role.getRoleID()); * ra1.setRoleName(role.getRoleName()); ra1.setDataType("Supplier"); * ra1.setDataValue("1435295347214"); * ra1.setInputDate(DateUtil.getDateString()); * ra1.setInputName("Jimmy Toy"); * * access.add(ra1); * * SYS_RoleAccess ra2= new SYS_RoleAccess(); * ra2.setRoacID(UUIDUtil.get32UUID()); * ra2.setRoleID(role.getRoleID()); * ra2.setRoleName(role.getRoleName()); ra2.setDataType("Company"); * ra2.setDataValue(role.getCompanyID()); * ra2.setInputDate(DateUtil.getDateString()); * ra2.setInputName("Jimmy Toy"); * * access.add(ra2); roleDao.insert(access); } */ } catch (Exception e) { return MessageUtil.exception(user, mv, e); } return MessageUtil.success(mv); }
@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); }