프로젝트 최초 커밋

This commit is contained in:
JiWoong Sul
2025-07-02 17:45:44 +09:00
commit e346f83c97
235 changed files with 23139 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:superport/models/warehouse_location_model.dart';
import 'package:superport/models/address_model.dart';
import 'package:superport/services/mock_data_service.dart';
/// 입고지 폼 상태 및 저장/수정 로직을 담당하는 컨트롤러
class WarehouseLocationFormController {
/// 폼 키
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
/// 입고지명 입력 컨트롤러
final TextEditingController nameController = TextEditingController();
/// 비고 입력 컨트롤러
final TextEditingController remarkController = TextEditingController();
/// 주소 정보
Address address = const Address();
/// 저장 중 여부
bool isSaving = false;
/// 수정 모드 여부
bool isEditMode = false;
/// 입고지 id (수정 모드)
int? id;
/// 기존 데이터 세팅 (수정 모드)
void initialize(int? locationId) {
id = locationId;
if (id != null) {
final location = MockDataService().getWarehouseLocationById(id!);
if (location != null) {
isEditMode = true;
nameController.text = location.name;
address = location.address;
remarkController.text = location.remark ?? '';
}
}
}
/// 주소 변경 처리
void updateAddress(Address newAddress) {
address = newAddress;
}
/// 저장 처리 (추가/수정)
Future<bool> save(BuildContext context) async {
if (!formKey.currentState!.validate()) return false;
isSaving = true;
if (isEditMode) {
// 수정
MockDataService().updateWarehouseLocation(
WarehouseLocation(
id: id!,
name: nameController.text.trim(),
address: address,
remark: remarkController.text.trim(),
),
);
} else {
// 추가
MockDataService().addWarehouseLocation(
WarehouseLocation(
id: 0,
name: nameController.text.trim(),
address: address,
remark: remarkController.text.trim(),
),
);
}
isSaving = false;
Navigator.pop(context, true);
return true;
}
/// 취소 처리
void cancel(BuildContext context) {
Navigator.pop(context, false);
}
/// 컨트롤러 해제
void dispose() {
nameController.dispose();
remarkController.dispose();
}
}

View File

@@ -0,0 +1,36 @@
import 'package:superport/models/warehouse_location_model.dart';
import 'package:superport/services/mock_data_service.dart';
/// 입고지 리스트 상태 및 CRUD만 담당하는 컨트롤러 클래스 (SRP 적용)
/// UI, 네비게이션, 다이얼로그 등은 포함하지 않음
/// 향후 서비스/리포지토리 DI 구조로 확장 가능
class WarehouseLocationListController {
/// 입고지 데이터 서비스 (mock)
final MockDataService _dataService = MockDataService();
/// 전체 입고지 목록
List<WarehouseLocation> warehouseLocations = [];
/// 데이터 로드
void loadWarehouseLocations() {
warehouseLocations = _dataService.getAllWarehouseLocations();
}
/// 입고지 추가
void addWarehouseLocation(WarehouseLocation location) {
_dataService.addWarehouseLocation(location);
loadWarehouseLocations();
}
/// 입고지 수정
void updateWarehouseLocation(WarehouseLocation location) {
_dataService.updateWarehouseLocation(location);
loadWarehouseLocations();
}
/// 입고지 삭제
void deleteWarehouseLocation(int id) {
_dataService.deleteWarehouseLocation(id);
loadWarehouseLocations();
}
}