import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter_unit/point_system/github_model/github_model.dart'; /// create by 张风捷特烈 on 2020/6/17 /// contact me by email 1981462002@qq.com /// 说明: const kBaseUrl = 'http://119.45.173.197:8080/api/v1'; class IssuesApi { static Dio dio = Dio(BaseOptions(baseUrl: kBaseUrl)); static Future getRepoFlutterUnit() async { Response rep = await dio.get('/repository/name/FlutterUnit'); dynamic repoStr = rep.data['data']['repositoryData']; return Repository.fromJson(json.decode(repoStr)); } static Future> getIssues( {int page = 1, int pageSize = 100}) async { List res = (await dio.get('/point', queryParameters: {"page": page, "pageSize": pageSize})) .data['data'] as List; return res.map((e) => Issue.fromJson(json.decode(e['pointData']))).toList(); } static Future> getIssuesComment(int pointId) async { List res = (await dio.get('/pointComment/$pointId')).data['data'] as List; return res .map((e) => IssueComment.fromJson(json.decode(e['pointCommentData']))) .toList(); } }