1010import org .lowcoder .api .framework .view .PageResponseView ;
1111import org .lowcoder .api .framework .view .ResponseView ;
1212import org .lowcoder .api .permission .view .CommonPermissionView ;
13+ import org .lowcoder .api .usermanagement .view .UpdateGroupRequest ;
1314import org .lowcoder .api .util .BusinessEventPublisher ;
1415import org .lowcoder .api .util .GidService ;
1516import org .lowcoder .domain .datasource .model .Datasource ;
@@ -52,7 +53,7 @@ public class DatasourceController implements DatasourceEndpoints
5253 public Mono <ResponseView <Datasource >> create (@ Valid @ RequestBody UpsertDatasourceRequest request ) {
5354 return datasourceApiService .create (upsertDatasourceRequestMapper .resolve (request ))
5455 .delayUntil (datasourceService ::removePasswordTypeKeysFromJsDatasourcePluginConfig )
55- .delayUntil (datasource -> businessEventPublisher .publishDatasourceEvent (datasource , DATA_SOURCE_CREATE ))
56+ .delayUntil (datasource -> businessEventPublisher .publishDatasourceEvent (datasource , DATA_SOURCE_CREATE , null ))
5657 .map (ResponseView ::success );
5758 }
5859
@@ -69,23 +70,25 @@ public Mono<ResponseView<Datasource>> update(@PathVariable String id,
6970 @ RequestBody UpsertDatasourceRequest request ) {
7071 Datasource resolvedDatasource = upsertDatasourceRequestMapper .resolve (request );
7172 return gidService .convertDatasourceIdToObjectId (id ).flatMap (objectId ->
72- datasourceApiService .update (objectId , resolvedDatasource )
73- .delayUntil (datasourceService ::removePasswordTypeKeysFromJsDatasourcePluginConfig )
74- .delayUntil (datasource -> businessEventPublisher .publishDatasourceEvent (datasource , DATA_SOURCE_UPDATE ))
75- .map (ResponseView ::success ));
73+ datasourceService .getById (id ).flatMap (orgDatasource ->
74+ datasourceApiService .update (objectId , resolvedDatasource )
75+ .delayUntil (datasourceService ::removePasswordTypeKeysFromJsDatasourcePluginConfig )
76+ .delayUntil (datasource -> businessEventPublisher .publishDatasourceEvent (datasource , DATA_SOURCE_UPDATE , orgDatasource .getName ()))
77+ .map (ResponseView ::success )));
7678 }
7779
7880 @ Override
7981 public Mono <ResponseView <Boolean >> delete (@ PathVariable String id ) {
8082 return gidService .convertDatasourceIdToObjectId (id ).flatMap (objectId ->
81- datasourceApiService .delete (objectId )
82- .delayUntil (result -> {
83- if (BooleanUtils .isTrue (result )) {
84- return businessEventPublisher .publishDatasourceEvent (objectId , DATA_SOURCE_DELETE );
85- }
86- return Mono .empty ();
87- })
88- .map (ResponseView ::success ));
83+ datasourceService .getById (id ).flatMap (orgDatasource ->
84+ datasourceApiService .delete (objectId )
85+ .delayUntil (result -> {
86+ if (BooleanUtils .isTrue (result )) {
87+ return businessEventPublisher .publishDatasourceEvent (objectId , DATA_SOURCE_DELETE , orgDatasource .getName ());
88+ }
89+ return Mono .empty ();
90+ })
91+ .map (ResponseView ::success )));
8992 }
9093
9194 @ Override
0 commit comments