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