completed migration from user to workspace

This commit is contained in:
2026-06-22 22:11:20 +02:00
parent 598287b0cc
commit 299cdf6e35
10 changed files with 39 additions and 15 deletions

View File

@@ -55,7 +55,7 @@ public class RecipientGroupService {
* 5. Return the batch + any row-level errors
*/
@Transactional
public GroupCreateFromFileResult createFromFile(MultipartFile file, GroupCreateFromFileRequest request, UUID workspaceId) {
public GroupCreateFromFileResult createFromFile(MultipartFile file, GroupCreateFromFileRequest request) {
ParseResult parseResult = parseCsv(file);
if(!parseResult.parseErrors.isEmpty()) {
@@ -77,7 +77,8 @@ public class RecipientGroupService {
.name(row.name)
.account(row.account)
.phoneNumber(row.phone)
.workspaceId(workspaceId)
.userId(request.getUserId().toString())
.workspaceId(request.getWorkspaceId())
.build();
recipients.add(recipient);
}
@@ -86,15 +87,16 @@ public class RecipientGroupService {
RecipientGroup group = RecipientGroup.builder()
.name(request.getGroupName())
.description(request.getDescription())
.workspaceId(workspaceId)
.userId(request.getUserId().toString())
.workspaceId(request.getWorkspaceId())
.build();
RecipientGroup savedGroup = recipientGroupRepository.save(group);
List<RecipientGroupMember> members = addMembers(savedGroup.getId(), workspaceId, recipients);
List<RecipientGroupMember> members = addMembers(savedGroup.getId(), request.getWorkspaceId(), recipients);
// Step 3: create group batch (inline to avoid circular dependency with GroupBatchService)
GroupBatch batch = createBatchInline(savedGroup.getId(), workspaceId, request, members);
GroupBatch batch = createBatchInline(savedGroup.getId(), request.getWorkspaceId(), request, members);
// Step 4: update batch items with bill/provider fields from CSV
List<GroupBatchItem> batchItems = groupBatchItemRepository.findAllByGroupBatchId(batch.getId());
@@ -136,7 +138,7 @@ public class RecipientGroupService {
}
// Return the updated batch + errors
GroupBatch resultBatch = groupBatchRepository.findByIdAndWorkspaceId(batch.getId(), workspaceId)
GroupBatch resultBatch = groupBatchRepository.findByIdAndWorkspaceId(batch.getId(), request.getWorkspaceId())
.orElseThrow(() -> new ApiException("Batch not found after creation"));
return GroupCreateFromFileResult.builder()
@@ -157,6 +159,7 @@ public class RecipientGroupService {
List<RecipientGroupMember> members) {
GroupBatch batch = GroupBatch.builder()
.recipientGroupId(recipientGroupId)
.userId(request.getUserId().toString())
.workspaceId(workspaceId)
.description(request.getDescription())
.requestedBy(request.getRequestedBy())