models.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. # coding: utf-8
  2. from sqlalchemy import Column, DateTime, Integer, Numeric, String
  3. from flask_sqlalchemy import SQLAlchemy
  4. #使用Werkzeug的security加密
  5. from werkzeug.security import generate_password_hash,check_password_hash
  6. #與當前項目相關的模型文件,即所有的實體類在此編寫
  7. from manage import db
  8. class User(db.Model):
  9. __tablename__ = 'user'
  10. sn = db.Column(db.Integer, primary_key=True)
  11. username = db.Column(db.String(30), nullable=False, unique=True)
  12. password = db.Column(db.Text, nullable=False)
  13. #哈希加密版本
  14. # class User(db.Model):
  15. # __tablename__ = 'user_info'
  16. #
  17. # sn = db.Column(db.Integer, primary_key=True)
  18. # username = db.Column(db.String(30), nullable=False, unique=True)
  19. # password = db.Column(db.Text, nullable=False)
  20. #
  21. # def __init__(self, *args, **kwargs):
  22. # username = kwargs.get('username')
  23. # password = kwargs.get('password')
  24. #
  25. # self.username = username
  26. # self.password = generate_password_hash(password)
  27. #
  28. # def check_hash_password(self,raw_password): 这里的参数是hash过的参数以及原始传入hash
  29. # result = check_password_hash(self.password, raw_password)
  30. # return result 得到验证結果  
  31. class Orientation(db.Model):
  32. __tablename__ = 'Orientation'
  33. sn = db.Column(db.Integer, primary_key=True)
  34. nr = db.Column(db.String(13), nullable=False, info='小小兵編號')
  35. mode = db.Column(db.Integer, nullable=True, info='方位')
  36. tilt_angle = db.Column(db.String(3), nullable=False)
  37. pan_angle = db.Column(db.String(3), nullable=False)
  38. zoom = db.Column(db.String(1), nullable=False, info='顯示UI')
  39. datetime = db.Column(db.DateTime, nullable=False)
  40. class Status(db.Model):
  41. __tablename__ = 'status'
  42. sn = db.Column(db.Integer, primary_key=True)
  43. nr = db.Column(db.String(13), nullable=False)
  44. status = db.Column(db.String(10), nullable=False)
  45. datetime = db.Column(db.DateTime, nullable=False)
  46. class JvtOTime(db.Model):
  47. __tablename__ = 'jvt_o_time'
  48. sn = db.Column(db.Integer, primary_key=True)
  49. mac = db.Column(db.String(20), nullable=False)
  50. nr = db.Column(db.String(20), nullable=False, info='小小兵編號')
  51. name = db.Column(db.Text, nullable=False, info='方位名稱')
  52. mode = db.Column(db.Integer, nullable=False, info='方位')
  53. tilt_angle = db.Column(db.String(3), nullable=False)
  54. pan_angle = db.Column(db.String(3), nullable=False)
  55. zoom = db.Column(db.Integer, nullable=False)
  56. time1 = db.Column(db.String(8), nullable=False)
  57. time2 = db.Column(db.String(8), nullable=False)
  58. time3 = db.Column(db.String(8), nullable=False)
  59. time4 = db.Column(db.String(8), nullable=False)
  60. time5 = db.Column(db.String(8), nullable=False)
  61. time6 = db.Column(db.String(8), nullable=False)
  62. time7 = db.Column(db.String(8), nullable=False)
  63. time8 = db.Column(db.String(8), nullable=False)
  64. datetime = db.Column(db.DateTime, nullable=False)
  65. class JvtOTimeHistory(db.Model):
  66. __tablename__ = 'jvt_o_time_history'
  67. sn = db.Column(db.Integer, primary_key=True)
  68. mac = db.Column(db.String(20), nullable=False)
  69. nr = db.Column(db.String(20), nullable=False, info='小小兵編號')
  70. name = db.Column(db.Text, nullable=False, info='方位名稱')
  71. mode = db.Column(db.Integer, nullable=False, info='方位')
  72. tilt_angle = db.Column(db.String(3), nullable=False)
  73. pan_angle = db.Column(db.String(3), nullable=False)
  74. zoom = db.Column(db.Integer, nullable=False)
  75. time1 = db.Column(db.String(8), nullable=False)
  76. time2 = db.Column(db.String(8), nullable=False)
  77. time3 = db.Column(db.String(8), nullable=False)
  78. time4 = db.Column(db.String(8), nullable=False)
  79. time5 = db.Column(db.String(8), nullable=False)
  80. time6 = db.Column(db.String(8), nullable=False)
  81. time7 = db.Column(db.String(8), nullable=False)
  82. time8 = db.Column(db.String(8), nullable=False)
  83. datetime = db.Column(db.DateTime, nullable=False)
  84. class SignalLog(db.Model):
  85. __tablename__ = 'signalLog'
  86. sn = db.Column(db.Integer, primary_key=True)
  87. nr = db.Column(db.String(13), nullable=False, info='小小兵編號')
  88. command = db.Column(db.String(20), nullable=False)
  89. response = db.Column(db.String(20), nullable=False)
  90. tilt_angle = db.Column(db.Text, nullable=True, info='垂直')
  91. pan_angle = db.Column(db.Text, nullable=True, info='水平')
  92. zoom = db.Column(db.Text, nullable=True, info='倍率')
  93. position = db.Column(db.Text, nullable=True, info='方位')
  94. datetime = db.Column(db.DateTime, nullable=False, info='日期時間')
  95. class Skyeye5GpsNr1(db.Model):
  96. __tablename__ = 'skyeye5_gps_nr1'
  97. sn = db.Column(db.Integer, primary_key=True)
  98. datetime = db.Column(db.DateTime, nullable=False)
  99. lat = db.Column(db.Text, nullable=False)
  100. lng = db.Column(db.Text, nullable=False)
  101. log = db.Column(db.Text, nullable=False)
  102. class Skyeye5GpsNr2(db.Model):
  103. __tablename__ = 'skyeye5_gps_nr2'
  104. sn = db.Column(db.Integer, primary_key=True)
  105. datetime = db.Column(db.DateTime, nullable=False)
  106. lat = db.Column(db.Text, nullable=False)
  107. lng = db.Column(db.Text, nullable=False)
  108. log = db.Column(db.Text, nullable=False)
  109. class Skyeye5GpsNr3(db.Model):
  110. __tablename__ = 'skyeye5_gps_nr3'
  111. sn = db.Column(db.Integer, primary_key=True)
  112. datetime = db.Column(db.DateTime, nullable=False)
  113. lat = db.Column(db.Text, nullable=False)
  114. lng = db.Column(db.Text, nullable=False)
  115. log = db.Column(db.Text, nullable=False)
  116. class ImageSignalLog(db.Model):
  117. __tablename__ = 'imgSignalLog'
  118. sn = db.Column(db.Integer, primary_key=True)
  119. nr = db.Column(db.String(13), nullable=False, info='小小兵編號')
  120. command = db.Column(db.String(20), nullable=False)
  121. response = db.Column(db.String(20), nullable=False)
  122. position = db.Column(db.Text, nullable=True, info='方位')
  123. time = db.Column(db.Text, nullable=True, info='排程')
  124. size_a = db.Column(db.Text, nullable=False)
  125. size_b = db.Column(db.Text, nullable=False)
  126. filename = db.Column(db.String(20), nullable=False, info='照片名')
  127. datetime = db.Column(db.DateTime, nullable=False, info='日期時間')
  128. class RebootInfo(db.Model):
  129. __tablename__ = 'reboot_info'
  130. sn = db.Column(db.Integer, primary_key=True)
  131. nr = db.Column(db.String(13), nullable=False, info='小小兵編號')
  132. info = db.Column(db.Text, nullable=True, info='原因')
  133. value = db.Column(db.Text, nullable=True, info='數值')
  134. datetime = db.Column(db.DateTime, nullable=False, info='日期時間')
  135. # db.create_all()