Files
superport_v2/lib/features/masters/warehouse/domain/entities/warehouse.dart

100 lines
2.3 KiB
Dart

/// 창고(Warehouse) 도메인 엔티티.
class Warehouse {
Warehouse({
this.id,
required this.warehouseCode,
required this.warehouseName,
this.zipcode,
this.addressDetail,
this.isActive = true,
this.isDeleted = false,
this.note,
this.createdAt,
this.updatedAt,
});
final int? id;
final String warehouseCode;
final String warehouseName;
final WarehouseZipcode? zipcode;
final String? addressDetail;
final bool isActive;
final bool isDeleted;
final String? note;
final DateTime? createdAt;
final DateTime? updatedAt;
/// 일부 속성만 변경한 새 인스턴스를 반환한다.
Warehouse copyWith({
int? id,
String? warehouseCode,
String? warehouseName,
WarehouseZipcode? zipcode,
String? addressDetail,
bool? isActive,
bool? isDeleted,
String? note,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return Warehouse(
id: id ?? this.id,
warehouseCode: warehouseCode ?? this.warehouseCode,
warehouseName: warehouseName ?? this.warehouseName,
zipcode: zipcode ?? this.zipcode,
addressDetail: addressDetail ?? this.addressDetail,
isActive: isActive ?? this.isActive,
isDeleted: isDeleted ?? this.isDeleted,
note: note ?? this.note,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}
}
/// 창고 주소에 대한 우편번호/행정 정보.
class WarehouseZipcode {
WarehouseZipcode({
required this.zipcode,
this.sido,
this.sigungu,
this.roadName,
});
final String zipcode;
final String? sido;
final String? sigungu;
final String? roadName;
}
/// 창고 생성/수정에 사용하는 입력 모델.
class WarehouseInput {
WarehouseInput({
required this.warehouseCode,
required this.warehouseName,
this.zipcode,
this.addressDetail,
this.isActive = true,
this.note,
});
final String warehouseCode;
final String warehouseName;
final String? zipcode;
final String? addressDetail;
final bool isActive;
final String? note;
/// API 요청 바디로 직렬화한다.
Map<String, dynamic> toPayload() {
return {
'warehouse_code': warehouseCode,
'warehouse_name': warehouseName,
'zipcode': zipcode,
'address_detail': addressDetail,
'is_active': isActive,
'note': note,
};
}
}