/** * 删除设计信息。 * * @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; }
/** * 是否有设计信息 * * @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); }
/** * 创建新的树型记录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; }
// 新增设计信息 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); }