프로젝트 최초 커밋
This commit is contained in:
81
lib/models/address_model.dart
Normal file
81
lib/models/address_model.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
/// 주소 모델
|
||||
///
|
||||
/// 우편번호, 시/도, 상세주소로 구성된 주소 정보를 관리합니다.
|
||||
/// 회사 및 지점의 주소 정보를 일관되게 처리하기 위한 모델입니다.
|
||||
class Address {
|
||||
/// 우편번호
|
||||
final String zipCode;
|
||||
|
||||
/// 시/도 (서울특별시, 경기도 등)
|
||||
final String region;
|
||||
|
||||
/// 상세 주소
|
||||
final String detailAddress;
|
||||
|
||||
/// 생성자
|
||||
const Address({this.zipCode = '', this.region = '', this.detailAddress = ''});
|
||||
|
||||
/// 주소를 문자열로 반환합니다. (전체 주소)
|
||||
///
|
||||
/// 예시: "12345 서울특별시 강남구 테헤란로 123"
|
||||
@override
|
||||
String toString() {
|
||||
final List<String> parts = [];
|
||||
|
||||
if (zipCode.isNotEmpty) {
|
||||
parts.add(zipCode);
|
||||
}
|
||||
|
||||
if (region.isNotEmpty) {
|
||||
parts.add(region);
|
||||
}
|
||||
|
||||
if (detailAddress.isNotEmpty) {
|
||||
parts.add(detailAddress);
|
||||
}
|
||||
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
/// 전체 주소에서 Address 객체를 생성합니다.
|
||||
///
|
||||
/// 현재는 우편번호, 시/도, 상세주소를 분리하지 않고 전체를 detailAddress로 저장합니다.
|
||||
/// 기존 데이터 마이그레이션을 위한 메서드입니다.
|
||||
factory Address.fromFullAddress(String fullAddress) {
|
||||
return Address(detailAddress: fullAddress);
|
||||
}
|
||||
|
||||
/// JSON에서 Address 객체를 생성합니다.
|
||||
factory Address.fromJson(Map<String, dynamic> json) {
|
||||
return Address(
|
||||
zipCode: json['zipCode'] ?? '',
|
||||
region: json['region'] ?? '',
|
||||
detailAddress: json['detailAddress'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
/// Address 객체를 JSON으로 변환합니다.
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'zipCode': zipCode,
|
||||
'region': region,
|
||||
'detailAddress': detailAddress,
|
||||
};
|
||||
}
|
||||
|
||||
/// 주소가 비어 있는지 확인합니다.
|
||||
bool get isEmpty =>
|
||||
zipCode.isEmpty && region.isEmpty && detailAddress.isEmpty;
|
||||
|
||||
/// 주소가 비어 있지 않은지 확인합니다.
|
||||
bool get isNotEmpty => !isEmpty;
|
||||
|
||||
/// 복사본을 생성하고 일부 필드를 업데이트합니다.
|
||||
Address copyWith({String? zipCode, String? region, String? detailAddress}) {
|
||||
return Address(
|
||||
zipCode: zipCode ?? this.zipCode,
|
||||
region: region ?? this.region,
|
||||
detailAddress: detailAddress ?? this.detailAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
259
lib/models/company_model.dart
Normal file
259
lib/models/company_model.dart
Normal file
@@ -0,0 +1,259 @@
|
||||
import 'package:superport/models/address_model.dart';
|
||||
|
||||
/// 회사 유형 열거형
|
||||
/// - 고객사: 서비스를 이용하는 회사
|
||||
/// - 파트너사: 서비스를 제공하는 회사
|
||||
enum CompanyType {
|
||||
customer, // 고객사
|
||||
partner, // 파트너사
|
||||
}
|
||||
|
||||
/// 회사 유형을 문자열로 변환 (복수 지원)
|
||||
String companyTypeToString(CompanyType type) {
|
||||
switch (type) {
|
||||
case CompanyType.customer:
|
||||
return '고객사';
|
||||
case CompanyType.partner:
|
||||
return '파트너사';
|
||||
}
|
||||
}
|
||||
|
||||
/// 문자열에서 회사 유형으로 변환 (단일)
|
||||
CompanyType stringToCompanyType(String type) {
|
||||
switch (type) {
|
||||
case '고객사':
|
||||
return CompanyType.customer;
|
||||
case '파트너사':
|
||||
return CompanyType.partner;
|
||||
default:
|
||||
return CompanyType.customer; // 기본값은 고객사
|
||||
}
|
||||
}
|
||||
|
||||
/// 문자열 리스트에서 회사 유형 리스트로 변환
|
||||
List<CompanyType> stringListToCompanyTypeList(List<dynamic> types) {
|
||||
// 문자열 또는 enum 문자열이 섞여 있을 수 있음
|
||||
return types.map((e) {
|
||||
if (e is CompanyType) return e;
|
||||
if (e is String) {
|
||||
if (e.contains('partner')) return CompanyType.partner;
|
||||
return CompanyType.customer;
|
||||
}
|
||||
return CompanyType.customer;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/// 회사 유형 리스트를 문자열 리스트로 변환
|
||||
List<String> companyTypeListToStringList(List<CompanyType> types) {
|
||||
return types.map((e) => companyTypeToString(e)).toList();
|
||||
}
|
||||
|
||||
class Branch {
|
||||
final int? id;
|
||||
final int companyId;
|
||||
final String name;
|
||||
final Address address; // 주소 모델 사용
|
||||
final String? contactName; // 담당자 이름
|
||||
final String? contactPosition; // 담당자 직책
|
||||
final String? contactPhone; // 담당자 전화번호
|
||||
final String? contactEmail; // 담당자 이메일
|
||||
final String? remark; // 비고
|
||||
|
||||
Branch({
|
||||
this.id,
|
||||
required this.companyId,
|
||||
required this.name,
|
||||
Address? address, // 옵셔널 파라미터로 변경
|
||||
this.contactName,
|
||||
this.contactPosition,
|
||||
this.contactPhone,
|
||||
this.contactEmail,
|
||||
this.remark,
|
||||
}) : address = address ?? const Address(); // 기본값 제공
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'companyId': companyId,
|
||||
'name': name,
|
||||
'address': address.toString(), // 하위 호환성을 위해 문자열로 변환
|
||||
'addressData': address.toJson(), // 새로운 형식으로 저장
|
||||
'contactName': contactName,
|
||||
'contactPosition': contactPosition,
|
||||
'contactPhone': contactPhone,
|
||||
'contactEmail': contactEmail,
|
||||
'remark': remark,
|
||||
};
|
||||
}
|
||||
|
||||
factory Branch.fromJson(Map<String, dynamic> json) {
|
||||
// 주소 데이터가 새 형식으로 저장되어 있는지 확인
|
||||
Address addressData;
|
||||
if (json.containsKey('addressData')) {
|
||||
addressData = Address.fromJson(json['addressData']);
|
||||
} else if (json.containsKey('address') && json['address'] != null) {
|
||||
// 이전 버전 호환성 - 문자열 주소를 Address 객체로 변환
|
||||
addressData = Address.fromFullAddress(json['address']);
|
||||
} else {
|
||||
addressData = const Address();
|
||||
}
|
||||
|
||||
return Branch(
|
||||
id: json['id'],
|
||||
companyId: json['companyId'],
|
||||
name: json['name'],
|
||||
address: addressData,
|
||||
contactName: json['contactName'],
|
||||
contactPosition: json['contactPosition'],
|
||||
contactPhone: json['contactPhone'],
|
||||
contactEmail: json['contactEmail'],
|
||||
remark: json['remark'],
|
||||
);
|
||||
}
|
||||
|
||||
/// 복사본을 생성하고 일부 필드를 업데이트합니다.
|
||||
Branch copyWith({
|
||||
int? id,
|
||||
int? companyId,
|
||||
String? name,
|
||||
Address? address,
|
||||
String? contactName,
|
||||
String? contactPosition,
|
||||
String? contactPhone,
|
||||
String? contactEmail,
|
||||
String? remark,
|
||||
}) {
|
||||
return Branch(
|
||||
id: id ?? this.id,
|
||||
companyId: companyId ?? this.companyId,
|
||||
name: name ?? this.name,
|
||||
address: address ?? this.address,
|
||||
contactName: contactName ?? this.contactName,
|
||||
contactPosition: contactPosition ?? this.contactPosition,
|
||||
contactPhone: contactPhone ?? this.contactPhone,
|
||||
contactEmail: contactEmail ?? this.contactEmail,
|
||||
remark: remark ?? this.remark,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Company {
|
||||
final int? id;
|
||||
final String name;
|
||||
final Address address; // 주소 모델 사용
|
||||
final String? contactName; // 담당자 이름
|
||||
final String? contactPosition; // 담당자 직책
|
||||
final String? contactPhone; // 담당자 전화번호
|
||||
final String? contactEmail; // 담당자 이메일
|
||||
final List<Branch>? branches;
|
||||
final List<CompanyType> companyTypes; // 회사 유형 (복수 가능)
|
||||
final String? remark; // 비고
|
||||
|
||||
Company({
|
||||
this.id,
|
||||
required this.name,
|
||||
Address? address, // 옵셔널 파라미터로 변경
|
||||
this.contactName,
|
||||
this.contactPosition,
|
||||
this.contactPhone,
|
||||
this.contactEmail,
|
||||
this.branches,
|
||||
this.companyTypes = const [CompanyType.customer], // 기본값은 고객사
|
||||
this.remark,
|
||||
}) : address = address ?? const Address(); // 기본값 제공
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'address': address.toString(), // 하위 호환성을 위해 문자열로 변환
|
||||
'addressData': address.toJson(), // 새로운 형식으로 저장
|
||||
'contactName': contactName,
|
||||
'contactPosition': contactPosition,
|
||||
'contactPhone': contactPhone,
|
||||
'contactEmail': contactEmail,
|
||||
'branches': branches?.map((branch) => branch.toJson()).toList(),
|
||||
// 회사 유형을 문자열 리스트로 저장
|
||||
'companyTypes': companyTypes.map((e) => e.toString()).toList(),
|
||||
'remark': remark,
|
||||
};
|
||||
}
|
||||
|
||||
factory Company.fromJson(Map<String, dynamic> json) {
|
||||
List<Branch>? branchList;
|
||||
if (json['branches'] != null) {
|
||||
branchList =
|
||||
(json['branches'] as List)
|
||||
.map((branchJson) => Branch.fromJson(branchJson))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// 주소 데이터가 새 형식으로 저장되어 있는지 확인
|
||||
Address addressData;
|
||||
if (json.containsKey('addressData')) {
|
||||
addressData = Address.fromJson(json['addressData']);
|
||||
} else if (json.containsKey('address') && json['address'] != null) {
|
||||
// 이전 버전 호환성 - 문자열 주소를 Address 객체로 변환
|
||||
addressData = Address.fromFullAddress(json['address']);
|
||||
} else {
|
||||
addressData = const Address();
|
||||
}
|
||||
|
||||
// 회사 유형 파싱 (복수)
|
||||
List<CompanyType> types = [CompanyType.customer]; // 기본값
|
||||
if (json.containsKey('companyTypes')) {
|
||||
final raw = json['companyTypes'];
|
||||
if (raw is List) {
|
||||
types = stringListToCompanyTypeList(raw);
|
||||
}
|
||||
} else if (json.containsKey('companyType')) {
|
||||
// 이전 버전 호환성: 단일 값
|
||||
final raw = json['companyType'];
|
||||
if (raw is String) {
|
||||
types = [stringToCompanyType(raw)];
|
||||
} else if (raw is int) {
|
||||
types = [CompanyType.values[raw]];
|
||||
}
|
||||
}
|
||||
|
||||
return Company(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
address: addressData,
|
||||
contactName: json['contactName'],
|
||||
contactPosition: json['contactPosition'],
|
||||
contactPhone: json['contactPhone'],
|
||||
contactEmail: json['contactEmail'],
|
||||
branches: branchList,
|
||||
companyTypes: types,
|
||||
remark: json['remark'],
|
||||
);
|
||||
}
|
||||
|
||||
/// 복사본을 생성하고 일부 필드를 업데이트합니다.
|
||||
Company copyWith({
|
||||
int? id,
|
||||
String? name,
|
||||
Address? address,
|
||||
String? contactName,
|
||||
String? contactPosition,
|
||||
String? contactPhone,
|
||||
String? contactEmail,
|
||||
List<Branch>? branches,
|
||||
List<CompanyType>? companyTypes,
|
||||
String? remark,
|
||||
}) {
|
||||
return Company(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
address: address ?? this.address,
|
||||
contactName: contactName ?? this.contactName,
|
||||
contactPosition: contactPosition ?? this.contactPosition,
|
||||
contactPhone: contactPhone ?? this.contactPhone,
|
||||
contactEmail: contactEmail ?? this.contactEmail,
|
||||
branches: branches ?? this.branches,
|
||||
companyTypes: companyTypes ?? this.companyTypes,
|
||||
remark: remark ?? this.remark,
|
||||
);
|
||||
}
|
||||
}
|
||||
278
lib/models/equipment_unified_model.dart
Normal file
278
lib/models/equipment_unified_model.dart
Normal file
@@ -0,0 +1,278 @@
|
||||
import 'package:superport/utils/constants.dart';
|
||||
|
||||
// 장비 정보 모델
|
||||
class Equipment {
|
||||
final int? id;
|
||||
final String manufacturer;
|
||||
final String name;
|
||||
final String category;
|
||||
final String subCategory;
|
||||
final String subSubCategory;
|
||||
final String? serialNumber;
|
||||
final String? barcode;
|
||||
final int quantity;
|
||||
final DateTime? inDate;
|
||||
final String? remark; // 비고
|
||||
final String? warrantyLicense; // 워런티 라이센스 명
|
||||
DateTime? warrantyStartDate; // 워런티 시작일(수정 가능)
|
||||
DateTime? warrantyEndDate; // 워런티 종료일(수정 가능)
|
||||
|
||||
Equipment({
|
||||
this.id,
|
||||
required this.manufacturer,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.subCategory,
|
||||
required this.subSubCategory,
|
||||
this.serialNumber,
|
||||
this.barcode,
|
||||
required this.quantity,
|
||||
this.inDate,
|
||||
this.remark,
|
||||
this.warrantyLicense,
|
||||
this.warrantyStartDate,
|
||||
this.warrantyEndDate,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'manufacturer': manufacturer,
|
||||
'name': name,
|
||||
'category': category,
|
||||
'subCategory': subCategory,
|
||||
'subSubCategory': subSubCategory,
|
||||
'serialNumber': serialNumber,
|
||||
'barcode': barcode,
|
||||
'quantity': quantity,
|
||||
'inDate': inDate?.toIso8601String(),
|
||||
'remark': remark,
|
||||
'warrantyLicense': warrantyLicense,
|
||||
'warrantyStartDate': warrantyStartDate?.toIso8601String(),
|
||||
'warrantyEndDate': warrantyEndDate?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory Equipment.fromJson(Map<String, dynamic> json) {
|
||||
return Equipment(
|
||||
id: json['id'],
|
||||
manufacturer: json['manufacturer'],
|
||||
name: json['name'],
|
||||
category: json['category'],
|
||||
subCategory: json['subCategory'],
|
||||
subSubCategory: json['subSubCategory'],
|
||||
serialNumber: json['serialNumber'],
|
||||
barcode: json['barcode'],
|
||||
quantity: json['quantity'],
|
||||
inDate: json['inDate'] != null ? DateTime.parse(json['inDate']) : null,
|
||||
remark: json['remark'],
|
||||
warrantyLicense: json['warrantyLicense'],
|
||||
warrantyStartDate:
|
||||
json['warrantyStartDate'] != null
|
||||
? DateTime.parse(json['warrantyStartDate'])
|
||||
: null,
|
||||
warrantyEndDate:
|
||||
json['warrantyEndDate'] != null
|
||||
? DateTime.parse(json['warrantyEndDate'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EquipmentIn {
|
||||
final int? id;
|
||||
final Equipment equipment;
|
||||
final DateTime inDate;
|
||||
final String status; // I (입고)
|
||||
final String type; // 장비 유형: '신제품', '중고', '계약'
|
||||
final String? warehouseLocation; // 입고지
|
||||
final String? partnerCompany; // 파트너사
|
||||
final String? remark; // 비고
|
||||
|
||||
EquipmentIn({
|
||||
this.id,
|
||||
required this.equipment,
|
||||
required this.inDate,
|
||||
this.status = 'I',
|
||||
this.type = EquipmentType.new_, // 기본값은 '신제품'으로 설정
|
||||
this.warehouseLocation,
|
||||
this.partnerCompany,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'equipment': equipment.toJson(),
|
||||
'inDate': inDate.toIso8601String(),
|
||||
'status': status,
|
||||
'type': type,
|
||||
'warehouseLocation': warehouseLocation,
|
||||
'partnerCompany': partnerCompany,
|
||||
'remark': remark,
|
||||
};
|
||||
}
|
||||
|
||||
factory EquipmentIn.fromJson(Map<String, dynamic> json) {
|
||||
return EquipmentIn(
|
||||
id: json['id'],
|
||||
equipment: Equipment.fromJson(json['equipment']),
|
||||
inDate: DateTime.parse(json['inDate']),
|
||||
status: json['status'],
|
||||
type: json['type'] ?? EquipmentType.new_,
|
||||
warehouseLocation: json['warehouseLocation'],
|
||||
partnerCompany: json['partnerCompany'],
|
||||
remark: json['remark'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EquipmentOut {
|
||||
final int? id;
|
||||
final Equipment equipment;
|
||||
final DateTime outDate;
|
||||
final String status; // O (출고), I (재입고), R (수리)
|
||||
final String? company; // 출고 회사
|
||||
final String? manager; // 담당자
|
||||
final String? license; // 라이센스
|
||||
final DateTime? returnDate; // 재입고/수리 날짜
|
||||
final String? returnType; // 재입고/수리 유형
|
||||
final String? remark; // 비고
|
||||
|
||||
EquipmentOut({
|
||||
this.id,
|
||||
required this.equipment,
|
||||
required this.outDate,
|
||||
this.status = 'O',
|
||||
this.company,
|
||||
this.manager,
|
||||
this.license,
|
||||
this.returnDate,
|
||||
this.returnType,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'equipment': equipment.toJson(),
|
||||
'outDate': outDate.toIso8601String(),
|
||||
'status': status,
|
||||
'company': company,
|
||||
'manager': manager,
|
||||
'license': license,
|
||||
'returnDate': returnDate?.toIso8601String(),
|
||||
'returnType': returnType,
|
||||
'remark': remark,
|
||||
};
|
||||
}
|
||||
|
||||
factory EquipmentOut.fromJson(Map<String, dynamic> json) {
|
||||
return EquipmentOut(
|
||||
id: json['id'],
|
||||
equipment: Equipment.fromJson(json['equipment']),
|
||||
outDate: DateTime.parse(json['outDate']),
|
||||
status: json['status'],
|
||||
company: json['company'],
|
||||
manager: json['manager'],
|
||||
license: json['license'],
|
||||
returnDate:
|
||||
json['returnDate'] != null
|
||||
? DateTime.parse(json['returnDate'])
|
||||
: null,
|
||||
returnType: json['returnType'],
|
||||
remark: json['remark'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UnifiedEquipment {
|
||||
final int? id;
|
||||
final Equipment equipment;
|
||||
final DateTime date; // 입고일 또는 출고일
|
||||
final String
|
||||
status; // 상태 코드: 'I'(입고), 'O'(출고), 'R'(수리중), 'D'(손상), 'L'(분실), 'E'(기타)
|
||||
final String? notes; // 추가 비고
|
||||
final String? _type; // 내부용: 입고 장비 유형
|
||||
|
||||
UnifiedEquipment({
|
||||
this.id,
|
||||
required this.equipment,
|
||||
required this.date,
|
||||
required this.status,
|
||||
this.notes,
|
||||
String? type,
|
||||
}) : _type = type;
|
||||
|
||||
// 장비 유형 반환 (입고 장비만)
|
||||
String? get type => status == 'I' ? _type : null;
|
||||
|
||||
// 장비 상태 텍스트 변환
|
||||
String get statusText {
|
||||
switch (status) {
|
||||
case EquipmentStatus.in_:
|
||||
return '입고';
|
||||
case EquipmentStatus.out:
|
||||
return '출고';
|
||||
case EquipmentStatus.rent:
|
||||
return '대여';
|
||||
case EquipmentStatus.repair:
|
||||
return '수리중';
|
||||
case EquipmentStatus.damaged:
|
||||
return '손상';
|
||||
case EquipmentStatus.lost:
|
||||
return '분실';
|
||||
case EquipmentStatus.etc:
|
||||
return '기타';
|
||||
default:
|
||||
return '알 수 없음';
|
||||
}
|
||||
}
|
||||
|
||||
// EquipmentIn 모델에서 변환
|
||||
factory UnifiedEquipment.fromEquipmentIn(
|
||||
id,
|
||||
equipment,
|
||||
inDate,
|
||||
status, {
|
||||
String? type,
|
||||
}) {
|
||||
return UnifiedEquipment(
|
||||
id: id,
|
||||
equipment: equipment,
|
||||
date: inDate,
|
||||
status: status,
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
|
||||
// EquipmentOut 모델에서 변환
|
||||
factory UnifiedEquipment.fromEquipmentOut(id, equipment, outDate, status) {
|
||||
return UnifiedEquipment(
|
||||
id: id,
|
||||
equipment: equipment,
|
||||
date: outDate,
|
||||
status: status,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'equipment': equipment.toJson(),
|
||||
'date': date.toIso8601String(),
|
||||
'status': status,
|
||||
'notes': notes,
|
||||
};
|
||||
}
|
||||
|
||||
factory UnifiedEquipment.fromJson(Map<String, dynamic> json) {
|
||||
return UnifiedEquipment(
|
||||
id: json['id'],
|
||||
equipment: Equipment.fromJson(json['equipment']),
|
||||
date: DateTime.parse(json['date']),
|
||||
status: json['status'],
|
||||
notes: json['notes'],
|
||||
);
|
||||
}
|
||||
}
|
||||
35
lib/models/license_model.dart
Normal file
35
lib/models/license_model.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
class License {
|
||||
final int? id;
|
||||
final int companyId;
|
||||
final String name;
|
||||
final int durationMonths;
|
||||
final String visitCycle; // 방문주기(월, 격월, 분기 등)
|
||||
|
||||
License({
|
||||
this.id,
|
||||
required this.companyId,
|
||||
required this.name,
|
||||
required this.durationMonths,
|
||||
required this.visitCycle,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'companyId': companyId,
|
||||
'name': name,
|
||||
'durationMonths': durationMonths,
|
||||
'visitCycle': visitCycle,
|
||||
};
|
||||
}
|
||||
|
||||
factory License.fromJson(Map<String, dynamic> json) {
|
||||
return License(
|
||||
id: json['id'],
|
||||
companyId: json['companyId'],
|
||||
name: json['name'],
|
||||
durationMonths: json['durationMonths'],
|
||||
visitCycle: json['visitCycle'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
50
lib/models/user_model.dart
Normal file
50
lib/models/user_model.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
class User {
|
||||
final int? id;
|
||||
final int companyId;
|
||||
final int? branchId; // 지점 ID
|
||||
final String name;
|
||||
final String role; // 관리등급: S(관리자), M(멤버)
|
||||
final String? position; // 직급
|
||||
final String? email; // 이메일
|
||||
final List<Map<String, String>> phoneNumbers; // 전화번호 목록 (유형과 번호)
|
||||
|
||||
User({
|
||||
this.id,
|
||||
required this.companyId,
|
||||
this.branchId,
|
||||
required this.name,
|
||||
required this.role,
|
||||
this.position,
|
||||
this.email,
|
||||
this.phoneNumbers = const [],
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'companyId': companyId,
|
||||
'branchId': branchId,
|
||||
'name': name,
|
||||
'role': role,
|
||||
'position': position,
|
||||
'email': email,
|
||||
'phoneNumbers': phoneNumbers,
|
||||
};
|
||||
}
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['id'],
|
||||
companyId: json['companyId'],
|
||||
branchId: json['branchId'],
|
||||
name: json['name'],
|
||||
role: json['role'],
|
||||
position: json['position'],
|
||||
email: json['email'],
|
||||
phoneNumbers:
|
||||
json['phoneNumbers'] != null
|
||||
? List<Map<String, String>>.from(json['phoneNumbers'])
|
||||
: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
19
lib/models/user_phone_field.dart
Normal file
19
lib/models/user_phone_field.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// 전화번호 입력 필드 관리를 위한 클래스
|
||||
// 타입 안정성 및 코드 간결성을 위해 사용
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserPhoneField {
|
||||
// 전화번호 종류(휴대폰, 사무실 등)
|
||||
String type;
|
||||
// 전화번호 입력 컨트롤러
|
||||
final TextEditingController controller;
|
||||
|
||||
UserPhoneField({required this.type, String? initialValue})
|
||||
: controller = TextEditingController(text: initialValue);
|
||||
|
||||
// 현재 입력된 전화번호 반환
|
||||
String get number => controller.text;
|
||||
|
||||
// 컨트롤러 해제
|
||||
void dispose() => controller.dispose();
|
||||
}
|
||||
38
lib/models/warehouse_location_model.dart
Normal file
38
lib/models/warehouse_location_model.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'address_model.dart';
|
||||
|
||||
/// 입고지 정보를 나타내는 모델 클래스
|
||||
class WarehouseLocation {
|
||||
/// 입고지 고유 번호
|
||||
final int id;
|
||||
|
||||
/// 입고지명
|
||||
final String name;
|
||||
|
||||
/// 입고지 주소
|
||||
final Address address;
|
||||
|
||||
/// 비고
|
||||
final String? remark;
|
||||
|
||||
WarehouseLocation({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.address,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
/// 복사본 생성 (불변성 유지)
|
||||
WarehouseLocation copyWith({
|
||||
int? id,
|
||||
String? name,
|
||||
Address? address,
|
||||
String? remark,
|
||||
}) {
|
||||
return WarehouseLocation(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
address: address ?? this.address,
|
||||
remark: remark ?? this.remark,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user