polishing the workspace migration

This commit is contained in:
2026-06-22 13:40:58 +02:00
parent caf4e4bc89
commit 598287b0cc
43 changed files with 730 additions and 167 deletions

View File

@@ -6,7 +6,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import zw.qantra.tm.domain.dtos.erp.VelocityAccountDto;
import zw.qantra.tm.domain.dtos.erp.VelocityStatementDto;
import zw.qantra.tm.domain.models.Workspace;
import zw.qantra.tm.domain.services.VelocityAccountService;
import zw.qantra.tm.domain.services.WorkspaceService;
import java.util.UUID;
@RestController
@RequestMapping("/accounts")
@@ -14,12 +18,17 @@ import zw.qantra.tm.domain.services.VelocityAccountService;
public class AccountController {
private final VelocityAccountService velocityAccountService;
private final WorkspaceService workspaceService;
@GetMapping("/phone/{currencyPhoneConcat}")
@PreAuthorize("hasRole('ACCOUNT_READ')")
public ResponseEntity<VelocityAccountDto> getAccountByPhone(
@PathVariable String currencyPhoneConcat) {
@GetMapping("/{workspaceId}/balance/{currency}")
public ResponseEntity<VelocityAccountDto> getAccount(
@PathVariable UUID workspaceId,
@PathVariable String currency
) {
try {
Workspace workspace = workspaceService.getWorkspace(workspaceId)
.orElseThrow(() -> new IllegalArgumentException("Workspace not found"));
String currencyPhoneConcat = currency + workspace.getPhone();
VelocityAccountDto account = velocityAccountService.getAccountByPhone(currencyPhoneConcat);
return ResponseEntity.ok(account);
} catch (Exception e) {
@@ -27,13 +36,16 @@ public class AccountController {
}
}
@GetMapping("/phone/{currencyPhoneConcat}/statement")
@PreAuthorize("hasRole('ACCOUNT_READ')")
public ResponseEntity<VelocityStatementDto> getStatementByPhone(
@PathVariable String currencyPhoneConcat,
@GetMapping("/{workspaceId}/statement/{currency}")
public ResponseEntity<VelocityStatementDto> getStatement(
@PathVariable UUID workspaceId,
@PathVariable String currency,
@RequestParam String startDate,
@RequestParam String endDate) {
try {
Workspace workspace = workspaceService.getWorkspace(workspaceId)
.orElseThrow(() -> new IllegalArgumentException("Workspace not found"));
String currencyPhoneConcat = currency + workspace.getPhone();
VelocityStatementDto statement = velocityAccountService.getStatementByPhone(
currencyPhoneConcat, startDate, endDate);
return ResponseEntity.ok(statement);