86 lines
2.1 KiB
Dart
86 lines
2.1 KiB
Dart
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';
|
|
|
|
import '../../data/models/plan_acttion_type.dart';
|
|
|
|
///初始化计划
|
|
Future<int> initPlanApi(String need, int agentId) async {
|
|
var res = await Request().post("/plan/init", {
|
|
"user_need": need,
|
|
"agent_id": agentId,
|
|
});
|
|
return res['plan_id'];
|
|
}
|
|
|
|
///保存用户计划
|
|
Future<void> savePlanApi({
|
|
required int 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(int 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,
|
|
});
|
|
}
|
|
|
|
///编辑用户计划步骤
|
|
Future<void> editPlanStepApi(
|
|
int planId, {
|
|
required PlanActionType act,
|
|
int? stepId,
|
|
String? content,
|
|
String? explain,
|
|
}) async {
|
|
await Request().post("/plan/edit_plan_steps_info", {
|
|
"plan_id": planId,
|
|
"act": act.value,
|
|
"step_id": stepId,
|
|
"step_content": content,
|
|
"step_explain": explain,
|
|
});
|
|
}
|
|
|
|
///修改步骤顺序
|
|
Future<void> editPlanStepOrderApi(int planId,List<PlanStepDto> list) async {
|
|
await Request().post("/plan/change_plan_steps", {
|
|
"plan_id": planId,
|
|
"steps": list.map((e) => e.toJson()).toList(),
|
|
});
|
|
}
|