Exemplo n.º 1
0
  /**
   * 删除设计信息。
   *
   * @param funcId -- 功能ID
   * @param pageType -- 页面类型
   * @return
   */
  public String deleteDesign(String funcId, String pageType) {
    if (funcId == null || funcId.length() == 0) {
      setMessage(JsMessage.getValue("pagedesign.funidisnull"));
      return _returnFaild;
    }
    if (pageType == null || pageType.length() == 0) {
      setMessage(JsMessage.getValue("pagedesign.pagetypeisnull"));
      return _returnFaild;
    }

    String sql = "delete from fun_design where fun_id = ? and page_type = ? ";

    DaoParam param = _dao.createParam(sql);
    param.addStringValue(funcId);
    param.addStringValue(pageType);
    param.setDsName(DefineName.DESIGN_NAME);

    boolean ret = _dao.update(param);
    if (!ret) {
      setMessage(JsMessage.getValue("pagedesign.dserror"));
      return _returnFaild;
    }

    return _returnSuccess;
  }
Exemplo n.º 2
0
    private void retrieveFromDB() {
      // 从数据库中取上次分配的最大值
      int dbmax = 0;
      String ssql = "select max_value from sys_tableid where table_name = ?";

      DaoParam sparam = _dao.createParam(ssql);
      sparam.addStringValue(keyName);
      Map<String, String> mpMax = _dao.queryMap(sparam);

      if (!mpMax.isEmpty()) {
        dbmax = Integer.parseInt(mpMax.get("max_value"));
      } else {
        // 新建一条记录
        String usql = "insert into sys_tableid(max_value, table_name) values(0, ?)";
        DaoParam uparam = _dao.createParam(usql);
        uparam.addStringValue(keyName);
        if (!_dao.update(uparam)) {
          _log.showWarn("get next keyid no update error!! tablename={0}!!", keyName);
        }
      }

      keyMax = dbmax + poolSize;
      keyMin = dbmax + 1;
      nextKey = keyMin;
    }
Exemplo n.º 3
0
  /**
   * 删除公告消息时,同时删除所有的阅读记录
   *
   * @param msgId -- 消息ID
   * @return
   */
  public String deleteBoard(String msgId) {
    String sql = "delete from plet_read where msg_id = ?";
    DaoParam param = _dao.createParam(sql);
    param.addStringValue(msgId);
    _dao.update(param);

    return _returnSuccess;
  }
Exemplo n.º 4
0
  /**
   * 是否有设计信息
   *
   * @param funcId
   * @param pageType
   * @return
   */
  private boolean hasDesign(String funcId, String pageType) {
    String sql = "select count(*) as cnt from fun_design where fun_id = ? and page_type = ?";
    DaoParam param = _dao.createParam(sql);
    param.setDsName(DefineName.DESIGN_NAME);
    param.addStringValue(funcId).addStringValue(pageType);
    Map<String, String> mpcnt = _dao.queryMap(param);

    return MapUtil.hasRecord(mpcnt);
  }
Exemplo n.º 5
0
 /**
  * 修改公告状态为“新”
  *
  * @param msgId
  * @return
  */
 private void sendMsg(String msgId) throws BoException {
   String usql = "update plet_msg set msg_state = '1', send_date = ? where msg_id = ?";
   DaoParam param = _dao.createParam(usql);
   param.addDateValue(DateUtil.getTodaySec());
   param.addStringValue(msgId);
   boolean bu = _dao.update(param);
   if (!bu) {
     // "发布公告失败:修改公告状态为“新”失败!"
     throw new BoException(JsMessage.getValue("portlet.boarderror"));
   }
 }
Exemplo n.º 6
0
  /**
   * 取用户所属角色的模板信息
   *
   * @param userId -- 用户ID
   * @return
   */
  private List<Map<String, String>> queryTemplet(String userId) {
    StringBuilder sql = new StringBuilder();
    sql.append("select templet_no, templet_name, col_num, col_width, templet_id ");
    sql.append("from plet_templet where templet_id in ");
    sql.append("(select sys_role.templet_id from sys_role, sys_user_role where ");
    sql.append("sys_role.role_id = sys_user_role.role_id and sys_user_role.user_id = ?) ");
    sql.append("order by templet_no ");

    DaoParam param = _dao.createParam(sql.toString());
    param.addStringValue(userId);
    return _dao.query(param);
  }
