*/
@RequestMapping(params = "save")
@ResponseBody
public AjaxJson save(CgFormHeadEntity cgFormHead,
HttpServletRequest request) {
AjaxJson j = new AjaxJson();
CgFormHeadEntity oldTable =cgFormFieldService.getEntity(CgFormHeadEntity.class, cgFormHead.getId());
cgFormFieldService.removeSubTableStr4Main(oldTable);
//step.1 如果数据表已经创建,则不能更改主键策略(后续通过强制同步解决此问题)
/*if(cgFormHead.getId()!=null){
boolean tableexist = cgFormFieldService.checkTableExist(cgFormHead.getTableName());
if(tableexist){
if(!cgFormHead.getJformPkType().equalsIgnoreCase(oldTable.getJformPkType())){
if((cgFormHead.getJformPkType().equalsIgnoreCase("NATIVE")||cgFormHead.getJformPkType().equalsIgnoreCase("SEQUENCE"))
&&(oldTable.getJformPkType().equalsIgnoreCase("NATIVE")||oldTable.getJformPkType().equalsIgnoreCase("SEQUENCE"))){
//native和sequence可以互转
}else{
throw new org.jeecgframework.core.common.exception.BusinessException("数据表已经创建,不能更换主键策略");
}
}
}
}
*/
//step.2 判定表格是否存在
CgFormHeadEntity table = judgeTableIsNotExit(cgFormHead,oldTable);
//step.3 刷新orderNum并且去重复
refreshFormFieldOrderNum(cgFormHead);
if (StringUtil.isNotEmpty(cgFormHead.getId())&&table!=null) {
List<CgFormFieldEntity> formFieldEntities = table.getColumns();
for (CgFormFieldEntity cgFormFieldEntity : formFieldEntities) {
if (StringUtil.isEmpty(cgFormFieldEntity.getOldFieldName())
&& StringUtil.isNotEmpty(cgFormFieldEntity.getFieldName())) {
cgFormFieldEntity.setFieldName(cgFormFieldEntity.getFieldName().toLowerCase());
cgFormFieldEntity.setOldFieldName(cgFormFieldEntity.getFieldName());
}
}
cgFormFieldService.updateTable(table,null);
cgFormFieldService.appendSubTableStr4Main(table);
cgFormFieldService.sortSubTableStr(table);
systemService.addLog(message, Globals.Log_Type_UPDATE,
Globals.Log_Leavel_INFO);
} else if (StringUtil.isEmpty(cgFormHead.getId())&&table==null) {
List<CgFormFieldEntity> formFieldEntities = cgFormHead.getColumns();
for (CgFormFieldEntity cgFormFieldEntity : formFieldEntities) {
if (StringUtil.isEmpty(cgFormFieldEntity.getOldFieldName())) {
cgFormFieldEntity.setFieldName(cgFormFieldEntity.getFieldName().toLowerCase());
cgFormFieldEntity.setOldFieldName(cgFormFieldEntity.getFieldName());
}
}
cgFormFieldService.saveTable(cgFormHead);
systemService.addLog(message, Globals.Log_Type_INSERT,
Globals.Log_Leavel_INFO);
}
j.setMsg(message);
return j;
}