1212import io .swagger .v3 .oas .annotations .media .Schema ;
1313import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
1414import io .swagger .v3 .oas .annotations .tags .Tag ;
15+ import jakarta .validation .Valid ;
16+ import lombok .extern .slf4j .Slf4j ;
1517import org .springframework .beans .factory .annotation .Autowired ;
1618import org .springframework .validation .annotation .Validated ;
1719import org .springframework .web .bind .annotation .*;
1820
1921import java .util .Map ;
2022
2123@ Validated
24+ @ Slf4j
2225@ RestController
2326@ RequestMapping ("/platform-center/api" )
2427@ Tag (name = "模型数据" )
@@ -38,13 +41,13 @@ public class ModelDataController {
3841 })
3942 @ SystemControllerLog (description = "模型数据查询" )
4043 @ PostMapping ("/model-data/queryApi" )
41- public Result <Map <String , Object >> query (@ RequestBody DynamicQuery dto ) {
44+ public Result <Map <String , Object >> query (@ RequestBody @ Valid DynamicQuery dto ) {
4245
43-
44- try {
46+ try {
4547 return Result .success (dynamicService .queryWithPage (dto ));
4648 } catch (Exception e ) {
47- return Result .failed (e .getMessage ());
49+ log .error ("Query failed for table: {}" , dto .getNameEn (), e );
50+ return Result .failed ("Query operation failed" );
4851 }
4952
5053 }
@@ -61,13 +64,13 @@ public Result<Map<String, Object>> query(@RequestBody DynamicQuery dto) {
6164 })
6265 @ SystemControllerLog (description = "新增模型数据" )
6366 @ PostMapping ("/model-data/insertApi" )
64- public Result <Map <String , Object > > insert (@ RequestBody DynamicInsert dto ) {
65-
67+ public Result <Map <String , Object > > insert (@ RequestBody @ Valid DynamicInsert dto ) {
6668
6769 try {
6870 return Result .success (dynamicService .insert (dto ));
6971 } catch (Exception e ) {
70- return Result .failed (e .getMessage ());
72+ log .error ("insert failed for table: {}" , dto .getNameEn (), e );
73+ return Result .failed ("insert operation failed" );
7174 }
7275
7376 }
@@ -84,13 +87,13 @@ public Result<Map<String, Object> > insert(@RequestBody DynamicInsert dto) {
8487 })
8588 @ SystemControllerLog (description = "更新模型数据" )
8689 @ PostMapping ("/model-data/updateApi" )
87- public Result <Map <String , Object > > update (@ RequestBody DynamicUpdate dto ) {
88-
90+ public Result <Map <String , Object > > update (@ RequestBody @ Valid DynamicUpdate dto ) {
8991
9092 try {
9193 return Result .success (dynamicService .update (dto ));
9294 } catch (Exception e ) {
93- return Result .failed (e .getMessage ());
95+ log .error ("updateApi failed for table: {}" , dto .getNameEn (), e );
96+ return Result .failed ("update operation failed" );
9497 }
9598
9699 }
@@ -106,11 +109,12 @@ public Result<Map<String, Object> > update(@RequestBody DynamicUpdate dto) {
106109 })
107110 @ SystemControllerLog (description = "刪除模型数据" )
108111 @ PostMapping ("/model-data/deleteApi" )
109- public Result <Map <String , Object > > delete (@ RequestBody DynamicDelete dto ) {
112+ public Result <Map <String , Object > > delete (@ RequestBody @ Valid DynamicDelete dto ) {
110113 try {
111114 return Result .success (dynamicService .delete (dto ));
112115 } catch (Exception e ) {
113- return Result .failed (e .getMessage ());
116+ log .error ("deleteApi failed for table: {}" , dto .getNameEn (), e );
117+ return Result .failed ("delete operation failed" );
114118 }
115119 }
116120}
0 commit comments