Esempio n. 1
0
  @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);
  }
Esempio n. 2
0
  @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);
  }