|
|
|
@ -75,6 +75,10 @@ public class OnlinePageController { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IOnlFormFieldService onlFormFieldService; |
|
|
|
private IOnlFormFieldService onlFormFieldService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//new=新建元数据,exist=现有元数据
|
|
|
|
|
|
|
|
private static final String META_SOURCE_NEW = "new"; |
|
|
|
|
|
|
|
private static final String META_SOURCE_EXIST = "exist"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 新增在线表单页面数据。 |
|
|
|
* 新增在线表单页面数据。 |
|
|
|
* |
|
|
|
* |
|
|
|
@ -85,14 +89,14 @@ public class OnlinePageController { |
|
|
|
@OperationLog(type = SysOperationLogType.ADD) |
|
|
|
@OperationLog(type = SysOperationLogType.ADD) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@PostMapping("/add") |
|
|
|
@PostMapping("/add") |
|
|
|
public ResponseResult<Long> add(@MyRequestBody OnlinePageDto onlinePageDto) { |
|
|
|
public ResponseResult<OnlinePage> add(@MyRequestBody OnlinePageDto onlinePageDto) { |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto); |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto); |
|
|
|
if (errorMessage != null) { |
|
|
|
if (errorMessage != null) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
// Validate based on metaSource
|
|
|
|
// Validate based on metaSource
|
|
|
|
String metaSource = onlinePageDto.getMetaSource(); |
|
|
|
String metaSource = onlinePageDto.getMetaSource(); |
|
|
|
if ("new".equals(metaSource)) { |
|
|
|
if (META_SOURCE_NEW.equals(metaSource)) { |
|
|
|
// New metadata flow: metaType and pageCode are required
|
|
|
|
// New metadata flow: metaType and pageCode are required
|
|
|
|
if (StrUtil.isEmpty(onlinePageDto.getMetaType())) { |
|
|
|
if (StrUtil.isEmpty(onlinePageDto.getMetaType())) { |
|
|
|
errorMessage = "数据验证失败,新建元数据时表类型(metaType)不能为空!"; |
|
|
|
errorMessage = "数据验证失败,新建元数据时表类型(metaType)不能为空!"; |
|
|
|
@ -115,17 +119,16 @@ public class OnlinePageController { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Long masterTableId; |
|
|
|
|
|
|
|
OnlFormHead onlFormHead; |
|
|
|
OnlFormHead onlFormHead; |
|
|
|
|
|
|
|
|
|
|
|
if ("new".equals(metaSource)) { |
|
|
|
if (META_SOURCE_NEW.equals(metaSource)) { |
|
|
|
// === New branch: create fresh metadata ===
|
|
|
|
// === New branch: create fresh metadata ===
|
|
|
|
String metaType = onlinePageDto.getMetaType(); |
|
|
|
String metaType = onlinePageDto.getMetaType(); |
|
|
|
String tableName = onlinePageDto.getPageCode(); |
|
|
|
String tableName = onlinePageDto.getPageCode(); |
|
|
|
String tableTxt = onlinePageDto.getPageName(); |
|
|
|
String tableTxt = onlinePageDto.getPageName(); |
|
|
|
|
|
|
|
|
|
|
|
onlFormHead = iOnlFormHeadService.createMetaAndSync(tableName, tableTxt, metaType, null); |
|
|
|
onlFormHead = iOnlFormHeadService.createMetaAndSync(tableName, tableTxt, metaType, null); |
|
|
|
masterTableId = onlFormHead.getId(); |
|
|
|
Long masterTableId = onlFormHead.getId(); |
|
|
|
onlinePage.setMasterTableId(String.valueOf(masterTableId)); |
|
|
|
onlinePage.setMasterTableId(String.valueOf(masterTableId)); |
|
|
|
onlinePage.setMasterTableName(onlFormHead.getTableName()); |
|
|
|
onlinePage.setMasterTableName(onlFormHead.getTableName()); |
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +141,6 @@ public class OnlinePageController { |
|
|
|
// === Existing branch: use existing metadata ===
|
|
|
|
// === Existing branch: use existing metadata ===
|
|
|
|
String formMetadata = onlinePageDto.getMasterTableId(); |
|
|
|
String formMetadata = onlinePageDto.getMasterTableId(); |
|
|
|
onlFormHead = iOnlFormHeadService.getById(formMetadata); |
|
|
|
onlFormHead = iOnlFormHeadService.getById(formMetadata); |
|
|
|
masterTableId = Long.valueOf(formMetadata); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -179,7 +181,7 @@ public class OnlinePageController { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
addOnlineDatasourceRelation(onlFormHead, onlineDatasource, errorMessage, onlineDblink); |
|
|
|
addOnlineDatasourceRelation(onlFormHead, onlineDatasource, errorMessage, onlineDblink); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseResult.success(onlinePage.getPageId()); |
|
|
|
return ResponseResult.success(onlinePage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|