123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import datetime
- from sqlalchemy import (Column, Integer, String, BOOLEAN, DateTime,
- SmallInteger, UniqueConstraint)
- from db.base import Base
- class WorkCategory(Base):
- """作业资源分类
- """
- __tablename__ = "work_category"
- id = Column(Integer, primary_key=True, autoincrement=True)
- name = Column(String(20), nullable=False, comment="分类名称")
- pid = Column(Integer, nullable=True, comment="上级分类ID")
- pname = Column(String(50), nullable=True, comment="上级分类名称")
- period = Column(String(20), nullable=False, comment="学段")
- subject = Column(String(20), nullable=False, comment="学科")
- class WorkResource(Base):
- """作业资源
- """
- __tablename__ = "work_resource"
- id = Column(Integer, primary_key=True, autoincrement=True)
- category_id = Column(Integer, nullable=False, comment="资源分类id")
- name = Column(String(255), nullable=False, comment="资源名称")
- area = Column(String(20), nullable=False, comment="地区")
- year = Column(String(20), nullable=False, comment="年份")
- visit = Column(Integer, nullable=True, comment="浏览量")
- collect = Column(Integer, nullable=True, comment="收藏量")
- download = Column(Integer, nullable=True, comment="下载量")
- rtype = Column(String(16), default="", comment="资源类型")
- hot = Column(BOOLEAN(), default=False, comment="是否热点资源")
- attach_url = Column(String(1000), nullable=True, comment="资源附件")
- creator_id = Column(Integer, comment="创建人ID")
- creator_name = Column(String(32), comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, comment="最后编辑人ID")
- editor_name = Column(String(32), comment="最后编辑人名称")
- updated_at = Column(DateTime,
- default=datetime.datetime.now,
- onupdate=datetime.datetime.now)
- class ExamCategory(Base):
- """考试资源分类
- """
- __tablename__ = "exam_category"
- id = Column(Integer, primary_key=True, autoincrement=True)
- name = Column(String(20), nullable=False, comment="用户名")
- pid = Column(Integer, nullable=True, comment="用户名")
- pname = Column(String(50), nullable=True, comment="上级名称")
- period = Column(String(20), nullable=False, comment="学段")
- subject = Column(String(20), nullable=False, comment="学科")
- class ExamResource(Base):
- """考试资源
- """
- __tablename__ = "exam_resource"
- id = Column(Integer, primary_key=True, autoincrement=True)
- category_id = Column(Integer, nullable=False, comment="资源分类id")
- name = Column(String(255), nullable=False, comment="资源名称")
- area = Column(String(20), nullable=False, comment="地区")
- year = Column(String(20), nullable=False, comment="年份")
- visit = Column(Integer, nullable=True, comment="浏览量")
- collect = Column(Integer, nullable=True, comment="收藏量")
- download = Column(Integer, nullable=True, comment="下载量")
- attach_url = Column(String(1000), nullable=True, comment="资源附件")
- school_id = Column(Integer, nullable=False, comment="学校ID")
- school_name = Column(String(64), nullable=False, comment="学校名称")
- hot = Column(BOOLEAN(), default=False)
- creator_id = Column(Integer, comment="创建人ID")
- creator_name = Column(String(32), comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, comment="最后编辑人ID")
- editor_name = Column(String(32), comment="最后编辑人名称")
- updated_at = Column(DateTime,
- default=datetime.datetime.now,
- onupdate=datetime.datetime.now)
- # 资源收藏表
- class ResourceCollectInfo(Base):
- id = Column(Integer, primary_key=True, autoincrement=True)
- ctype = Column(String(4), nullable=False, comment="资源分类")
- rid = Column(Integer, nullable=False, comment="资源ID")
- uid = Column(Integer, nullable=False, comment="用户ID")
- utype = Column(SmallInteger, nullable=False, comment="用户类型,1:教师,2:学生")
- created_at = Column(DateTime, default=datetime.datetime.now)
- __tablename__ = "resource_collect_info"
- __table_args__ = (UniqueConstraint("uid",
- "utype",
- "rid",
- "ctype",
- name="uix_collect_uid_utype_rid_ctype"),)
|