model_factory.dart 1.0 KB

12345678910111213141516171819202122232425262728
  1. import 'package:device_info_plus/device_info_plus.dart';
  2. import 'package:drift/drift.dart';
  3. import 'package:lszlgl/drfit/database.dart';
  4. import 'package:lszlgl/service/print_service.dart';
  5. import '../model/rsp/user_rsp.dart';
  6. import '../service/user_service.dart';
  7. class ModelFactory {
  8. static Future<DeviceInfoTableCompanion> convertToTSlideComp(String bleMac, String bleName, String phoneAddress) async {
  9. UserRsp? userRsp = UserService.get().getUser();
  10. AndroidDeviceInfo? androidDeviceInfo = await PrintService.getDeviceInfo();
  11. var tsc = DeviceInfoTableCompanion(
  12. username: Value.absentIfNull(userRsp?.username),
  13. phoneBrand: Value.absentIfNull(androidDeviceInfo?.board),
  14. phoneModel: Value.absentIfNull(androidDeviceInfo?.model),
  15. phoneRelease: Value.absentIfNull(androidDeviceInfo?.version.release),
  16. phoneAddress: Value(phoneAddress),
  17. bleMac: Value(bleMac),
  18. bleName: Value(bleName),
  19. createdAt: Value(DateTime.now().millisecondsSinceEpoch)
  20. );
  21. return tsc;
  22. }
  23. }