feat(approvals): Approval Flow v2 프런트엔드 전면 개편

- 환경/라우터 모듈에 approval_flow_v2 토글을 추가하고 FeatureFlags 초기화를 연결 (.env*, lib/core/**)
- ApiClient 빌더·ApiRoutes 확장과 ApprovalRepositoryRemote 리팩터링으로 include·액션 시그니처를 정합화
- ApprovalFlow·ApprovalDraft 엔티티/레포/유즈케이스를 도입해 서버 초안과 단계 액션(승인·회수·재상신)을 지원
- Approval 컨트롤러·히스토리·템플릿 페이지와 공유 위젯을 재작성해 감사 로그·회수 UX·템플릿 CRUD를 반영
- Inbound/Outbound/Rental 컨트롤러·페이지에 결재 섹션을 삽입하고 대시보드 pending 카드 요약을 갱신
- SuperportDialog·FormField 등 공통 위젯을 보강하고 승인 위젯 가이드를 추가해 UI 가이드를 정리
- 결재/재고 테스트 픽스처와 단위·위젯·통합 테스트를 확장하고 flutter_test_config로 스테이징 호스트를 허용
- Approval Flow 레포트/플랜 문서를 업데이트하고 ApprovalFlow_System_Integration_and_ChangePlan.md를 추가
- 실행: flutter analyze, flutter test
This commit is contained in:
JiWoong Sul
2025-10-31 01:05:39 +09:00
parent 259b056072
commit d76f765814
133 changed files with 13878 additions and 947 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:collection';
import 'package:dio/dio.dart';
import 'api_error.dart';
@@ -14,6 +16,116 @@ class ApiClient {
final ApiErrorMapper _errorMapper;
static const _dataKey = 'data';
/// 경로 세그먼트를 조합해 일관된 요청 경로를 생성한다.
///
/// - 각 세그먼트의 선행/후행 `/`를 제거한 뒤 단일 슬래시로 결합한다.
/// - 첫 번째 세그먼트가 `/`로 시작하면 결과 역시 `/`를 유지한다.
static String buildPath(
Object base, [
Iterable<Object?> segments = const [],
]) {
final joined = <String>[];
var leadingSlash = false;
void append(Object? value, {bool isFirst = false}) {
if (value == null) {
return;
}
var text = value.toString();
if (text.isEmpty) {
return;
}
if (isFirst && text.startsWith('/')) {
leadingSlash = true;
}
text = text.replaceAll(RegExp(r'^/+'), '').replaceAll(RegExp(r'/+$'), '');
if (text.isEmpty) {
return;
}
joined.add(text);
}
append(base, isFirst: true);
for (final segment in segments) {
append(segment);
}
if (joined.isEmpty) {
return leadingSlash ? '/' : '';
}
final path = joined.join('/');
return leadingSlash ? '/$path' : path;
}
/// 페이지네이션/검색/필터 파라미터를 표준 규칙에 맞춰 구성한다.
///
/// - 문자열은 trim 후 빈 값이면 제외한다.
/// - `include`는 중복 제거 후 콤마로 연결한다.
/// - `DateTime`은 UTC ISO8601 문자열로 직렬화한다.
/// - [filters]가 동일 키를 포함하면 앞선 설정을 덮어쓴다.
static Map<String, dynamic> buildQuery({
int? page,
int? pageSize,
String? q,
String? sort,
String? order,
Iterable<String>? include,
DateTime? updatedSince,
Map<String, dynamic>? filters,
}) {
final query = <String, dynamic>{};
void put(String key, dynamic value) {
if (value == null) {
return;
}
if (value is String) {
final trimmed = value.trim();
if (trimmed.isEmpty) {
return;
}
query[key] = trimmed;
return;
}
if (value is DateTime) {
query[key] = value.toUtc().toIso8601String();
return;
}
if (value is Iterable) {
final sanitized = <String>[];
for (final element in value) {
if (element == null) {
continue;
}
final text = element.toString().trim();
if (text.isEmpty) {
continue;
}
sanitized.add(text);
}
if (sanitized.isEmpty) {
return;
}
final unique = LinkedHashSet<String>.from(sanitized);
query[key] = unique.join(',');
return;
}
query[key] = value;
}
put('page', page);
put('page_size', pageSize);
put('q', q);
put('sort', sort);
put('order', order?.trim().toLowerCase());
put('include', include);
put('updated_since', updatedSince);
filters?.forEach(put);
return Map.unmodifiable(query);
}
/// 내부에서 사용하는 Dio 인스턴스
/// 외부에서 Dio 직접 사용을 최소화하고, 가능하면 아래 헬퍼 메서드를 사용한다.
Dio get dio => _dio;

View File

@@ -5,4 +5,21 @@ class ApiRoutes {
/// API v1 prefix
static const apiV1 = '/api/v1';
/// 결재(Approval) 관련 엔드포인트
static const approvals = '$apiV1/approvals';
static const approvalRoot = '$apiV1/approval';
static const approvalSteps = '$apiV1/approval-steps';
static const approvalHistory = '$apiV1/approval/history';
static const approvalActions = '$apiV1/approval-actions';
static const approvalDrafts = '$apiV1/approval-drafts';
/// 결재 행위 전용 경로(`/approval/{action}`)를 반환한다.
static String approvalAction(String action) {
final sanitized = action
.trim()
.replaceAll(RegExp(r'^/+'), '')
.replaceAll(RegExp(r'/+$'), '');
return '$approvalRoot/$sanitized';
}
}