feat: 회사 관리 기능 개선 및 지점 평면화 DTO 추가

- CompanyBranchFlatDto 모델 추가로 지점 데이터 처리 개선
- 회사 서비스에 브랜치 평면화 기능 추가
- 회사 폼 컨트롤러 기능 확장
- 회사 리스트 화면 UI 개선

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
JiWoong Sul
2025-08-09 02:16:57 +09:00
parent 8302ff37cc
commit f8e8a95391
9 changed files with 682 additions and 208 deletions

View File

@@ -66,23 +66,48 @@ class CompanyListController extends ChangeNotifier {
try {
if (_useApi) {
// API 호출
print('[CompanyListController] Using API to fetch companies');
final apiCompanies = await _companyService.getCompanies(
page: _currentPage,
perPage: _perPage,
search: searchKeyword.isNotEmpty ? searchKeyword : null,
isActive: _isActiveFilter,
);
print('[CompanyListController] API returned ${apiCompanies.length} companies');
// API 호출 - 지점 정보 포함
print('[CompanyListController] Using API to fetch companies with branches');
if (isRefresh) {
companies = apiCompanies;
} else {
companies.addAll(apiCompanies);
// 지점 정보를 포함한 전체 회사 목록 가져오기
final apiCompaniesWithBranches = await _companyService.getCompaniesWithBranchesFlat();
print('[CompanyListController] API returned ${apiCompaniesWithBranches.length} companies with branches');
// 지점 수 출력
for (final company in apiCompaniesWithBranches) {
if (company.branches?.isNotEmpty ?? false) {
print('[CompanyListController] ${company.name} has ${company.branches?.length ?? 0} branches');
}
}
_hasMore = apiCompanies.length == _perPage;
// 검색어 필터 적용 (서버에서 필터링이 안 되므로 클라이언트에서 처리)
List<Company> filteredApiCompanies = apiCompaniesWithBranches;
if (searchKeyword.isNotEmpty) {
final keyword = searchKeyword.toLowerCase();
filteredApiCompanies = apiCompaniesWithBranches.where((company) {
return company.name.toLowerCase().contains(keyword) ||
(company.contactName?.toLowerCase().contains(keyword) ?? false) ||
(company.contactPhone?.toLowerCase().contains(keyword) ?? false);
}).toList();
}
// 활성 상태 필터 적용 (현재 API에서 지원하지 않으므로 주석 처리)
// if (_isActiveFilter != null) {
// filteredApiCompanies = filteredApiCompanies.where((c) => c.isActive == _isActiveFilter).toList();
// }
// 페이지네이션 처리 (클라이언트 사이드)
final startIndex = (_currentPage - 1) * _perPage;
final endIndex = startIndex + _perPage;
final paginatedCompanies = filteredApiCompanies.skip(startIndex).take(_perPage).toList();
if (isRefresh) {
companies = paginatedCompanies;
} else {
companies.addAll(paginatedCompanies);
}
_hasMore = endIndex < filteredApiCompanies.length;
if (_hasMore) _currentPage++;
} else {
// Mock 데이터 사용