승인 단계 삭제 복구 흐름 구현하고 API 정렬 문서 추가

This commit is contained in:
JiWoong Sul
2025-10-01 15:51:01 +09:00
parent 5578bf443f
commit 67fc319c3c
16 changed files with 671 additions and 38 deletions

View File

@@ -158,4 +158,64 @@ class ApprovalStepController extends ChangeNotifier {
notifyListeners();
}
}
/// 결재 단계를 삭제(비활성화)하고 목록 상태를 반영한다.
Future<bool> deleteStep(int id) async {
_isSaving = true;
_errorMessage = null;
notifyListeners();
try {
await _repository.delete(id);
if (_result != null) {
final items = _result!.items
.map((record) {
final stepId = record.step.id;
if (stepId != null && stepId == id) {
return record.copyWith(
step: record.step.copyWith(isDeleted: true),
);
}
return record;
})
.toList(growable: false);
_result = _result!.copyWith(items: items);
}
return true;
} catch (e) {
_errorMessage = e.toString();
return false;
} finally {
_isSaving = false;
notifyListeners();
}
}
/// 삭제된 결재 단계를 복구하고 최신 데이터를 반환한다.
Future<ApprovalStepRecord?> restoreStep(int id) async {
_isSaving = true;
_errorMessage = null;
notifyListeners();
try {
final record = await _repository.restore(id);
if (_result != null) {
final items = _result!.items
.map((item) {
final stepId = item.step.id;
if (stepId != null && stepId == id) {
return record;
}
return item;
})
.toList(growable: false);
_result = _result!.copyWith(items: items);
}
return record;
} catch (e) {
_errorMessage = e.toString();
return null;
} finally {
_isSaving = false;
notifyListeners();
}
}
}