BuildService.dart 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'dart:convert';
  2. import 'package:colorize_logger/colorize_logger.dart';
  3. import 'package:get_it/get_it.dart';
  4. import 'dart:typed_data';
  5. import 'UserService.dart';
  6. class BuildService {
  7. Future<BuildHistory> LoadDataAsync() async {
  8. var userService = GetIt.instance.get<UserService>();
  9. final user = await userService.getCurrentUser();
  10. final token = user?.accessToken;
  11. dynamic datas = []; //TODO
  12. var list =
  13. datas.map<BuildHistory>((json) => BuildHistory.fromJson(json)).toList();
  14. return list;
  15. }
  16. decodeResponseBody(String logTag, Uint8List bodyBytes) {
  17. var utfString = utf8.decode(bodyBytes);
  18. Logger.info('$logTag response.body' + utfString);
  19. final parsed = jsonDecode(utfString);
  20. return parsed;
  21. }
  22. }
  23. class BuildHistory {
  24. final String id;
  25. final String platform;
  26. final DateTime createTime;
  27. final String userName;
  28. BuildHistory(
  29. {required this.id,
  30. required this.platform,
  31. required this.createTime,
  32. required this.userName});
  33. factory BuildHistory.fromJson(Map<String, dynamic> json) {
  34. return BuildHistory(
  35. id: json['id'] as String,
  36. platform: json['platform'] as String,
  37. createTime: json['createTime'] as DateTime,
  38. userName: json['userName'] as String,
  39. );
  40. }
  41. Map<String, dynamic> toJson() => {
  42. "id": id,
  43. "userName": userName,
  44. "platform": platform,
  45. "createTime": createTime
  46. };
  47. }
  48. class Platform {
  49. final String id;
  50. final String name;
  51. Platform({required this.id, required this.name});
  52. factory Platform.fromJson(Map<String, dynamic> json) {
  53. return Platform(
  54. id: json['id'] as String,
  55. name: json['name'] as String,
  56. );
  57. }
  58. Map<String, dynamic> toJson() => {
  59. "id": id,
  60. "name": name,
  61. };
  62. }