public synchronized void updateTable(CgFormHeadEntity t, String sign) { CgFormFieldEntity column; boolean databaseFieldIsChange = false; for (int i = 0; i < t.getColumns().size(); i++) { column = t.getColumns().get(i); if (oConvertUtils.isEmpty(column.getFieldName())) { continue; } column.setTable(t); // 设置checkbox的值 PublicUtil.judgeCheckboxValue(column, "isNull,isShow,isShowList,isQuery,isKey"); if (oConvertUtils.isEmpty(column.getId())) { databaseFieldIsChange = true; this.save(column); } else { CgFormFieldEntity c = this.getEntity(CgFormFieldEntity.class, column.getId()); if (!databaseFieldIsChange && databaseFieldIsChange(c, column)) { databaseFieldIsChange = true; } try { MyBeanUtils.copyBeanNotNull2Bean(column, c); } catch (Exception e) { e.printStackTrace(); logger.error(e); } this.saveOrUpdate(c); } } t.setIsDbSynch(databaseFieldIsChange ? "N" : t.getIsDbSynch()); // 表单配置修改,版本号未升级 Integer newVerion = Integer.parseInt(t.getJformVersion()) + 1; t.setJformVersion(newVerion.toString()); this.saveOrUpdate(t); }
/** * 添加通过JDBC访问数据库 * * @param ids * @return */ @RequestMapping(params = "save") @ResponseBody public AjaxJson save(SbJdbcEntity sbJdbc, HttpServletRequest request) { AjaxJson j = new AjaxJson(); if (StringUtil.isNotEmpty(sbJdbc.getId())) { message = "更新成功"; SbJdbcEntity t = sbJdbcService.get(SbJdbcEntity.class, sbJdbc.getId()); try { MyBeanUtils.copyBeanNotNull2Bean(sbJdbc, t); sbJdbcService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); } } else { message = "添加成功"; sbJdbcService.save(sbJdbc); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } return j; }