123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import datetime
- from sqlalchemy import Column, Integer, String, BOOLEAN, DateTime, SmallInteger, UniqueConstraint,TEXT
- from db import BaseORMModel
- class WorkCategory(BaseORMModel):
- """作业资源分类
- """
- __tablename__ = "work_categories"
- id = Column(Integer, primary_key=True, autoincrement=True)
- name = Column(String(64), nullable=False, comment="分类名称")
- pid = Column(Integer, default=0, comment="上级分类ID")
- pname = Column(String(64), default="", comment="上级分类名称")
- period = Column(String(20), nullable=False, comment="学段")
- subject = Column(String(20), nullable=False, comment="学科")
- __table_args__ = (UniqueConstraint("name",
- "pid",
- "subject",
- "period",
- name="uix_work_name_pid_subject_period"),)
- class WorkResource(BaseORMModel):
- """作业资源
- """
- __tablename__ = "work_resources"
- id = Column(Integer, primary_key=True, autoincrement=True)
- category_id = Column(Integer, nullable=False, comment="资源分类id")
- category_name = Column(String(64), nullable=False, comment="分类名称")
- name = Column(String(255), nullable=False, comment="资源名称")
- subject = Column(String(10), nullable=False, comment="所属科目")
- area = Column(String(20), nullable=False, comment="地区")
- year = Column(String(20), nullable=False, comment="年份")
- visit = Column(Integer, default=0, comment="浏览量")
- collect = Column(Integer, default=0, comment="收藏量")
- download = Column(Integer, default=0, comment="下载量")
- rtype = Column(String(16), default="", comment="资源类型")
- hot = Column(BOOLEAN(), default=False, comment="是否热点资源")
- attach_url = Column(String(1000), default="", comment="资源附件")
- creator_id = Column(Integer, nullable=False, comment="创建人ID")
- creator_name = Column(String(32), nullable=False, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, nullable=False, comment="最后编辑人ID")
- editor_name = Column(String(32), nullable=False, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- class ExamCategory(BaseORMModel):
- """考试资源分类
- """
- __tablename__ = "exam_categories"
- id = Column(Integer, primary_key=True, autoincrement=True)
- name = Column(String(64), nullable=False, comment="用户名")
- pid = Column(Integer, default=0, comment="上级分类ID")
- pname = Column(String(64), default="", comment="上级名称")
- period = Column(String(20), nullable=False, comment="学段")
- subject = Column(String(20), nullable=False, comment="学科")
- __table_args__ = (UniqueConstraint("name",
- "pid",
- "subject",
- "period",
- name="uix_exam_name_pid_subject_period"),)
- class ExamResource(BaseORMModel):
- """考试资源
- """
- __tablename__ = "exam_resources"
- id = Column(Integer, primary_key=True, autoincrement=True)
- category_id = Column(Integer, nullable=False, comment="资源分类id")
- category_name = Column(String(64), nullable=False, comment="分类名称")
- name = Column(String(255), nullable=False, comment="资源名称")
- subject = Column(String(10), nullable=False, comment="所属科目")
- area = Column(String(20), nullable=False, comment="地区")
- year = Column(String(20), nullable=False, comment="年份")
- visit = Column(Integer, default=0, comment="浏览量")
- collect = Column(Integer, default=0, comment="收藏量")
- download = Column(Integer, default=0, comment="下载量")
- attach_url = Column(String(1000), default="", 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, nullable=False, comment="创建人ID")
- creator_name = Column(String(32), nullable=False, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, nullable=False, comment="最后编辑人ID")
- editor_name = Column(String(32), nullable=False, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- # 资源收藏表
- class ResourceCollectInfo(BaseORMModel):
- 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"),)
- class ResourceQuestions(BaseORMModel):
- """
- """
- id = Column(Integer, primary_key=True, autoincrement=True)
- rid = Column(Integer, nullable=False, comment="资源ID")
- rtype = Column(String(4), nullable=False,default="work",comment="资源类型,work/exam")
- qno = Column(String(32), nullable=False, comment="题号")
- qtype = Column(String(6), default="", comment="单选题/多选题/判断题/主观题")
- answer = Column(String(200), default="", comment="标准答案")
- analysis = Column(TEXT, default="", comment="答案解析")
- level = Column(String(50), default="", comment="难度,简单/中等/困难")
- lpoints = Column(String(1000), default="", comment="知识点")
- stem = Column(TEXT, default="", comment="试题题干")
- __tablename__ = "resource_questions"
- CATEGORY_MODES = {"work": WorkCategory, "exam": ExamCategory}
- RESOURCE_MODES = {"work": WorkResource, "exam": ExamResource}
|