2
2
3
3
import io .swagger .annotations .Api ;
4
4
import io .swagger .annotations .ApiOperation ;
5
+ import io .swagger .annotations .ResponseHeader ;
5
6
import org .hswebframework .web .authorization .Permission ;
6
7
import org .hswebframework .web .authorization .annotation .Authorize ;
8
+ import org .hswebframework .web .authorization .annotation .Logical ;
7
9
import org .hswebframework .web .commons .entity .PagerResult ;
8
10
import org .hswebframework .web .commons .entity .param .DeleteParamEntity ;
9
11
import org .hswebframework .web .commons .entity .param .QueryParamEntity ;
10
12
import org .hswebframework .web .commons .entity .param .UpdateParamEntity ;
11
13
import org .hswebframework .web .controller .message .ResponseMessage ;
12
14
import org .hswebframework .web .service .form .DynamicFormOperationService ;
13
15
import org .springframework .beans .factory .annotation .Autowired ;
16
+ import org .springframework .http .HttpStatus ;
14
17
import org .springframework .web .bind .annotation .*;
15
18
16
19
import java .util .List ;
@@ -45,7 +48,7 @@ public ResponseMessage<PagerResult<Object>> selectPager(@PathVariable String for
45
48
@ GetMapping ("/{formId}/no-paging" )
46
49
@ ApiOperation ("不分页动态查询" )
47
50
@ Authorize (action = Permission .ACTION_QUERY )
48
- public ResponseMessage <List <Object >> select (@ PathVariable String formId , QueryParamEntity paramEntity ) {
51
+ public ResponseMessage <List <Object >> selectNoPaging (@ PathVariable String formId , QueryParamEntity paramEntity ) {
49
52
paramEntity .setPaging (false );
50
53
return ResponseMessage .ok (dynamicFormOperationService .select (formId , paramEntity ));
51
54
}
@@ -67,34 +70,42 @@ public ResponseMessage<Object> selectCount(@PathVariable String formId, QueryPar
67
70
@ PostMapping ("/{formId}" )
68
71
@ ApiOperation ("新增" )
69
72
@ Authorize (action = Permission .ACTION_ADD )
73
+ @ ResponseStatus (HttpStatus .CREATED )
70
74
public ResponseMessage <Map <String , Object >> add (@ PathVariable String formId ,
71
75
@ RequestBody Map <String , Object > data ) {
72
- dynamicFormOperationService .insert (formId , data );
73
- return ResponseMessage .ok (data );
76
+ return ResponseMessage .ok (dynamicFormOperationService .insert (formId , data ));
77
+ }
78
+
79
+ @ PatchMapping ("/{formId}" )
80
+ @ ApiOperation ("新增或者修改" )
81
+ @ Authorize (action = {Permission .ACTION_ADD , Permission .ACTION_UPDATE }, logical = Logical .OR )
82
+ public ResponseMessage <Object > saveOrUpdate (@ PathVariable String formId ,
83
+ @ RequestBody Map <String , Object > data ) {
84
+ return ResponseMessage .ok (dynamicFormOperationService .saveOrUpdate (formId , data ));
74
85
}
75
86
76
87
@ PutMapping ("/{formId}" )
77
88
@ ApiOperation ("动态修改" )
78
89
@ Authorize (action = Permission .ACTION_UPDATE )
79
- public ResponseMessage <Integer > update (@ PathVariable String formId ,
80
- @ RequestBody UpdateParamEntity <Map <String , Object >> paramEntity ) {
90
+ public ResponseMessage <Integer > dynamicUpdate (@ PathVariable String formId ,
91
+ @ RequestBody UpdateParamEntity <Map <String , Object >> paramEntity ) {
81
92
return ResponseMessage .ok (dynamicFormOperationService .update (formId , paramEntity ));
82
93
}
83
94
84
95
@ PutMapping ("/{formId}/{id}" )
85
96
@ ApiOperation ("根据主键修改" )
86
97
@ Authorize (action = Permission .ACTION_UPDATE )
87
- public ResponseMessage <Map <String , Object >> update (@ PathVariable String formId ,
88
- @ PathVariable String id ,
89
- @ RequestBody Map <String , Object > param ) {
98
+ public ResponseMessage <Map <String , Object >> updateById (@ PathVariable String formId ,
99
+ @ PathVariable String id ,
100
+ @ RequestBody Map <String , Object > param ) {
90
101
return ResponseMessage .ok (dynamicFormOperationService .updateById (formId , id , param ));
91
102
}
92
103
93
104
@ DeleteMapping ("/{formId}/{id}" )
94
105
@ ApiOperation ("根据主键删除" )
95
106
@ Authorize (action = Permission .ACTION_DELETE )
96
- public ResponseMessage <Integer > delete (@ PathVariable String formId ,
97
- @ PathVariable String id ) {
107
+ public ResponseMessage <Integer > deleteById (@ PathVariable String formId ,
108
+ @ PathVariable String id ) {
98
109
return ResponseMessage .ok (dynamicFormOperationService .deleteById (formId , id ));
99
110
}
100
111
}
0 commit comments