# Path: handlers/base.py
# class BaseHandler(tornado.web.RequestHandler):
#     def __init__(self, application, request, **kwargs):
#         super(BaseHandler, self).__init__(application, request, **kwargs)
#         self.session = DB_Session()
# 
#     def data_received(self, chunk):
#         pass
# 
#     def get_current_user(self):
#         return self.get_secure_cookie("username")
# 
#     def on_finish(self):
#         self.session.close()
# 
# Path: models/models.py
# class Company(BaseModel):
#     __tablename__ = 'company'
# 
#     id = Column(Integer, Sequence('company_id_seq'), primary_key=True)  # id
#     code = Column(String(11), unique=True, nullable=True)  # 公司编码
#     name = Column(String(32))  # 公司名称
#     address = Column(String(64))  # 公司地址
#     parent = Column(String(11))  # 公司母公司
#     data = Column(DATE)  # 新建时间
#     user_group = relationship("UserGroup", backref="company")  # 对应的用户组
#     user = relationship("User", backref="company")  # 对应的用户
#     devices = relationship("Device", backref="company")  # 对应的设备
#     device_time_switch = relationship("DeviceTimeSwitch", backref="company")  # 对应的定时开关机表
#     device_week = relationship("DeviceWeek", backref="company")  # 对应的定时开关每周
#     device_day = relationship("DeviceDay", backref="company")  # 对应的定时开关机每天
#     device_group = relationship("DeviceGroup", backref="company")  # 对应的设备组
#     resources_group = relationship("ResGroup", backref="company")  # 对应的资源组
#     res_text = relationship("ResText", backref="company")  # 对应的文字资源
#     res_image = relationship("ResImage", backref="company")  # 对应的图片资源
#     res_video = relationship("ResVideo", backref="company")  # 对应的视频资源
#     my_task = relationship("MyTask", backref="company")  # 对应的任务
# 
# class User(BaseModel):
#     __tablename__ = 'user'
# 
#     id = Column(Integer, Sequence('user_id_seq'), primary_key=True)  # id
#     username = Column(String(32))  # 用户名
#     password = Column(CHAR(64))  # 密码
#     email = Column(String(32))  # 邮箱
#     is_active = Column(BOOLEAN)  # 是否激活
#     is_admin = Column(BOOLEAN)  # 是否管理员
#     data = Column(DATE)  # 新建时间
#     tell_phone = Column(CHAR(11))  # 电话号码
#     my_task = relationship("MyTask", backref="user")  # 对应的任务
#     company_id = Column(Integer, ForeignKey('company.id'))  # 外键  公司
#     userGroup = relationship('UserGroup', secondary=user_userGroup, back_populates='user')


import hashlib
import time
import tornado
import tornado.auth
import tornado.web
from handlers.base import BaseHandler
from models.models import Company, User
#!/usr/bin/env python
# _*_coding:utf-8_*_



# 公司管理
class CompanyHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self):

# Path: handlers/base.py
# class BaseHandler(tornado.web.RequestHandler):
#     def __init__(self, application, request, **kwargs):
#         super(BaseHandler, self).__init__(application, request, **kwargs)
#         self.session = DB_Session()
# 
#     def data_received(self, chunk):
#         pass
# 
#     def get_current_user(self):
#         return self.get_secure_cookie("username")
# 
#     def on_finish(self):
#         self.session.close()
# 
# Path: models/models.py
# class Company(BaseModel):
#     __tablename__ = 'company'
# 
#     id = Column(Integer, Sequence('company_id_seq'), primary_key=True)  # id
#     code = Column(String(11), unique=True, nullable=True)  # 公司编码
#     name = Column(String(32))  # 公司名称
#     address = Column(String(64))  # 公司地址
#     parent = Column(String(11))  # 公司母公司
#     data = Column(DATE)  # 新建时间
#     user_group = relationship("UserGroup", backref="company")  # 对应的用户组
#     user = relationship("User", backref="company")  # 对应的用户
#     devices = relationship("Device", backref="company")  # 对应的设备
#     device_time_switch = relationship("DeviceTimeSwitch", backref="company")  # 对应的定时开关机表
#     device_week = relationship("DeviceWeek", backref="company")  # 对应的定时开关每周
#     device_day = relationship("DeviceDay", backref="company")  # 对应的定时开关机每天
#     device_group = relationship("DeviceGroup", backref="company")  # 对应的设备组
#     resources_group = relationship("ResGroup", backref="company")  # 对应的资源组
#     res_text = relationship("ResText", backref="company")  # 对应的文字资源
#     res_image = relationship("ResImage", backref="company")  # 对应的图片资源
#     res_video = relationship("ResVideo", backref="company")  # 对应的视频资源
#     my_task = relationship("MyTask", backref="company")  # 对应的任务
# 
# class User(BaseModel):
#     __tablename__ = 'user'
# 
#     id = Column(Integer, Sequence('user_id_seq'), primary_key=True)  # id
#     username = Column(String(32))  # 用户名
#     password = Column(CHAR(64))  # 密码
#     email = Column(String(32))  # 邮箱
#     is_active = Column(BOOLEAN)  # 是否激活
#     is_admin = Column(BOOLEAN)  # 是否管理员
#     data = Column(DATE)  # 新建时间
#     tell_phone = Column(CHAR(11))  # 电话号码
#     my_task = relationship("MyTask", backref="user")  # 对应的任务
#     company_id = Column(Integer, ForeignKey('company.id'))  # 外键  公司
#     userGroup = relationship('UserGroup', secondary=user_userGroup, back_populates='user')


# Path: handlers/fra.py
import hashlib
import time
import tornado
import tornado.auth
import tornado.web
from handlers.base import BaseHandler
from models.models import Company, User

#!/usr/bin/env python
# _*_coding:utf-8_*_



# 公司管理
class CompanyHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self):

        companys = self.session.query(Company).filter(Company.id == self.get_secure_cookie('company_id')).all()