base.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy import String, Column, Integer,DateTime,Text,Date,Time,ForeignKey
  3. from database import Base
  4. from sqlalchemy.orm import relationship
  5. from datetime import datetime
  6. class AppInfo(Base):
  7. """
  8. 应用表
  9. """
  10. __tablename__ = "tp_app_info"
  11. app_id = Column(String(100), primary_key=True)
  12. app_secret = Column(String(100))
  13. hashed_secret = Column(String(100))
  14. app_name = Column(String(100))
  15. note = Column(String(100))
  16. def __repr__(self):
  17. return "<AppInfo>{}:{}".format(self.app_id, self.app_secret)
  18. class Config:
  19. orm_mode = True
  20. class ApiServiceEntity(Base):
  21. __tablename__ = "tp_api_service"
  22. id = Column(String(100), primary_key=True)
  23. name = Column(String(100))
  24. status = Column(String(100))
  25. create_time = Column(DateTime, default=datetime.now)
  26. class Config:
  27. orm_mode = True
  28. class DatasourceEntity(Base):
  29. __tablename__ = "tp_datasource"
  30. id = Column(String(100), primary_key=True)
  31. name = Column(String(100))
  32. scope = Column(String(100))
  33. dsn = Column(String(100))
  34. dbtype = Column(String(100))
  35. host = Column(String(100))
  36. user = Column(String(100))
  37. password = Column(String(100))
  38. database = Column(String(100))
  39. port = Column(Integer)
  40. charset = Column(String(100))
  41. class Config:
  42. orm_mode = True
  43. class CommandEntity(Base):
  44. __tablename__ = "tp_command"
  45. id = Column(String(100), primary_key=True)
  46. sqltext = Column(String(100))
  47. datasource = Column(String(100))
  48. scope = Column(String(100))
  49. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now)
  50. class Config:
  51. orm_mode = True
  52. class OprIdxStat(Base):
  53. """
  54. 指标统计表
  55. 统计各项指标
  56. """
  57. __tablename__ = "opr_idx_stat"
  58. id = Column(Integer, primary_key=True, autoincrement=True, comment='id')
  59. stat_dt = Column(DateTime,comment='统计日期')
  60. stat_lvl = Column(Integer,comment='统计级别 1地市2市有关单位3区县')
  61. area_id = Column(String(100),comment='行政区划编码')
  62. area_nm = Column(String(100),comment='行政区划名称')
  63. index_no = Column(String(100),comment='指标编号')
  64. index_nm = Column(String(100),comment='指标名称')
  65. index_value = Column(String(100),comment='指标度量值')
  66. index_unit = Column(String(100), comment='指标单位')
  67. etl_time = Column(DateTime,comment='etl加工时间戳')
  68. class Config:
  69. orm_mode = True
  70. class OprIdx(Base):
  71. """
  72. 指标表
  73. 存储各项指标,记录统计sql
  74. """
  75. __tablename__ = "opr_idx"
  76. id = Column(Integer, primary_key=True, autoincrement=True, comment='id')
  77. index_no = Column(String(100),comment='指标编号')
  78. index_nm = Column(String(100),comment='指标名称')
  79. index_sql = Column(Text,comment='指标统计sql')
  80. index_corn = Column(String(100), comment='执行指标corn表达式')
  81. create_time = Column(DateTime,comment='创建时间')
  82. class Config:
  83. orm_mode = True
  84. class MsgCenter(Base):
  85. """
  86. 消息中心
  87. """
  88. __tablename__ = "msg_center"
  89. id = Column(Integer, primary_key=True, autoincrement=True, comment='id')
  90. msg_type = Column(String, comment='消息类型')
  91. msg_id = Column(String,comment='消息ID')
  92. recv_time = Column(DateTime, default=datetime.now, comment='接收时间')
  93. recv_userid = Column(Integer, comment='接收用户ID')
  94. recv_status = Column(Integer, default="0", comment='接收状态 0 未阅 1 已阅')
  95. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='创建时间')
  96. del_flag = Column(String, default='0', comment='删除标志(0代表存在 2代表删除)')
  97. content = Column(String, default='', comment='消息内容')
  98. foreign_key = Column(String(50), comment='文件外键 --技术字段')
  99. from_scenario = Column(String(50), comment='对应标识 --技术字段')
  100. title = Column(String, default='', comment='标题')
  101. class Config:
  102. orm_mode = True
  103. class CzrzEntity(Base):
  104. __tablename__ = 'tp_czrz'
  105. id = Column(Integer, autoincrement=True, primary_key=True, index=True)
  106. user_id = Column(Integer, default=0, server_default="0")
  107. user_name = Column(String, default='', server_default='')
  108. nick_name = Column(String, default='', server_default='')
  109. czrz = Column(String, default='', server_default='')
  110. gxsj = Column(DateTime, default=0, server_default="0")
  111. ip = Column(String, default='', server_default='')
  112. action = Column(String, default='', server_default='')
  113. sign = Column(String, default='', server_default='')
  114. class Config:
  115. orm_mode = True