Exemplo n.º 7
0
    public int getNextKey() {
      if (nextKey > keyMax) {
        retrieveFromDB();
      }

      // 每次取新号时,更新当前最大值;采用累加1的方式可以解决多线程多事务累加不丢失的问题。
      String usql = "update sys_tableid set max_value = max_value + 1 where table_name = ?";
      DaoParam uparam = _dao.createParam(usql);
      uparam.addStringValue(keyName);
      if (!_dao.update(uparam)) {
        _log.showWarn("get next code no update error!! tablename={0}!!", keyName);
      }

      return nextKey++;
    }
Exemplo n.º 8
0
  /**
   * 取模板栏目内容的详细信息
   *
   * @param templetId -- 模板ID
   * @return
   */
  private List<Map<String, String>> queryPortlet(String templetId) {
    StringBuilder sql = new StringBuilder();
    sql.append("select plet_type.type_code, plet_type.iconcls, plet_type.height, ");
    sql.append("plet_portlet.portlet_id, plet_portlet.portlet_no, ");
    sql.append("plet_portlet.portlet_title, plet_portlet.collapse,");
    sql.append("plet_portlet.col_no, plet_portlet.templet_id, ");
    sql.append("plet_portlet.object_id, plet_portlet.object_name ");
    sql.append("from plet_portlet, plet_type ");
    sql.append(
        "where plet_portlet.type_code = plet_type.type_code and plet_portlet.templet_id = ? ");
    sql.append("order by plet_portlet.col_no, plet_portlet.portlet_no ");

    DaoParam param = _dao.createParam(sql.toString());
    param.addStringValue(templetId);
    return _dao.query(param);
  }
Exemplo n.º 9
0
  /**
   * 创建新的树型记录ID
   *
   * @param parentID
   * @param level
   * @param tableName
   * @param pkField
   * @param levelCol
   * @param dsName
   * @return
   */
  public synchronized String createTreeKey(
      String parentID,
      int level,
      String tableName,
      String pkField,
      String levelCol,
      String dsName) {
    if (parentID == null) parentID = "";

    StringBuilder selsql = new StringBuilder();
    StringBuilder wheresql = new StringBuilder();
    selsql.append(" select max(" + pkField + ") as maxval, count(" + pkField + ") as cnt ");
    wheresql.append(" from " + tableName);
    if (parentID.length() == 0) {
      wheresql.append(" where " + pkField + " like '%' ");
      wheresql.append(" and " + levelCol + " = " + level);
    } else {
      wheresql.append(" where " + pkField + " like '" + parentID + "%' ");
      wheresql.append(" and " + levelCol + " = " + level);
    }
    selsql.append(wheresql);

    _log.showDebug("treeid selectsql = " + selsql.toString());

    DaoParam param = _dao.createParam(selsql.toString());
    param.setDsName(dsName);
    Map<String, String> keyMap = _dao.queryMap(param);

    String maxVal = keyMap.get("maxval");
    if (maxVal.length() == 0) {
      if (parentID.length() == 0) {
        return "1001";
      } else {
        // 本级别第一个节点
        return parentID + "0001";
      }
    } else {
      if (maxVal.equals("9999")) {
        _log.showWarn("treeid exceed 9999!");
        return "9999";
      }
    }
    maxVal = "0000" + (Long.parseLong(maxVal) + 1);
    String treeID = parentID + maxVal.substring(maxVal.length() - 4, maxVal.length());

    return treeID;
  }
Exemplo n.º 10
0
  // 新增设计信息
  private boolean insertDesign(String funcId, String pageType, String content) {
    String sql = "insert into fun_design(design_id, fun_id, page_type) " + "values(?, ?, ?)";

    // 创建主键
    String keyId = KeyCreator.getInstance().createKey("fun_design");

    DaoParam param = _dao.createParam(sql);
    param.setDsName(DefineName.DESIGN_NAME);
    param.addStringValue(keyId).addStringValue(funcId).addStringValue(pageType);

    _dao.update(param);

    // 保存大字段信息
    String usql = "update fun_design set page_content = ? where design_id = '" + keyId + "'";

    return BigFieldUtil.updateStream(usql, content, DefineName.DESIGN_NAME);
  }