# coding: utf-8 from sqlalchemy import Column, DateTime, Integer, Numeric, String from flask_sqlalchemy import SQLAlchemy #使用Werkzeug的security加密 from werkzeug.security import generate_password_hash,check_password_hash #與當前項目相關的模型文件,即所有的實體類在此編寫 from manage import db class User(db.Model): __tablename__ = 'user' sn = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), nullable=False, unique=True) password = db.Column(db.Text, nullable=False) #哈希加密版本 # class User(db.Model): # __tablename__ = 'user_info' # # sn = db.Column(db.Integer, primary_key=True) # username = db.Column(db.String(30), nullable=False, unique=True) # password = db.Column(db.Text, nullable=False) # # def __init__(self, *args, **kwargs): # username = kwargs.get('username') # password = kwargs.get('password') # # self.username = username # self.password = generate_password_hash(password) # # def check_hash_password(self,raw_password): 这里的参数是hash过的参数以及原始传入hash # result = check_password_hash(self.password, raw_password) # return result 得到验证結果   class Orientation(db.Model): __tablename__ = 'Orientation' sn = db.Column(db.Integer, primary_key=True) nr = db.Column(db.String(13), nullable=False, info='小小兵編號') mode = db.Column(db.Integer, nullable=True, info='方位') tilt_angle = db.Column(db.String(3), nullable=False) pan_angle = db.Column(db.String(3), nullable=False) zoom = db.Column(db.String(1), nullable=False, info='顯示UI') datetime = db.Column(db.DateTime, nullable=False) class Status(db.Model): __tablename__ = 'status' sn = db.Column(db.Integer, primary_key=True) nr = db.Column(db.String(13), nullable=False) status = db.Column(db.String(10), nullable=False) datetime = db.Column(db.DateTime, nullable=False) class JvtOTime(db.Model): __tablename__ = 'jvt_o_time' sn = db.Column(db.Integer, primary_key=True) mac = db.Column(db.String(20), nullable=False) nr = db.Column(db.String(20), nullable=False, info='小小兵編號') name = db.Column(db.Text, nullable=False, info='方位名稱') mode = db.Column(db.Integer, nullable=False, info='方位') tilt_angle = db.Column(db.String(3), nullable=False) pan_angle = db.Column(db.String(3), nullable=False) zoom = db.Column(db.Integer, nullable=False) time1 = db.Column(db.String(8), nullable=False) time2 = db.Column(db.String(8), nullable=False) time3 = db.Column(db.String(8), nullable=False) time4 = db.Column(db.String(8), nullable=False) time5 = db.Column(db.String(8), nullable=False) time6 = db.Column(db.String(8), nullable=False) time7 = db.Column(db.String(8), nullable=False) time8 = db.Column(db.String(8), nullable=False) datetime = db.Column(db.DateTime, nullable=False) class JvtOTimeHistory(db.Model): __tablename__ = 'jvt_o_time_history' sn = db.Column(db.Integer, primary_key=True) mac = db.Column(db.String(20), nullable=False) nr = db.Column(db.String(20), nullable=False, info='小小兵編號') name = db.Column(db.Text, nullable=False, info='方位名稱') mode = db.Column(db.Integer, nullable=False, info='方位') tilt_angle = db.Column(db.String(3), nullable=False) pan_angle = db.Column(db.String(3), nullable=False) zoom = db.Column(db.Integer, nullable=False) time1 = db.Column(db.String(8), nullable=False) time2 = db.Column(db.String(8), nullable=False) time3 = db.Column(db.String(8), nullable=False) time4 = db.Column(db.String(8), nullable=False) time5 = db.Column(db.String(8), nullable=False) time6 = db.Column(db.String(8), nullable=False) time7 = db.Column(db.String(8), nullable=False) time8 = db.Column(db.String(8), nullable=False) datetime = db.Column(db.DateTime, nullable=False) class SignalLog(db.Model): __tablename__ = 'signalLog' sn = db.Column(db.Integer, primary_key=True) nr = db.Column(db.String(13), nullable=False, info='小小兵編號') command = db.Column(db.String(20), nullable=False) response = db.Column(db.String(20), nullable=False) tilt_angle = db.Column(db.Text, nullable=True, info='垂直') pan_angle = db.Column(db.Text, nullable=True, info='水平') zoom = db.Column(db.Text, nullable=True, info='倍率') position = db.Column(db.Text, nullable=True, info='方位') datetime = db.Column(db.DateTime, nullable=False, info='日期時間') class Skyeye5GpsNr1(db.Model): __tablename__ = 'skyeye5_gps_nr1' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) lat = db.Column(db.Text, nullable=False) lng = db.Column(db.Text, nullable=False) log = db.Column(db.Text, nullable=False) class Skyeye5GpsNr2(db.Model): __tablename__ = 'skyeye5_gps_nr2' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) lat = db.Column(db.Text, nullable=False) lng = db.Column(db.Text, nullable=False) log = db.Column(db.Text, nullable=False) class Skyeye5GpsNr3(db.Model): __tablename__ = 'skyeye5_gps_nr3' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) lat = db.Column(db.Text, nullable=False) lng = db.Column(db.Text, nullable=False) log = db.Column(db.Text, nullable=False) class ImageSignalLog(db.Model): __tablename__ = 'imgSignalLog' sn = db.Column(db.Integer, primary_key=True) nr = db.Column(db.String(13), nullable=False, info='小小兵編號') command = db.Column(db.String(20), nullable=False) response = db.Column(db.String(20), nullable=False) position = db.Column(db.Text, nullable=True, info='方位') time = db.Column(db.Text, nullable=True, info='排程') size_a = db.Column(db.Text, nullable=False) size_b = db.Column(db.Text, nullable=False) filename = db.Column(db.String(20), nullable=False, info='照片名') datetime = db.Column(db.DateTime, nullable=False, info='日期時間') class RebootInfo(db.Model): __tablename__ = 'reboot_info' sn = db.Column(db.Integer, primary_key=True) nr = db.Column(db.String(13), nullable=False, info='小小兵編號') info = db.Column(db.Text, nullable=True, info='原因') value = db.Column(db.Text, nullable=True, info='數值') datetime = db.Column(db.DateTime, nullable=False, info='日期時間') # db.create_all()