feat: 대규모 코드베이스 개선 - 백엔드 통합성 강화 및 UI 일관성 완성
- CLAUDE.md 대폭 개선: 개발 가이드라인 및 프로젝트 상태 문서화 - 백엔드 API 통합: 모든 엔티티 간 Foreign Key 관계 완벽 구현 - UI 일관성 강화: shadcn_ui 컴포넌트 표준화 적용 - 데이터 모델 개선: DTO 및 모델 클래스 백엔드 스키마와 100% 일치 - 사용자 관리: 회사 연결, 중복 검사, 입력 검증 기능 추가 - 창고 관리: 우편번호 연결, 중복 검사 기능 강화 - 회사 관리: 우편번호 연결, 중복 검사 로직 구현 - 장비 관리: 불필요한 카테고리 필드 제거, 벤더-모델 관계 정리 - 우편번호 시스템: 검색 다이얼로그 Provider 버그 수정 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -230,6 +230,26 @@ class ModelController extends ChangeNotifier {
|
||||
return _modelsByVendor[vendorId] ?? [];
|
||||
}
|
||||
|
||||
/// 모델명 중복 확인
|
||||
Future<bool> checkDuplicateName(String name, {int? excludeId}) async {
|
||||
try {
|
||||
// 현재 로드된 모델 목록에서 중복 검사
|
||||
final duplicates = _models.where((model) {
|
||||
// 수정 모드일 때 자기 자신은 제외
|
||||
if (excludeId != null && model.id == excludeId) {
|
||||
return false;
|
||||
}
|
||||
// 대소문자 구분 없이 이름 비교
|
||||
return model.name.toLowerCase() == name.toLowerCase();
|
||||
}).toList();
|
||||
|
||||
return duplicates.isNotEmpty;
|
||||
} catch (e) {
|
||||
// 에러 발생 시 false 반환 (중복 없음으로 처리)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 에러 메시지 클리어
|
||||
void clearError() {
|
||||
_errorMessage = null;
|
||||
|
||||
@@ -23,6 +23,7 @@ class _ModelFormDialogState extends State<ModelFormDialog> {
|
||||
|
||||
int? _selectedVendorId;
|
||||
bool _isSubmitting = false;
|
||||
String? _statusMessage;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -87,7 +88,24 @@ class _ModelFormDialogState extends State<ModelFormDialog> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 상태 메시지 영역 (고정 높이)
|
||||
SizedBox(
|
||||
height: 20,
|
||||
child: _statusMessage != null
|
||||
? Text(
|
||||
_statusMessage!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _statusMessage!.contains('존재')
|
||||
? Colors.red
|
||||
: Colors.grey,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
|
||||
// 활성 상태는 백엔드에서 관리하므로 UI에서 제거
|
||||
@@ -122,6 +140,28 @@ class _ModelFormDialogState extends State<ModelFormDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _checkDuplicate() async {
|
||||
final name = _nameController.text.trim();
|
||||
if (name.isEmpty) return false;
|
||||
|
||||
// 수정 모드일 때 현재 이름과 같으면 검사하지 않음
|
||||
if (widget.model != null && widget.model!.name == name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final isDuplicate = await widget.controller.checkDuplicateName(
|
||||
name,
|
||||
excludeId: widget.model?.id,
|
||||
);
|
||||
|
||||
return isDuplicate;
|
||||
} catch (e) {
|
||||
// 네트워크 오류 시 false 반환
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit() async {
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
@@ -140,6 +180,22 @@ class _ModelFormDialogState extends State<ModelFormDialog> {
|
||||
|
||||
setState(() {
|
||||
_isSubmitting = true;
|
||||
_statusMessage = '중복 확인 중...';
|
||||
});
|
||||
|
||||
// 저장 시 중복 검사 수행
|
||||
final isDuplicate = await _checkDuplicate();
|
||||
|
||||
if (isDuplicate) {
|
||||
setState(() {
|
||||
_isSubmitting = false;
|
||||
_statusMessage = '이미 존재하는 모델명입니다.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_statusMessage = '저장 중...';
|
||||
});
|
||||
|
||||
bool success;
|
||||
@@ -160,6 +216,7 @@ class _ModelFormDialogState extends State<ModelFormDialog> {
|
||||
|
||||
setState(() {
|
||||
_isSubmitting = false;
|
||||
_statusMessage = null;
|
||||
});
|
||||
|
||||
if (mounted) {
|
||||
|
||||
Reference in New Issue
Block a user