Files
plan_flutter/lib/api/dto/plan_detail_dto.dart
zhutao ca376d9393 1.列表,筛选完成和未完成
2.详情,增加checkout
2025-09-24 10:22:35 +08:00

88 lines
2.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class PlanStepDto {
int? id;
String? stepIcon;
String? stepContent;
String? stepExplain;
int? stepStatus;
PlanStepDto({this.id, this.stepIcon, this.stepContent, this.stepExplain, this.stepStatus});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id ?? 0;
map["step_icon"] = stepIcon;
map["step_content"] = stepContent;
map["step_explain"] = stepExplain;
map["step_status"] = stepStatus;
return map;
}
PlanStepDto.fromJson(dynamic json) {
id = json["id"];
stepIcon = json["step_icon"];
stepContent = json["step_content"];
stepExplain = json["step_explain"];
stepStatus = json["step_status"];
}
/// 浅拷贝(只复制字段,不生成新 id
PlanStepDto copyWith({
int? id,
String? stepIcon,
String? stepContent,
String? stepExplain,
int? stepStatus,
}) => PlanStepDto(
id: id ?? this.id,
stepIcon: stepIcon ?? this.stepIcon,
stepContent: stepContent ?? this.stepContent,
stepExplain: stepExplain ?? this.stepExplain,
stepStatus: stepStatus ?? this.stepStatus,
);
}
class PlanDetailDto {
String? agentName;
String? summary;
String? dialog;
List<PlanStepDto> stepsList;
List<String> suggestionsList;
String? planEndTime;
PlanDetailDto({
this.agentName,
this.summary,
this.dialog,
this.planEndTime,
List<PlanStepDto>? stepsList,
List<String>? suggestionsList,
}) : stepsList = stepsList ?? [],
suggestionsList = suggestionsList ?? [];
factory PlanDetailDto.fromJson(Map<String, dynamic> json) {
return PlanDetailDto(
agentName: json["agent_name"],
summary: json["summary"],
dialog: json["dialog"],
stepsList: json["steps"] != null
? (json["steps"] as List).map((v) => PlanStepDto.fromJson(v)).toList()
: [],
suggestionsList: json["suggestions"] != null
? List<String>.from(json["suggestions"])
: [],
planEndTime: json["plan_end_time"],
);
}
Map<String, dynamic> toJson() {
return {
"agent_name": agentName,
"summary": summary,
"dialog": dialog,
"steps": stepsList.map((v) => v.toJson()).toList(),
"suggestions": suggestionsList,
"plan_end_time": planEndTime,
};
}
}