import 'package:fis_jsonrpc/utils.dart'; class BaseDTO { DateTime? createTime; DateTime? updateTime; BaseDTO({ this.createTime, this.updateTime, }); factory BaseDTO.fromJson(Map map) { return BaseDTO( createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = Map(); if (createTime != null) map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!); if (updateTime != null) map['UpdateTime'] = JsonRpcUtils.dateFormat(updateTime!); return map; } } class IdentityApplyDTO extends BaseDTO { String? applyPosition; List? identityCard; List? licenseCard; IdentityApplyDTO({ this.applyPosition, this.identityCard, this.licenseCard, DateTime? createTime, DateTime? updateTime, }) : super( createTime: createTime, updateTime: updateTime, ); factory IdentityApplyDTO.fromJson(Map map) { final identityCardData = map['IdentityCard']; final licenseCardData = map['LicenseCard']; return IdentityApplyDTO( applyPosition: map['ApplyPosition'], identityCard: identityCardData != null ? (identityCardData as List).map((e) => e as String).toList() : null, licenseCard: licenseCardData != null ? (licenseCardData as List).map((e) => e as String).toList() : null, createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if (applyPosition != null) map['ApplyPosition'] = applyPosition; if (identityCard != null) map['IdentityCard'] = identityCard; if (licenseCard != null) map['LicenseCard'] = licenseCard; return map; } } enum ApplyStateEnum { NotApply, Applying, Refused, Passed, } class IdentityApplyStateDTO extends IdentityApplyDTO { ApplyStateEnum applyState; String? applyNote; IdentityApplyStateDTO({ this.applyState = ApplyStateEnum.NotApply, this.applyNote, String? applyPosition, List? identityCard, List? licenseCard, DateTime? createTime, DateTime? updateTime, }) : super( applyPosition: applyPosition, identityCard: identityCard, licenseCard: licenseCard, createTime: createTime, updateTime: updateTime, ); factory IdentityApplyStateDTO.fromJson(Map map) { final identityCardData = map['IdentityCard']; final licenseCardData = map['LicenseCard']; return IdentityApplyStateDTO( applyState: ApplyStateEnum.values.firstWhere((e) => e.index == map['ApplyState']), applyNote: map['ApplyNote'], applyPosition: map['ApplyPosition'], identityCard: identityCardData != null ? (identityCardData as List).map((e) => e as String).toList() : null, licenseCard: licenseCardData != null ? (licenseCardData as List).map((e) => e as String).toList() : null, createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); map['ApplyState'] = applyState.index; if (applyNote != null) map['ApplyNote'] = applyNote; return map; } } class BaseRequest { BaseRequest(); factory BaseRequest.fromJson(Map map) { return BaseRequest(); } Map toJson() { final map = Map(); return map; } } class TokenRequest extends BaseRequest { String? token; TokenRequest({ this.token, }) : super(); factory TokenRequest.fromJson(Map map) { return TokenRequest( token: map['Token'], ); } Map toJson() { final map = super.toJson(); if (token != null) map['Token'] = token; return map; } } class ApplyForRequest extends IdentityApplyDTO { String? token; String? extensionData; ApplyForRequest({ this.token, this.extensionData, String? applyPosition, List? identityCard, List? licenseCard, DateTime? createTime, DateTime? updateTime, }) : super( applyPosition: applyPosition, identityCard: identityCard, licenseCard: licenseCard, createTime: createTime, updateTime: updateTime, ); factory ApplyForRequest.fromJson(Map map) { final identityCardData = map['IdentityCard']; final licenseCardData = map['LicenseCard']; return ApplyForRequest( token: map['Token'], extensionData: map['ExtensionData'], applyPosition: map['ApplyPosition'], identityCard: identityCardData != null ? (identityCardData as List).map((e) => e as String).toList() : null, licenseCard: licenseCardData != null ? (licenseCardData as List).map((e) => e as String).toList() : null, createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if (token != null) map['Token'] = token; if (extensionData != null) map['ExtensionData'] = extensionData; return map; } }