knowledge_base.py 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, DateTime, Table, MetaData,Text
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy.orm import relationship, sessionmaker
  4. Base = declarative_base()
  5. metadata = MetaData()
  6. from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
  7. from sqlalchemy.orm import relationship
  8. class KnowledgeFile(Base):
  9. __tablename__ = 'knowledge_file'
  10. id = Column(Integer, primary_key=True, autoincrement=True, comment="id")
  11. file_identifier = Column(String(50), unique=True, nullable=False, comment='文件唯一标识符')
  12. file_path = Column(Text, nullable=False, comment='文件路径')
  13. file_name = Column(String(255), nullable=False, comment='文件名字')
  14. is_deleted = Column(Integer, default=0, comment='是否删除')
  15. createTime = Column(DateTime, comment='创建时间')
  16. updateTime = Column(DateTime, comment='更新时间')
  17. storage_file_name = Column(Text,comment = '文件存储名字')
  18. knowledge_base_code = Column(String(50), ForeignKey('knowledge_base.base_code'), nullable=False)
  19. knowledge_base = relationship("KnowledgeBase", back_populates="files")
  20. class KnowledgeBase(Base):
  21. __tablename__ = 'knowledge_base'
  22. id = Column(Integer, primary_key=True, autoincrement=True, comment="id")
  23. reportId = Column(String(255),comment='报告ID')
  24. reportUid = Column(String(255),comment='报告UUID')
  25. reportName = Column(String(400), comment='报告名称')
  26. subject = Column(String(100), comment='主题词')
  27. eventType = Column(String(10), comment='事件类型')
  28. publishDate = Column(DateTime, comment='发布日期')
  29. publishingUnit = Column(String(255), comment='来源单位')
  30. summary = Column(String(100), comment='摘要')
  31. notificationType = Column(String(100), comment='知识类型')
  32. updateTime = Column(DateTime, comment='更新时间')
  33. base_code = Column(String(50), unique=True, comment='知识库的基础编码')
  34. del_flag = Column(String(10), comment='是否删除')
  35. files = relationship("KnowledgeFile", order_by=KnowledgeFile.id, back_populates="knowledge_base")
  36. class HazardStandardsFile(Base):
  37. __tablename__ = 'hazard_standards_file'
  38. id = Column(Integer, primary_key=True, autoincrement=True)
  39. file_id = Column(String(50), nullable=False, comment='文件id')#uuid
  40. file_number = Column(String(50), nullable=False, comment='文件编号')#YHBZ+10位随机数字
  41. file_name = Column(String(255), nullable=False, comment='文件名称')#url
  42. standard_type = Column(String(255), nullable=False, comment='标准类型 1国家版,2广东省版')#标准类型
  43. file_name_desc = Column(String(255), nullable=False, comment='文件名称原名')#name
  44. file_title = Column(String(255), nullable=False, comment='标准文件名称')#name
  45. file_path = Column(String(255), nullable=True, comment='文件存储路径')
  46. file_size = Column(String(50), nullable=True, comment='文件大小')
  47. status = Column(String(50), nullable=True, comment='文件状态')
  48. foreign_key = Column(String(50), nullable=True, comment='文件外键 --技术字段')
  49. from_scenario = Column(String(50), nullable=True, comment='对应标识 --技术字段')
  50. del_flag = Column(String(1), default='0', comment='删除标志(0代表存在 2代表删除)')
  51. create_dept = Column(Integer, default=None, comment='创建部门')
  52. create_by = Column(Integer, default=None, comment='创建者')
  53. create_time = Column(DateTime, default=datetime.now, comment='创建时间')
  54. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')