Ejemplo n.º 1
0
 /**
  * 删除自定义字段
  *
  * @param cmId 表单ID
  * @param request 请求
  * @param response 响应
  */
 @RequestMapping("/{fieldId}/delete")
 public void delete(
     @PathVariable int fieldId, HttpServletRequest request, HttpServletResponse response) {
   //
   DiyFormFieldEntity diyFormField = (DiyFormFieldEntity) this.diyFormFieldBiz.getEntity(fieldId);
   if (diyFormField == null) {
     this.outJson(
         response,
         null,
         false,
         this.getResString("err.not.exist", this.getResString("diy.form.field")));
     return;
   }
   DiyFormEntity diyForm =
       (DiyFormEntity) this.diyFormBiz.getEntity(diyFormField.getDiyFormFieldFormId());
   if (diyForm == null) {
     this.outJson(
         response, null, false, this.getResString("err.not.exist", this.getResString("diy.form")));
     return;
   }
   Map fields = new HashMap();
   // 要删除的字段名
   fields.put("fieldName", diyFormField.getDiyFormFieldFieldName());
   // 删除列
   diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fields, "drop");
   diyFormFieldBiz.deleteEntity(diyFormField.getDiyFormFieldId());
   this.outJson(response, null, true);
 }
Ejemplo n.º 2
0
  /**
   * 更新字段信息
   *
   * @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);
  }
Ejemplo n.º 3
0
  /**
   * @param diyFormfield
   * @param cmTableName
   * @param response
   */
  @RequestMapping("/{diyFormId}/save")
  @ResponseBody
  public void save(
      @ModelAttribute DiyFormFieldEntity diyFormfield,
      @PathVariable int diyFormId,
      HttpServletResponse response) {
    // 获取自定义表单实体
    DiyFormEntity diyForm = (DiyFormEntity) diyFormBiz.getEntity(diyFormId);
    if (diyForm == null) {
      this.outJson(
          response, null, false, this.getResString("err.not.exist", this.getResString("diy.form")));
      return;
    }
    // 更新前判断数据是否合法
    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;
    }

    // 读取属性配置文件
    Map<String, String> maps = new LinkedHashMap<String, String>();
    maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type");
    // 动态的修改表结构
    // 获取字段信息
    Map fileds = new HashMap();
    // 压入字段名
    fileds.put("fieldName", diyFormfield.getDiyFormFieldFieldName());
    // 字段的数据类型
    fileds.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType())));
    fileds.put("default", diyFormfield.getDiyFormFieldDefault());
    // 在表中创建字段
    diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fileds, "add");
    this.diyFormFieldBiz.saveEntity(diyFormfield);
    this.outJson(response, null, true, null);
  }