/** * 获取编辑的字段实体的信息 * * @param mode * @param fieldId :要获取的字段实体的id * @param request * @return */ @RequestMapping("/{diyFormFieldId}/edit") @ResponseBody public ModelMap edit( ModelMap mode, @PathVariable int diyFormFieldId, HttpServletRequest request) { DiyFormFieldEntity diyFormfield = (DiyFormFieldEntity) diyFormFieldBiz.getEntity(diyFormFieldId); mode.addAttribute("diyFormfield", diyFormfield); return mode; }
/** * 更新字段信息 * * @param field 要更新的字段信息的id * @param response */ @RequestMapping("/update") @ResponseBody public void update( @ModelAttribute DiyFormFieldEntity diyFormfield, HttpServletResponse response) { // 更新前判断数据是否合法 if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldTipsName(), 1, 20)) { this.outJson( response, null, false, getResString("err.length", this.getResString("fieldTipsName"), "1", "20")); return; } if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldFieldName(), 1, 20)) { this.outJson( response, null, false, getResString("err.length", this.getResString("fieldFieldName"), "1", "20")); return; } // 获取自定义表单实体 DiyFormEntity diyForm = (DiyFormEntity) diyFormBiz.getEntity(diyFormfield.getDiyFormFieldFormId()); // 读取属性配置文件 Map<String, String> maps = new LinkedHashMap<String, String>(); maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type"); // 获取更改前的字段实体 DiyFormFieldEntity oldField = (DiyFormFieldEntity) diyFormFieldBiz.getEntity(diyFormfield.getDiyFormFieldId()); Map fields = new HashMap(); // 更改前的字段名 fields.put("fieldOldName", oldField.getDiyFormFieldFieldName()); // 新字段名 fields.put("fieldName", diyFormfield.getDiyFormFieldFieldName()); // 字段的数据类型 fields.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType()))); if (diyForm == null) { this.outJson(response, null, false, this.getResString("err.not.exist")); return; } // 更新表的字段名 diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fields, "modify"); diyFormFieldBiz.updateEntity(diyFormfield); this.outJson(response, null, true, null); }