feat: 회사 관리 기능 개선 및 지점 평면화 DTO 추가
- CompanyBranchFlatDto 모델 추가로 지점 데이터 처리 개선 - 회사 서비스에 브랜치 평면화 기능 추가 - 회사 폼 컨트롤러 기능 확장 - 회사 리스트 화면 UI 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:superport/data/models/common/paginated_response.dart';
|
||||
import 'package:superport/data/models/company/company_dto.dart';
|
||||
import 'package:superport/data/models/company/company_list_dto.dart';
|
||||
import 'package:superport/data/models/company/branch_dto.dart';
|
||||
import 'package:superport/data/models/company/company_branch_flat_dto.dart';
|
||||
|
||||
abstract class CompanyRemoteDataSource {
|
||||
Future<PaginatedResponse<CompanyListDto>> getCompanies({
|
||||
@@ -48,6 +49,8 @@ abstract class CompanyRemoteDataSource {
|
||||
Future<void> deleteBranch(int companyId, int branchId);
|
||||
|
||||
Future<List<BranchListDto>> getCompanyBranches(int companyId);
|
||||
|
||||
Future<List<CompanyBranchFlatDto>> getCompanyBranchesFlat();
|
||||
}
|
||||
|
||||
@LazySingleton(as: CompanyRemoteDataSource)
|
||||
@@ -343,6 +346,36 @@ class CompanyRemoteDataSourceImpl implements CompanyRemoteDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<CompanyBranchFlatDto>> getCompanyBranchesFlat() async {
|
||||
try {
|
||||
final response = await _apiClient.get('${ApiEndpoints.companies}/branches');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseData = response.data;
|
||||
if (responseData != null && responseData['success'] == true && responseData['data'] != null) {
|
||||
final List<dynamic> dataList = responseData['data'];
|
||||
return dataList.map((item) =>
|
||||
CompanyBranchFlatDto.fromJson(item as Map<String, dynamic>)
|
||||
).toList();
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: responseData?['error']?['message'] ?? 'Failed to load company branches',
|
||||
statusCode: response.statusCode,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: 'Failed to load company branches',
|
||||
statusCode: response.statusCode,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e is ApiException) rethrow;
|
||||
throw ApiException(message: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> checkDuplicateCompany(String name) async {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user