knowledge_base.py 3.7 KB

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