Example #1
0
 @SuppressWarnings("unchecked")
 @Transactional(propagation = Propagation.REQUIRED)
 public ArrayList<VColumn> getColumn(String type, String selfId) throws ChecksException {
   SqlExcuterImpl sqlMager = (SqlExcuterImpl) SpringContextUtil.getBean("SqlExcuter");
   VUser loginuser = WebContextMaker.getLoginer(WebContextMaker.getRequest());
   StringBuffer sqlBuffer = new StringBuffer();
   if (loginuser.getId().equals(SystemParms.ROOTID)) {
     sqlBuffer.append(
         " select distinct a.* from  v_column a where a.leveler = '"
             + type
             + "' and a.state = 1 and backHidden = 0 ");
   } else {
     sqlBuffer.append(
         "select distinct a.* from  v_column a left join v_power b  on (b.dataId=a.id) where a.leveler = '"
             + type
             + "' and a.state = 1 and backHidden = 0 ");
     String aa = getPowerSql(loginuser, 1, 0, 0, 0);
     if (!Checks.empty(aa)) {
       sqlBuffer.append(" and ").append(aa);
     }
   }
   if (selfId != null) {
     sqlBuffer.append(" and a.selfId ='" + selfId + "'");
   }
   sqlBuffer.append(" order by a.backSorter asc");
   String theSql = sqlBuffer.toString();
   return (ArrayList<VColumn>)
       sqlMager.sqlQuery(theSql, null, null, "com.fangshuoit.basic.entity", "VColumn", null, 0);
 }
Example #2
0
 @SuppressWarnings("unchecked")
 public void laodPower() throws ChecksException {
   // TODO Auto-generated method stub
   SqlExcuterImpl sqlMager = (SqlExcuterImpl) SpringContextUtil.getBean("SqlExcuter");
   VUser loginuser = WebContextMaker.getLoginer(WebContextMaker.getRequest());
   StringBuffer sqlBuffer = new StringBuffer();
   sqlBuffer.append(
       "select b.* from  v_column a left join v_power b  on (b.dataId=a.id) where  a.state = 1 and backHidden = 0 ");
   String aa = getPowerSql(loginuser, 0, 0, 0, 0);
   if (!Checks.empty(aa)) {
     sqlBuffer.append(" and ").append(aa);
   }
   List<VPower> alist =
       sqlMager.sqlQuery(
           sqlBuffer.toString(), null, null, "com.fangshuoit.basic.entity", "VPower", null, 0); //
   if (alist != null && alist.size() > 0) {
     if (PowerMap.powerMap.containsKey(loginuser.getId())) {
       PowerMap.powerMap.remove(loginuser.getId());
     }
     Map<String, Object> userMap = new HashMap<String, Object>();
     for (int i = 0; i < alist.size(); i++) {
       if (!Checks.empty(alist.get(i).getReservation())) {
         if (alist.get(i).getIfAdd() == 1 && alist.get(i).getIfNotAdd() != 1) {
           if (!userMap.containsKey(alist.get(i).getReservation() + "add")) {
             userMap.put(alist.get(i).getReservation() + "add", true);
           }
         }
         if (alist.get(i).getIfEdit() == 1 && alist.get(i).getIfNotEdit() != 1) {
           if (!userMap.containsKey(alist.get(i).getReservation() + "edit")) {
             userMap.put(alist.get(i).getReservation() + "edit", true);
           }
         }
         if (alist.get(i).getIfDel() == 1 && alist.get(i).getIfNotDel() != 1) {
           if (!userMap.containsKey(alist.get(i).getReservation() + "del")) {
             userMap.put(alist.get(i).getReservation() + "del", true);
           }
         }
         if (alist.get(i).getIfView() == 1 && alist.get(i).getIfNotView() != 1) {
           if (!userMap.containsKey(alist.get(i).getReservation() + "view")) {
             userMap.put(alist.get(i).getReservation() + "view", true);
           }
         }
       }
     }
     PowerMap.powerMap.put(loginuser.getId(), userMap);
   }
 }
Example #3
0
  @Transactional(propagation = Propagation.REQUIRED)
  public String getPowerSql(VUser user, int view, int edit, int del, int add)
      throws ChecksException {
    SqlExcuterImpl sqlMager = (SqlExcuterImpl) SpringContextUtil.getBean("SqlExcuter");
    String whereWriteSql = " ( ";
    int count = 0;
    if (user != null) {
      whereWriteSql += " b.op_id = '" + user.getId() + "' ";
      count++;
    } else throw new ChecksException("miss_user");
    if (user.getVDepartment() != null && user.getVDepartment().getId() != null) {
      if (count > 0) whereWriteSql += " or ";
      whereWriteSql += " b.op_id ='" + user.getVDepartment().getId() + "' ";
    }
    @SuppressWarnings("rawtypes")
    List roleList =
        sqlMager.sqlQuery(
            "select distinct roleId from v_role_user where userId = '" + user.getId() + "'",
            null,
            null,
            0);
    if (roleList != null && roleList.size() > 0) {
      for (Object obj : roleList) {
        if (count > 0) whereWriteSql += " or ";
        whereWriteSql += " b.op_id = '" + obj.toString() + "' ";
        count++;
      }
    }
    whereWriteSql += " ) ";
    if (view == 1) {
      if (count > 0) {
        whereWriteSql += " and ";
      }
      whereWriteSql += "b.ifView = 1 and b.ifNotView <> 1";
      count++;
    }
    if (edit == 1) {
      if (count > 0) {
        whereWriteSql += " and ";
      }
      whereWriteSql += "b.ifEdit = 1 and b.ifNotEdit <> 1";
      count++;
    }
    if (del == 1) {
      if (count > 0) {
        whereWriteSql += " and ";
      }
      whereWriteSql += "b.ifDel = 1 and b.ifNotDel <> 1";
      count++;
    }
    if (add == 1) {
      if (count > 0) {
        whereWriteSql += " and ";
      }
      whereWriteSql += "b.ifAdd = 1 and b.ifNotAdd <> 1";
      count++;
    }

    return " ( " + whereWriteSql + " and " + user.getSafeLeveler() + " > b.safeLeveler ) ";
  }
Example #4
0
 public boolean fixGetPower(Object thId, String simpleName) throws ChecksException {
   StringBuffer sqlBuffer = new StringBuffer();
   VUser loginuser = WebContextMaker.getLoginer(WebContextMaker.getRequest());
   if (!loginuser.getId().equals(SystemParms.ROOTID)) {
     sqlBuffer.append(
         "select b.id from v_power b where power_types = '"
             + simpleName
             + "' and data_id ='"
             + thId
             + "'");
     String aa = getPowerSql(loginuser, 1, 0, 0, 0);
     if (!Checks.empty(aa)) {
       sqlBuffer.append(" and").append(aa);
     }
   } else {
     return true;
   }
   String theSql = sqlBuffer.toString();
   SqlExcuterImpl sqlMager = (SqlExcuterImpl) SpringContextUtil.getBean("SqlExcuter");
   if (sqlMager.sqlQueryString(theSql, null, null, 0) == null) return false;
   return true;
 }