告警中心的二级详情页面+信息中心的页面+对接机器人接口
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:maibu_satabot_v2/core/consts/http_api_consts.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/data/datasources/site_datasource.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/site_entity.dart';
|
||||
|
||||
class SiteDataSourceImpl implements SiteDataSource {
|
||||
final Dio dio;
|
||||
|
||||
SiteDataSourceImpl(this.dio);
|
||||
|
||||
@override
|
||||
Future<List<SiteEntity>> getSiteList(int orgId) async {
|
||||
// 构建查询参数:orgId 为 0 时不传递
|
||||
final queryParams = <String, dynamic>{
|
||||
'pageNum': 1,
|
||||
'pageSize': 9999,
|
||||
};
|
||||
|
||||
if (orgId != 0) {
|
||||
queryParams['orgId'] = orgId;
|
||||
}
|
||||
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getSiteList,
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
return rows.map((item) => SiteEntity.fromJson(item)).toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user