BasicInfo.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import 'package:flutter/material.dart';
  2. import 'package:sqflite/sqflite.dart';
  3. import 'package:flutter_habit/common/SqfliteDataBase.dart';
  4. class BasicInfo {
  5. String tableName = "basicInfo";
  6. Map<String, dynamic> value = {
  7. "id" : null,
  8. "height" : null,
  9. "weight" : null,
  10. "breastLine" : null,
  11. "waistLine" : null,
  12. "hipLine" : null,
  13. "date" : null,
  14. };
  15. static Future<void> create() async {
  16. Database database = SqfliteDataBase.getInstance()!;
  17. await database.execute("""
  18. CREATE TABLE IF NOT EXISTS basicInfo (
  19. id INTEGER PRIMARY KEY AUTOINCREMENT ,
  20. height REAL NOT NULL ,
  21. weight REAL NOT NULL ,
  22. breastLine REAL NOT NULL ,
  23. waistLine REAL NOT NULL ,
  24. hipLine REAL NOT NULL ,
  25. date INTEGER NOT NULL
  26. );
  27. """);
  28. debugPrint("create basicInfo");
  29. }
  30. static Future<void> recreate() async {
  31. Database database = SqfliteDataBase.getInstance()!;
  32. await database.execute("""
  33. DROP TABLE IF EXISTS basicInfo;
  34. """);
  35. debugPrint("drop basicInfo");
  36. await create();
  37. }
  38. List<BasicInfo> resultAsList(List<Map<String, dynamic>> dbResult) {
  39. return dbResult.map((value) {
  40. BasicInfo entity = BasicInfo();
  41. entity.value = value;
  42. return entity;
  43. }).toList();
  44. }
  45. int? getId() {
  46. return value["id"];
  47. }
  48. BasicInfo setId(int? id) {
  49. value["id"] = id;
  50. return this;
  51. }
  52. double? getHeight() {
  53. return value["height"];
  54. }
  55. BasicInfo setHeight(double? height) {
  56. value["height"] = height;
  57. return this;
  58. }
  59. double? getWeight() {
  60. return value["weight"];
  61. }
  62. BasicInfo setWeight(double? weight) {
  63. value["weight"] = weight;
  64. return this;
  65. }
  66. double? getBreastLine() {
  67. return value["breastLine"];
  68. }
  69. BasicInfo setBreastLine(double? cheatLine) {
  70. value["breastLine"] = cheatLine;
  71. return this;
  72. }
  73. double? getWaistLine() {
  74. return value["waistLine"];
  75. }
  76. BasicInfo setWaistLine(double? waistLine) {
  77. value["waistLine"] = waistLine;
  78. return this;
  79. }
  80. double? getHipLine() {
  81. return value["hipLine"];
  82. }
  83. BasicInfo setHipLine(double? hipLine) {
  84. value["hipLine"] = hipLine;
  85. return this;
  86. }
  87. int? getDate() {
  88. return value["date"];
  89. }
  90. BasicInfo setDate(int date) {
  91. value["date"] = date;
  92. return this;
  93. }
  94. @override
  95. String toString() {
  96. return value.toString();
  97. }
  98. }