2024-11-28 14:57:49 +08:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
import 'package:star_lock/network/api_provider.dart';
|
|
|
|
|
import 'package:star_lock/network/api_provider_base.dart';
|
2025-01-23 14:30:31 +08:00
|
|
|
import 'package:star_lock/talk/starChart/entity/relay_info_entity.dart';
|
|
|
|
|
import 'package:star_lock/talk/starChart/entity/report_information_data.dart';
|
|
|
|
|
import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart';
|
2024-11-28 14:57:49 +08:00
|
|
|
|
|
|
|
|
class StartChartApi extends BaseProvider {
|
|
|
|
|
// 星图url
|
|
|
|
|
final String _startChartHost = 'http://sls1-scd.star-lock.cn:8080';
|
|
|
|
|
|
2025-01-20 14:13:56 +08:00
|
|
|
static StartChartApi get to => Get.put(StartChartApi());
|
2024-11-28 14:57:49 +08:00
|
|
|
|
|
|
|
|
// 星图--注册节点
|
|
|
|
|
Future<StarChartRegisterNodeEntity> starChartRegisterNode({
|
|
|
|
|
required String product,
|
|
|
|
|
required String model,
|
|
|
|
|
required String name,
|
|
|
|
|
required String unique,
|
|
|
|
|
}) async {
|
|
|
|
|
final response = await post(
|
|
|
|
|
_startChartHost + starChartRegisterNodeURL.toUrl,
|
|
|
|
|
jsonEncode(<String, dynamic>{
|
|
|
|
|
'product': product,
|
|
|
|
|
'model': model,
|
|
|
|
|
'name': name,
|
|
|
|
|
'unique': unique,
|
|
|
|
|
}),
|
|
|
|
|
isUnShowLoading: true,
|
|
|
|
|
isUserBaseUrl: false,
|
|
|
|
|
);
|
|
|
|
|
return StarChartRegisterNodeEntity.fromJson(response.body);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 星图--中继查询
|
|
|
|
|
Future<RelayInfoEntity> relayQueryInfo() async {
|
|
|
|
|
final response = await get(
|
|
|
|
|
_startChartHost + relayQueryInfoURL.toUrl,
|
|
|
|
|
isUnShowLoading: true,
|
|
|
|
|
isUserBaseUrl: false,
|
|
|
|
|
);
|
|
|
|
|
return RelayInfoEntity.fromJson(response.body);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 星图--上报信息至发现服务
|
2024-11-30 15:39:06 +08:00
|
|
|
Future<Response> reportInformation({
|
2024-11-28 14:57:49 +08:00
|
|
|
required ReportInformationData reportInformationData,
|
|
|
|
|
}) async {
|
|
|
|
|
final response = await post(
|
|
|
|
|
_startChartHost + reportInformationDataURL.toUrl,
|
|
|
|
|
jsonEncode(reportInformationData.toJson()),
|
|
|
|
|
isUnShowLoading: true,
|
|
|
|
|
isUserBaseUrl: false,
|
|
|
|
|
);
|
2024-11-30 15:39:06 +08:00
|
|
|
return response;
|
2024-11-28 14:57:49 +08:00
|
|
|
}
|
2024-11-29 14:18:22 +08:00
|
|
|
|
|
|
|
|
// 星图--解析对端信息
|
2024-11-30 15:39:06 +08:00
|
|
|
Future<Response> analyzeInformationOtherEnd({
|
2024-11-29 14:18:22 +08:00
|
|
|
required String peerId,
|
|
|
|
|
}) async {
|
|
|
|
|
final response = await get(
|
|
|
|
|
_startChartHost + analyzeInformationOtherEndURL.toUrl + '?id=$peerId',
|
|
|
|
|
isUnShowLoading: true,
|
|
|
|
|
isUserBaseUrl: false,
|
|
|
|
|
);
|
2024-11-30 15:39:06 +08:00
|
|
|
return response;
|
2024-11-29 14:18:22 +08:00
|
|
|
}
|
2024-11-28 14:57:49 +08:00
|
|
|
}
|