class Block_Info(Base): __tablename__ = 'BlockInfo' id = db.Column(db.Integer, primary_key=True, autoincrement=True) block_name = db.Column(db.String(255), unique=True) def to_json(self): json_data = {'uid': self.main_id, 'label': self.block_name} return json_data @staticmethod def Write(mydirt): blockInfo = Block_Info() blockInfo.set_attrs(mydirt) db.session.add(blockInfo) db.session.commit() @staticmethod def Read(main_id): blockInfo = Block_Info.query.filter( Block_Info.main_id == main_id).first() return blockInfo @staticmethod def Delete(blockInfo): db.session.delete(blockInfo) db.session.commit() @staticmethod def ReadAll(): blockInfo = Block_Info.query.all() return blockInfo
class BlogContentTag(db.Model): __tablename__ = "blog_content_tag" content_id = db.Column(db.String(32), primary_key=True) # 关联内容id tag_id = db.Column(db.String(32), primary_key=True) def __repr__(self): return '<BlogContentTag %r>' % self.content_id
class CompanyRegisitLicenseFile(Base): __tablename__ = 'CompanyRegisitLicenseFile' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_business_id = db.Column( db.String(255), ForeignKey("CompanyRegisitBusinessScope.main_id")) company_license_file_name = db.Column(db.String(255)) company_license_file_link = db.Column(db.String(255))
class CompanyInfoAndAllLegal(Base): __tablename__ = 'CompanyInfoAndAllLegal' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_regisit_id = db.Column(db.String(255), ForeignKey("CompanyRegisitInfo.main_id")) company_alllegal_id = db.Column( db.String(255), ForeignKey("CompanyRegisitAllLegalPerson.main_id"))
class AdminRole(db.Model): __tablename__ = "admin_role" role_id = db.Column(db.String(32), primary_key=True) # 关联内容id admin_id = db.Column(db.String(32), primary_key=True) def __repr__(self): return '<AdminRole %r>' % self.admin_id
class AdminLog(BaseModel): __tablename__ = "admin_log" username = db.Column(db.String(100)) ip = db.Column(db.String(100)) def __repr__(self): return '<AdminLog %r>' % self.id
class CompanyRegisitFileZip(Base): __tablename__ = 'CompanyRegisitFileZip' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_regisit_id = db.Column(db.String(255), ForeignKey("CompanyRegisitInfo.main_id")) company_regisit_file_name = db.Column(db.String(255)) company_regisit_file_link = db.Column(db.String(255))
class CompanyInfoAndAllKind(Base): __tablename__ = 'CompanyInfoAndAllKind' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_regisit_id = db.Column(db.String(255), ForeignKey("CompanyRegisitInfo.main_id")) company_kind_id = db.Column(db.String(255), ForeignKey("CompanyRegisitKind.main_id"))
class FirstLevelDepartment(Base): id = db.Column(db.SmallInteger, nullable=False, autoincrement=True, primary_key=True) name = db.Column(db.Text, nullable=False) phone = db.Column(db.BigInteger)
class RoleRule(db.Model): __tablename__ = "role_rule" role_id = db.Column(db.String(32), primary_key=True) # 关联内容id rule_id = db.Column(db.String(32), primary_key=True) def __repr__(self): return '<RoleRule %r>' % self.role_id
class MetalpartsTag(BaseModel): __tablename__ = "metalparts_tag" name = db.Column(db.String(100), nullable=False) sort = db.Column(db.Integer, default=0) # 排序 lang = db.Column(db.String(20)) def __repr__(self): return '<MetalpartsTag %r>' % self.name
class Admin(UserMixin, Base): __tablename__ = "admin" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64), unique=True, nullable=False) _password = db.Column('password', db.String(128), nullable=False) is_super = db.Column(db.SmallInteger, default=0) # 是否超级管理员 1为是 0为否 role_id = db.Column(db.Integer, nullable=False) # 角色 def __repr__(self): return '<Admin %r>' % self.username @property def password(self): """ 读取属性 :return: """ return self._password @password.setter def password(self, raw): """ 为password写入属性 :param raw:明文密码 :return:加密后的密码 """ self._password = generate_password_hash(raw) def check_pwd(self, raw): """ 密码验证 :param raw: :return: """ return check_password_hash(self._password, raw)
class Role(BaseModel): __tablename__ = "role" name = db.Column(db.String(100), unique=True, nullable=False) info = db.Column(db.String(255)) def __repr__(self): return '<Role %r>' % self.name
class ScoreUser(Base): __tablename__ = 'score_user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) sc_user_id = db.Column(db.String(255)) # 评价人 sc_le_user_id = db.Column(db.String(255)) # 被点评人 sc_value = db.Column(db.Integer) # 分数 -1 为弃权票 sc_time = db.Column(db.Date) # 评价时间 @staticmethod def getMonthFirstDayAndLastDay(year=None, month=None): """ :param year: 年份,默认是本年,可传int或str类型 :param month: 月份,默认是本月,可传int或str类型 :return: firstDay: 当月的第一天,datetime.date类型 lastDay: 当月的最后一天,datetime.date类型 """ if year: year = int(year) else: year = datetime.date.today().year if month: month = int(month) else: month = datetime.date.today().month # 获取当月第一天的星期和当月的总天数 firstDayWeekDay, monthRange = calendar.monthrange(year, month) # 获取当月的第一天 firstDay = datetime.date(year=year, month=month, day=1) lastDay = datetime.date(year=year, month=month, day=monthRange) return firstDay, lastDay
class Knowledge_Article_GoodCollection(Base): __tablename__='Knowledge_Article_GoodCollection' id = db.Column(db.Integer, primary_key=True, autoincrement=True) article_id = db.Column(db.String(255), ForeignKey('Knowledge_Articles_Info.main_id')) #文章Id user_Id = db.Column(db.String(255), ForeignKey('user_and_oa.user_id')) #用户 good_status = db.Column(db.Integer, default=0) # 是否收藏 0 未收藏, 1 已收藏 collection_status = db.Column(db.Integer, default=0) # 是否点赞 0 未点赞, 1 已点赞
class Wish(Base): id = db.Column(db.Integer, primary_key=True) user = relationship('User') uid = db.Column(db.Integer, ForeignKey('user.id')) isbn = db.Column(db.String(15), nullable=False) # book = relationship('Book') # bid = db.Column(db.Integer,ForeignKey('book.id')) launched = db.Column(db.Boolean, default=False) @classmethod def get_user_wishes(cls, uid): wishes = Wish.query.filter_by(uid=uid, launched=False).order_by( desc(Wish.create_time)).all() return wishes @classmethod def get_gift_counts(cls, isbn_list): from app.models.gift import Gift # 根据传入的一组isbn,到Wish表中计算出某个礼物的Wish心愿数量 count_list = db.session.query(func.count(Gift.id), Gift.isbn).filter( Gift.launched == False, Gift.isbn.in_(isbn_list), Gift.status == 1).group_by(Gift.isbn).all() count_list = [{'count': w[0], 'isbn': w[1]} for w in count_list] return count_list @property def book(self): yushu_book = YuShuBook() yushu_book.search_by_isbn(self.isbn) return yushu_book.first
class CompanyInfoAndAllContent(Base): __tablename__ = 'CompanyInfoAndAllContent' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_regisit_id = db.Column(db.String(255), ForeignKey("CompanyRegisitInfo.main_id")) company_allcontent_id = db.Column( db.String(255), ForeignKey("CompanyRegisitServiceAllContent.main_id"))
class DoctorSpec(db.Model): __tablename__ = 'doctor_spec' id = db.Column(db.Integer, primary_key=True) spec_id = db.Column(db.Integer, primary_key=True) def __repr__(self): return f'<Doctor_Spec(doctor={self.id}, spec={self.spec_id})>'
class ArticleType(db.Model): __tablename__ = 'article_type' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(64), nullable=False) articles = db.relationship("NewSubmission", backref='type') def __repr__(self): return '<ArticleType id={0}, name={1}>'.format(self.id, self.name)
class Lang(BaseModel): __tablename__ = "lang" name = db.Column(db.String(20)) ename = db.Column(db.String(20), nullable=False) sort = db.Column(db.Integer, default=0) # 排序 def __repr__(self): return '<Lang %r>' % self.name
class Userlog(Base): __tablename__ = "userlog" id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) ip = db.Column(db.String(100)) def __repr__(self): return '<Userlog %r>' % self.id
class CompanyRegisitBusinessScope(Base): __tablename__ = 'CompanyRegisitBusinessScope' id = db.Column(db.Integer, primary_key=True, autoincrement=True) company_regisit_id = db.Column(db.String(255), ForeignKey("CompanyRegisitInfo.main_id")) company_regisit_name = db.Column(db.String(255)) company_business_scope = db.Column(db.String(255)) status = db.Column(db.Integer, default=1) # 0下架, 1正常
class CompanyProviderAndAllContent(Base): __tablename__ = 'CompanyProviderAndAllContent' id = db.Column(db.Integer, primary_key=True, autoincrement=True) provider_regisit_id = db.Column( db.String(255), ForeignKey("CompanyProviderInfo.main_id")) # 服务商Id provider_allcontent_id = db.Column( db.String(255), ForeignKey("CompanyRegisitProviderAllContent.main_id")) # 服务商服务内容
class CompanyProviderCustomers(Base): __tablename__ = 'CompanyProviderCustomers' # 数据库名称 id = db.Column(db.Integer, primary_key=True, autoincrement=True) provider_regisit_id = db.Column( db.String(255), ForeignKey("CompanyProviderInfo.main_id")) # 服务商id company_servicecustomers_id = db.Column(db.String(255)) # 合同号 company_servicecustomers_people = db.Column(db.String(255)) # 服务商客户 company_serviceprovider_feedback = db.Column(db.String(255)) # 反馈
class NbTeam(Base): __tablename__ = 'NbTeam' id = db.Column(db.Integer, primary_key=True, autoincrement=True) t_name = db.Column(db.String(255)) # 团队名称 t_header_id = db.Column(db.String(255)) # 团队长id t_header_name = db.Column(db.String(255)) # 团队长 名字 user_value = relationship("UserAndOA", secondary=NbTeam_And_User) grade = db.Column(db.Integer, default=0) # 显示位置
class Tag(Base): __tablename__ = "tag" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) sort = db.Column(db.Integer, default=0) # 排序 def __repr__(self): return '<Tag %r>' % self.name
class Role(Base): __tablename__ = "role" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), unique=True, nullable=False) auths = db.Column(db.String(512)) def __repr__(self): return '<Role %r>' % self.name
class Adspace(Base): __tablename__ = "adspace" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) ename = db.Column(db.String(100)) def __repr__(self): return '<Adspace %r>' % self.name
class Operationlog(Base): __tablename__ = "operationlog" id = db.Column(db.Integer, primary_key=True) admin_id = db.Column(db.Integer) ip = db.Column(db.String(100)) reason = db.Column(db.String(600)) # 操作原因 def __repr__(self): return '<Operationlog %r>' % self.id
class Adminlog(Base): __tablename__ = "adminlog" id = db.Column(db.Integer, primary_key=True) admin_id = db.Column(db.Integer) ip = db.Column(db.String(100)) info = db.Column(db.String(255)) def __repr__(self): return '<Adminlog %r>' % self.id