1
This commit is contained in:
@@ -9,7 +9,7 @@ class PlanStepDto {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["id"] = id;
|
||||
map["id"] = id ?? 0;
|
||||
map["step_icon"] = stepIcon;
|
||||
map["step_content"] = stepContent;
|
||||
map["step_explain"] = stepExplain;
|
||||
|
||||
41
lib/api/dto/plan_item_dto.dart
Normal file
41
lib/api/dto/plan_item_dto.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
class PlanItemDto {
|
||||
int? id;
|
||||
String? agentName;
|
||||
String? summary;
|
||||
int? completedSteps;
|
||||
int? totalSteps;
|
||||
int? planStatus;
|
||||
String? createdAt;
|
||||
|
||||
PlanItemDto({
|
||||
this.id,
|
||||
this.agentName,
|
||||
this.summary,
|
||||
this.completedSteps,
|
||||
this.totalSteps,
|
||||
this.planStatus,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["plan_id"] = id;
|
||||
map["agent_name"] = agentName;
|
||||
map["summary"] = summary;
|
||||
map["completed_steps"] = completedSteps;
|
||||
map["total_steps"] = totalSteps;
|
||||
map["plan_status"] = planStatus;
|
||||
map["created_at"] = createdAt;
|
||||
return map;
|
||||
}
|
||||
|
||||
PlanItemDto.fromJson(dynamic json) {
|
||||
id = json["plan_id"] ?? 0;
|
||||
agentName = json["agent_name"] ?? "";
|
||||
summary = json["summary"] ?? "";
|
||||
completedSteps = json["completed_steps"] ?? 0;
|
||||
totalSteps = json["total_steps"] ?? 0;
|
||||
planStatus = json["plan_status"] ?? 0;
|
||||
createdAt = json["created_at"] ?? "";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:plan/api/dto/plan_detail_dto.dart';
|
||||
import 'package:plan/api/dto/plan_item_dto.dart';
|
||||
import 'package:plan/api/network/request.dart';
|
||||
|
||||
///初始化计划
|
||||
@@ -8,3 +10,49 @@ Future<int> initPlanApi(String need, int agentId) async {
|
||||
});
|
||||
return res['plan_id'];
|
||||
}
|
||||
|
||||
///保存用户计划
|
||||
Future<void> savePlanApi({
|
||||
required String planId,
|
||||
required String summary,
|
||||
required String dialog,
|
||||
required List<PlanStepDto> steps,
|
||||
required List<String> suggestions,
|
||||
}) async {
|
||||
await Request().post("/plan/save_plan", {
|
||||
"plan_id": planId,
|
||||
"summary": summary,
|
||||
"dialog": dialog,
|
||||
"steps": steps.map((e) => e.toJson()).toList(),
|
||||
"suggestions": suggestions,
|
||||
});
|
||||
}
|
||||
|
||||
///获取计划列表
|
||||
Future<List<PlanItemDto>> getPlanListApi() async {
|
||||
var res = await Request().get("/plan/plan_list");
|
||||
return res['list'].map<PlanItemDto>((e) => PlanItemDto.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
///编辑计划摘要
|
||||
Future<void> editPlanSummaryApi(int planId, String summary) async {
|
||||
await Request().post("/plan/edit_plan_summary", {
|
||||
"plan_id": planId,
|
||||
"summary": summary,
|
||||
});
|
||||
}
|
||||
|
||||
///获取计划详情
|
||||
Future<PlanDetailDto> getPlanDetailApi(String planId) async {
|
||||
var res = await Request().get("/plan/plan_detail", {
|
||||
"plan_id": planId,
|
||||
});
|
||||
return PlanDetailDto.fromJson(res);
|
||||
}
|
||||
|
||||
///删除计划
|
||||
Future<void> deletePlanApi(int planId) async {
|
||||
await Request().get("/plan/delete_plan", {
|
||||
"plan_id": planId,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user