patient.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import 'package:vital_local_database/core/interface/entity.dart';
  2. import 'package:vital_local_database/core/sqlite/entity.dart';
  3. import 'syncable.dart';
  4. /// 病人实体
  5. class PatientEntity extends SyncableEntity<PatientEntity> {
  6. static const String _tableName = "patients";
  7. static final _columns = PatientColumnsDefine();
  8. /**
  9. *
  10. * map['code'] = code;
  11. map['dataJson'] = dataJson;
  12. map['syncType'] = syncType.index;
  13. map['syncState'] = syncState.index;
  14. */
  15. // ignore: constant_identifier_names
  16. static const TABLE_CREATE_SQL = 'CREATE TABLE IF NOT EXISTS "patients" ('
  17. '"id" INTEGER NOT NULL,'
  18. '"code" VARCHAR(100) NOT NULL,'
  19. '"name" VARCHAR(200) NOT NULL,'
  20. '"dataJson" TEXT NOT NULL,'
  21. '"extJson" TEXT NULL,'
  22. '"syncType" INTEGER NOT NULL,'
  23. '"syncState" INTEGER NOT NULL,'
  24. '"createTime" DATETIME NOT NULL,'
  25. '"updateTime" DATETIME NULL,'
  26. '"isValid" INTEGER NOT NULL,'
  27. 'PRIMARY KEY ("id")'
  28. ');';
  29. @override
  30. PatientColumnsDefine get columns => _columns;
  31. @override
  32. String get tableName => _tableName;
  33. /// 扩展Json
  34. String? extJson;
  35. /// 姓名
  36. String name = "";
  37. @override
  38. Map<String, dynamic> toJson() {
  39. final map = super.toJson();
  40. map['name'] = name;
  41. map['extJson'] = extJson;
  42. return map;
  43. }
  44. @override
  45. PatientEntity fromJson(Map<String, dynamic> map) {
  46. super.fromJson(map);
  47. name = map['name'];
  48. extJson = map['extJson'];
  49. return this;
  50. }
  51. }
  52. /// 病人字段定义
  53. class PatientColumnsDefine extends SyncableColumnsDefine<PatientEntity>
  54. implements IDbColumnsDefine<PatientEntity> {
  55. final name = DbColumn<String>("name");
  56. final extJson = DbColumn<String>("extJson");
  57. }