11using System . Text . Json ;
22using Juggle . Application . Models . Request ;
33using Juggle . Application . Models . Response ;
4+ using Juggle . Application . Services ;
45using Juggle . Application . Services . Flow ;
56using Juggle . Domain . Entities ;
67using Juggle . Infrastructure . Persistence ;
@@ -17,11 +18,13 @@ public class FlowDefinitionController : ControllerBase
1718{
1819 private readonly JuggleDbContext _db ;
1920 private readonly FlowExecutionService _flowExec ;
21+ private readonly ITenantAccessor _tenant ;
2022
21- public FlowDefinitionController ( JuggleDbContext db , FlowExecutionService flowExec )
23+ public FlowDefinitionController ( JuggleDbContext db , FlowExecutionService flowExec , ITenantAccessor tenant )
2224 {
2325 _db = db ;
2426 _flowExec = flowExec ;
27+ _tenant = tenant ;
2528 }
2629
2730 [ HttpPost ( "add" ) ]
@@ -37,6 +40,7 @@ public async Task<ApiResult> Add([FromBody] FlowDefinitionAddRequest req)
3740 GroupName = req . GroupName ,
3841 FlowContent = "[]" ,
3942 Status = 0 ,
43+ TenantId = _tenant . TenantId ,
4044 CreatedAt = DateTime . Now . ToString ( "o" )
4145 } ;
4246 _db . FlowDefinitions . Add ( entity ) ;
@@ -258,6 +262,7 @@ public async Task<ApiResult> Import([FromBody] System.Text.Json.JsonElement body
258262 FlowType = flowType ,
259263 FlowContent = flowContent ,
260264 Status = 0 ,
265+ TenantId = _tenant . TenantId ,
261266 CreatedAt = DateTime . Now . ToString ( "o" )
262267 } ;
263268 _db . FlowDefinitions . Add ( entity ) ;
@@ -320,6 +325,7 @@ public async Task<ApiResult> Clone(long id)
320325 GroupName = source . GroupName ,
321326 FlowContent = source . FlowContent ,
322327 Status = 0 ,
328+ TenantId = _tenant . TenantId ,
323329 CreatedAt = DateTime . Now . ToString ( "o" )
324330 } ;
325331 _db . FlowDefinitions . Add ( cloned ) ;
@@ -394,6 +400,7 @@ public async Task<ApiResult> Deploy([FromBody] FlowDeployRequest req)
394400 FlowDesc = definition . FlowDesc ,
395401 FlowType = definition . FlowType ,
396402 Status = 1 ,
403+ TenantId = _tenant . TenantId ,
397404 CreatedAt = DateTime . Now . ToString ( "o" )
398405 } ;
399406 _db . FlowInfos . Add ( flowInfo ) ;
@@ -419,6 +426,7 @@ public async Task<ApiResult> Deploy([FromBody] FlowDeployRequest req)
419426 Version = newVersion ,
420427 FlowContent = definition . FlowContent ,
421428 Status = 1 ,
429+ TenantId = _tenant . TenantId ,
422430 CreatedAt = DateTime . Now . ToString ( "o" )
423431 } ;
424432 _db . FlowVersions . Add ( flowVersion ) ;
0 commit comments