class FlowStepInfo(db.Model): ''' 流程步骤对应表 ''' id=db.Column(db.Integer,primary_key=True) name = db.Column(db.String(20)) flow_info_id=db.Column(db.Integer,db.ForeignKey("flow_info.id")) flow_info = db.relationship("FlowInfo",backref=db.backref('flow_step_infos', order_by=id)) flow_action_info_id=db.Column(db.Integer,db.ForeignKey("flow_action_info.id")) flow_action_info=db.relationship("FlowActionInfo",backref=db.backref('flow_step_infos')) repeat_no=db.Column(db.Integer,default=1)#重复次数 order_no=db.Column(db.Integer) #排序号 def __repr__(self): return u'<FlowStepInfo {}>'.format(self.name)
class UserFlowInfo(db.Model): ''' 用户流程表 ''' id=db.Column(db.Integer,primary_key=True) user_id=db.Column(db.Integer,db.ForeignKey("user.id")) flow_info_id=db.Column(db.Integer,db.ForeignKey("flow_info.id")) flow_info=db.relationship('FlowInfo',backref=db.backref('user_flow_infos')) step_id=db.Column(db.Integer,db.ForeignKey("flow_step_info.id")) step=db.relationship('FlowStepInfo',backref=db.backref('user_flow_infos')) next_user_id=db.Column(db.Integer,db.ForeignKey("user.id")) is_finish=db.Column(db.Boolean,default=False) create_time=db.Column(db.DateTime,default=datetime.datetime.now()) def __repr__(self): return u'<UserFlowInfo {}>'.format(self.id)
class FlowActionInfo(db.Model): ''' 步骤信息表 ''' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) desc=db.Column(db.String(500)) role_id = db.Column(db.Integer,db.ForeignKey("role.id")) def __repr__(self): return u'<FlowActionInfo {}>'.format(self.name)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), unique=True) roles = db.relationship('Role', secondary=user_role, backref=db.backref('users', lazy='dynamic'), lazy='dynamic') email = db.Column(db.String(120), unique=True) password = db.Column(db.String(30), unique=True) company_id = db.Column(db.String(32), db.ForeignKey('company.id')) create_time = db.Column(db.DateTime, default=datetime.datetime.now()) def __repr__(self): return u'<user {}>'.format(self.name)
class TranctProc(db.Model): ''' 用户流程表详尽 ''' id = db.Column(db.Integer, primary_key=True) user_flow_info_id = db.Column(db.Integer, db.ForeignKey("user_flow_info.id")) user_flow_info = db.relationship('UserFlowInfo', backref=db.backref('tranct_procs', lazy='dynamic')) step_action = db.Column(db.Integer) # 同意1,退回2,终止3 step_time = db.Column(db.DateTime, default=datetime.datetime.now()) desc = db.Column(db.String(500)) def __repr__(self): return u'<TranctProc {}>'.format(self.id)
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80)) body = db.Column(db.Text) pub_date = db.Column(db.DateTime) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) category = db.relationship('Category', backref=db.backref('posts', lazy='dynamic')) def __init__(self, title, body, category, pub_date=None): self.title = title self.body = body if pub_date is None: pub_date = datetime.utcnow() self.pub_date = pub_date self.category = category def __repr__(self): return '<Post %r>' % self.title
# coding:utf-8 import datetime import uuid from flask_admin.contrib.sqla import ModelView from flask_login import UserMixin from ..moudel.util import generate_uuid from managesys import db, is_debug, admin import sqlalchemy.types as types user_role = db.Table('user_role', db.Column('user_id', db.Integer, db.ForeignKey('user.id'), primary_key=True), db.Column('role_id', db.Integer, db.ForeignKey('role.id'), primary_key=True) ) class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), unique=True) roles = db.relationship('Role', secondary=user_role, backref=db.backref('users', lazy='dynamic'), lazy='dynamic') email = db.Column(db.String(120), unique=True) password = db.Column(db.String(30), unique=True) company_id = db.Column(db.String(32), db.ForeignKey('company.id')) create_time = db.Column(db.DateTime, default=datetime.datetime.now()) def __repr__(self): return u'<user {}>'.format(self.name) # role和flowinfo是多对多关系