- 담당자 연락처 필드를 드롭다운 + 입력 방식으로 분리 - 사용자 폼과 동일한 전화번호 UI 패턴 적용 - 미사용 위젯 파일 4개 정리 (branch_card, contact_info_* 등) - 파일명 통일성 확보 (branch_edit_screen → branch_form, company_form_simplified → company_form) - 네이밍 일관성 개선으로 유지보수성 향상
78 lines
2.9 KiB
Dart
78 lines
2.9 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'company_dto.freezed.dart';
|
|
part 'company_dto.g.dart';
|
|
|
|
@freezed
|
|
class CreateCompanyRequest with _$CreateCompanyRequest {
|
|
const factory CreateCompanyRequest({
|
|
required String name,
|
|
required String address,
|
|
@JsonKey(name: 'contact_name') required String contactName,
|
|
@JsonKey(name: 'contact_position') required String contactPosition,
|
|
@JsonKey(name: 'contact_phone') required String contactPhone,
|
|
@JsonKey(name: 'contact_email') required String contactEmail,
|
|
@JsonKey(name: 'company_types') @Default([]) List<String> companyTypes,
|
|
@JsonKey(name: 'is_partner') @Default(false) bool isPartner,
|
|
@JsonKey(name: 'is_customer') @Default(true) bool isCustomer,
|
|
String? remark,
|
|
}) = _CreateCompanyRequest;
|
|
|
|
factory CreateCompanyRequest.fromJson(Map<String, dynamic> json) =>
|
|
_$CreateCompanyRequestFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class UpdateCompanyRequest with _$UpdateCompanyRequest {
|
|
const factory UpdateCompanyRequest({
|
|
String? name,
|
|
String? address,
|
|
@JsonKey(name: 'contact_name') String? contactName,
|
|
@JsonKey(name: 'contact_position') String? contactPosition,
|
|
@JsonKey(name: 'contact_phone') String? contactPhone,
|
|
@JsonKey(name: 'contact_email') String? contactEmail,
|
|
@JsonKey(name: 'company_types') List<String>? companyTypes,
|
|
@JsonKey(name: 'is_partner') bool? isPartner,
|
|
@JsonKey(name: 'is_customer') bool? isCustomer,
|
|
String? remark,
|
|
@JsonKey(name: 'is_active') bool? isActive,
|
|
}) = _UpdateCompanyRequest;
|
|
|
|
factory UpdateCompanyRequest.fromJson(Map<String, dynamic> json) =>
|
|
_$UpdateCompanyRequestFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class CompanyResponse with _$CompanyResponse {
|
|
const factory CompanyResponse({
|
|
required int id,
|
|
required String name,
|
|
String? address,
|
|
@JsonKey(name: 'contact_name') required String contactName,
|
|
@JsonKey(name: 'contact_position') String? contactPosition, // nullable로 변경
|
|
@JsonKey(name: 'contact_phone') required String contactPhone,
|
|
@JsonKey(name: 'contact_email') required String contactEmail,
|
|
@JsonKey(name: 'company_types') @Default([]) List<String> companyTypes,
|
|
String? remark,
|
|
@JsonKey(name: 'is_active') required bool isActive,
|
|
@JsonKey(name: 'is_partner') @Default(false) bool isPartner,
|
|
@JsonKey(name: 'is_customer') @Default(false) bool isCustomer,
|
|
@JsonKey(name: 'created_at') required DateTime createdAt,
|
|
@JsonKey(name: 'updated_at') DateTime? updatedAt, // nullable로 변경
|
|
@JsonKey(name: 'address_id') int? addressId,
|
|
}) = _CompanyResponse;
|
|
|
|
factory CompanyResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$CompanyResponseFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class CompanyNameDto with _$CompanyNameDto {
|
|
const factory CompanyNameDto({
|
|
required int id,
|
|
required String name,
|
|
}) = _CompanyNameDto;
|
|
|
|
factory CompanyNameDto.fromJson(Map<String, dynamic> json) =>
|
|
_$CompanyNameDtoFromJson(json);
|
|
} |