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 Company(db.Model): __tablename__ = "company" id = db.Column(db.String(32), primary_key=True, default=generate_uuid) name = db.Column(db.String(100)) users = db.relationship('User', backref='company', lazy='dynamic') def __unicode__(self): return u'<单位 {}>'.format(self.name) def __repr__(self): return u'<单位 {}>'.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 FlowInfo(db.Model): ''' 流程信息表 ''' __tablename__ = "flow_info" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) desc = db.Column(db.String(500)) create_time = db.Column(db.DateTime, default=datetime.datetime.now()) enable = db.Column(db.Boolean, default="Y") def __repr__(self): return u'<FlowInfo {}>'.format(self.name)
class Category(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) def __init__(self, name): self.name = name def __repr__(self): return '<Category %r>' % self.name
class Role(db.Model): __tablename__ = "role" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) flow_infos = db.relationship('FlowInfo', secondary=role_flow, backref=db.backref('role', lazy='dynamic'), lazy='dynamic') flow_action_infos = db.relationship("FlowActionInfo", backref=db.backref("role")) create_time = db.Column(db.DateTime, default=datetime.datetime.now()) enable = db.Column(db.Boolean, default=True) def __repr__(self): return u'<角色 {}>'.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 Workflow(Base): ''' 流程信息表 ''' __tablename__ = "workflow" id = Column(String(32), primary_key=True, default=generate_uuid) name = Column(String(20)) desc = Column(db.String(500)) create_time = Column(DateTime, default=datetime.datetime.now()) roles = relationship("Role", secondary=role_Workflow, backref='workflows') enable = Column(Boolean, default="Y") def __repr__(self): return u'<流程表 {}>'.format(self.name)
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 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