Пример #1
0
class Share(db.Model):
    __tablename__ = "share"
    Id = db.Column(db.Integer, primary_key=True)
    ObjectId = db.Column(db.Integer, db.ForeignKey("object.Id"))
    CreatorUserId = db.Column(db.Integer, db.ForeignKey("user.Id"))
    Name = db.Column(db.VARCHAR(255))
    CreateTime = db.Column(db.TIMESTAMP)
    Users = db.relationship("ShareUser",
                            backref=db.backref("Share", uselist=False),
                            lazy="dynamic",
                            foreign_keys="ShareUser.ShareObjectId")
    CreatorUser = db.relationship("User",
                                  backref=db.backref("Shares", lazy="dynamic"),
                                  uselist=False,
                                  foreign_keys="Share.CreatorUserId")
    Object = db.relationship("Object",
                             uselist=False,
                             backref=db.backref("Shares"))
    UsersCache = db.relationship("ShareUserCache",
                                 backref=db.backref("Share", uselist=False),
                                 lazy="dynamic",
                                 foreign_keys="ShareUserCache.ShareObjectId")

    def __init__(self, Name, CreatorUserId, ObjectId):
        self.Name = Name
        self.CreatorUserId = CreatorUserId
        self.ObjectId = ObjectId
        # self.CreateTime='current_timestamp()'

    def __repr__(self):
        return '<Share %r>' % {
            'Id': self.Id,
            'CreatorUserId': self.CreatorUserId
        }
Пример #2
0
class WewFactor(db.Model):
    __tablename__ = "wew_factor"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(1 - 0))
    classes = {}

    def __init__(self, id, name):
        self.classes = []
        self.id = id
        self.name = name

    def json(self):
        """Returns the models data converted to JSON"""
        return {"classes": self.classes, "id": self.id, "name": self.name}

    @staticmethod
    def delete():
        """Empties the table specified in the model"""
        db.session.execute("SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE wew_factor; SET FOREIGN_KEY_CHECKS = 1;")
        db.session.commit()

    def save(self):
        """Saves the object to the table specified in the model"""
        db.session.add(self)
        db.session.commit()
Пример #3
0
class TaxonLevel(db.Model):
    __tablename__ = "taxon_level"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))

    def __init__(self, name):
        self.name = name

    def json(self):
        """Returns the models data converted to JSON"""
        return {"id": self.id, "name": self.name}

    @classmethod
    def findTaxonLevelById(cls, id):
        """Returns the data of a specific taxon level chosen by id"""
        return cls.query.filter_by(id = id).first()

    @classmethod
    def findAllTaxonLevels(cls):
        """Returns the data of all taxon levels"""
        return cls.query.all()

    def save(self):
        """Saves the object to the table specified in the model"""
        db.session.add(self)
        db.session.commit()

    def delete(self):
        """Deletes the object from the table specified in the model"""
        db.session.delete(self)
        db.session.commit()
Пример #4
0
class Reference(db.Model):
    __tablename__ = "reference"
    id = db.Column(db.Integer, primary_key=True)
    watertype_id = db.Column(db.Integer)

    def __init__(self, id, watertype_id):
        self.id = id
        self.watertype_id = watertype_id

    def json(self):
        """Returns the models data converted to JSON"""
        return {"id": self.id, "watertypeId": self.watertype_id}

    @classmethod
    def getReference(cls, id):
        """Returns the data of a specific reference chosen by id"""
        return cls.query.filter_by(id=id).first()

    @classmethod
    def getAllReferences(cls):
        """Returns the data of all references"""
        return cls.query.all()

    @classmethod
    def findReferencesByWatertype(cls, watertype_id):
        """Returns the data of a specific reference chosen by watertype id"""
        return cls.query.filter_by(watertype_id=watertype_id).first()
Пример #5
0
class Order(db.Model):
    __tablename__ = "order"
    Id = db.Column(db.BIGINT, primary_key=True)
    SerialNumber = db.Column(db.VARCHAR(255))
    Subject = db.Column(db.VARCHAR(100))
    Description = db.Column(db.VARCHAR(255))
    Amount = db.Column(db.FLOAT)
    UseAccount = db.Column(db.FLOAT)
    State = db.Column(db.INT)
    PayUserId = db.Column(db.BIGINT, db.ForeignKey('user.Id'))
    ReceiverId = db.Column(db.BIGINT, db.ForeignKey('user.Id'))
    CreateTime = db.Column(db.TIMESTAMP)
    PayUser = db.relation('User',
                          foreign_keys='Order.PayUserId',
                          lazy="joined")
    Receiver = db.relation('User',
                           foreign_keys='Order.ReceiverId',
                           lazy="joined")

    def __init__(self, SerialNumber, Subject, Description, Amount, PayUserId,
                 ReceiverId):
        self.SerialNumber = SerialNumber
        self.Subject = Subject
        self.Description = Description
        self.Amount = Amount
        self.UseAccount = 0
        self.PayUserId = PayUserId
        self.ReceiverId = ReceiverId
        self.State = OrderState.UnPay
Пример #6
0
class Watertype(db.Model):
    __tablename__ = "watertype"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    code = db.Column(db.String(10))

    def __init__(self, id, name, code):
        self.id = id
        self.name = name
        self.code = code

    def json(self):
        """Returns the models data converted to JSON"""
        return {"id": self.id, "name": self.name, "code": self.code}

    @classmethod
    def findWatertypeById(cls, id):
        """Returns the data of a watertype chosen by id"""
        return cls.query.filter_by(id = id).first()

    @classmethod
    def findAllWatertypes(cls):
        """Returns the data of all watertypes"""
        return cls.query.all()

    def save(self):
        """Saves the object to the table specified in the model"""
        db.session.add(self)
        db.session.commit()

    def delete(self):
        """Deletes the object from the table specified in the model"""
        db.session.delete(self)
        db.session.commit()
Пример #7
0
class Settings(db.Model):
    __tablename__ = "settings"
    Item = db.Column(db.VARCHAR(255), primary_key=True)
    Value = db.Column(db.VARCHAR(255))

    def __init__(self, item, value):
        self.Item = item
        self.Value = value
Пример #8
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post {}>'.format(self.body)
Пример #9
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))

    def __repr__(self):
        return '<User {}>'.format(self.username)
Пример #10
0
class Subject(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(200), unique=True)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return "<Subject %r>" % self.name
Пример #11
0
class Segment(db.Model):
    __tablename__ = 'segment'
    Id = db.Column(db.BIGINT, primary_key=True)
    Name = db.Column(db.VARCHAR(20))
    Identity = db.Column(db.VARCHAR(20))

    def __init__(self, req_id, seg_id):
        self.RequirementId = req_id
        self.SegmentId = seg_id
Пример #12
0
class Favortie(db.Model):
    __tablename__ = "favorite"
    Id = db.Column(db.INT, primary_key=True)
    ZoneItemId = db.Column(db.VARCHAR(255))
    UserId = db.Column(db.VARCHAR(255))

    def __init__(self, zi, ud):
        self.ZoneItemId = zi
        self.UserId = ud
Пример #13
0
class ManageUser(db.Model):
    __tablename__ = "manage_user"
    Id = db.Column(db.INT, primary_key=True)
    CustomerCount = db.Column(db.BIGINT)
    ProducerCount = db.Column(db.BIGINT)
    UpdateTime = db.Column(db.DATETIME)

    def __init__(self, cc, pc):
        self.CustomerCount = cc
        self.ProducerCount = pc
Пример #14
0
class CollectionProducer(db.Model):
    __tablename__ = "collection_producer"
    Id = db.Column(db.BIGINT, primary_key=True)
    DomainId = db.Column(db.BIGINT, db.ForeignKey("domain.Id"))
    UserId = db.Column(db.BIGINT)
    Domain = db.relation('Domain', lazy="joined")

    def __init__(self, domain_id, user_id):
        self.DomainId = domain_id
        self.UserId = user_id
Пример #15
0
class GroupUser(db.Model):
    __tablename__ = "groupuser"
    Id = db.Column(db.BIGINT, primary_key=True)
    GroupId = db.Column(db.BIGINT, db.ForeignKey('group.Id'))
    UserId = db.Column(db.BIGINT, db.ForeignKey('user.Id'))
    Group = db.relationship('Group', uselist=False)

    def __init__(self, GroupId, UserId):
        self.GroupId = GroupId
        self.UserId = UserId
Пример #16
0
class Group(db.Model):
    __tablename__ = "group"
    Id = db.Column(db.Integer, primary_key=True)
    GroupName = db.Column(db.String(50))
    ShareObjectId = db.Column(db.Integer, db.ForeignKey("share.Id"))
    GroupRead = db.Column(db.BOOLEAN)
    GroupWrite = db.Column(db.BOOLEAN)
    GroupCreate = db.Column(db.BOOLEAN)
    GroupDelete = db.Column(db.BOOLEAN)
    GroupDownload = db.Column(db.BOOLEAN)
    CreateTime = db.Column(db.TIMESTAMP)
    ShareObject = db.relationship('Share',
                                  backref=db.backref('Groups', lazy='dynamic'),
                                  lazy='select',
                                  uselist=False)
    Users = db.relationship('User',
                            secondary=groupusers,
                            backref=db.backref('Group', uselist=False))
    UsersQuery = db.relationship('User', secondary=groupusers, lazy='dynamic')

    def __init__(self, GroupName, GroupRead, GroupWrite, GroupCreate,
                 GroupDelete, GroupDownload):
        self.GroupName = GroupName
        self.GroupRead = GroupRead
        self.GroupWrite = GroupWrite
        self.GroupCreate = GroupCreate
        self.GroupDelete = GroupDelete
        self.GroupDownload = GroupDownload
        # self.CreateTime='current_timestamp()'
    def __repr__(self):
        return '<Group %r>' % {'Id': self.Id, 'OwnerUserId': self.OwnerUserId}
Пример #17
0
class ShareUserCache(db.Model):
    __tablename__ = "shareusercache"
    Id = db.Column(db.Integer, primary_key=True)
    ShareObjectId = db.Column(db.Integer, db.ForeignKey("share.Id"))
    UserId = db.Column(db.Integer, db.ForeignKey("user.Id"))
    UserRead = db.Column(db.BOOLEAN)
    UserWrite = db.Column(db.BOOLEAN)
    UserCreate = db.Column(db.BOOLEAN)
    UserDelete = db.Column(db.BOOLEAN)
    UserDownload = db.Column(db.BOOLEAN)
    CreateTime = db.Column(db.TIMESTAMP)
    User = db.relationship('User',
                           lazy='joined',
                           backref=db.backref('ShareCache', lazy='dynamic'))
    ShareObject = db.relationship('Share',
                                  uselist=False,
                                  backref=db.backref('ShareUserCache',
                                                     lazy='dynamic'))

    def __init__(self, UserId, UserRead, UserWrite, UserCreate, UserDelete,
                 UserDownload):
        self.UserId = UserId
        self.UserRead = UserRead
        self.UserWrite = UserWrite
        self.UserCreate = UserCreate
        self.UserDelete = UserDelete
        self.UserDownload = UserDownload
        # self.CreateTime='current_timestamp()'

    def __repr__(self):
        return '<Domain %r>' % {'Id': self.Id, 'UserId': self.UserId}
Пример #18
0
class CollectionVideo(db.Model):
    __tablename__ = "collection_video"
    Id = db.Column(db.BIGINT, primary_key=True)
    ZoneItemId = db.Column(db.BIGINT, db.ForeignKey("zone_item.Id"))
    UserId = db.Column(db.BIGINT, db.ForeignKey("user.Id"))
    ZoneItem = db.relation('ZoneItem', lazy="joined")
    User = db.relation('User', lazy="joined")

    def __init__(self, item_id, user_id):
        self.ZoneItemId = item_id
        self.UserId = user_id
Пример #19
0
class WewFactorClass(db.Model):
    __tablename__ = "wew_factor_class"
    id = db.Column(db.Integer, primary_key=True)
    factor_id = db.Column(db.Integer, db.ForeignKey("wew_factor.id"))
    code = db.Column(db.String(10))
    description = db.Column(db.String(100))
    order = db.Column(db.Integer)
    computed_value = 0

    def __init__(self, id, factor_id, code, description, order):
        self.id = id
        self.factor_id = factor_id
        self.code = code
        self.description = description
        self.order = order
        self.computed_value = 0

    def json(self):
        """Returns the models data converted to JSON"""
        return {
            "id": self.id,
            "factorId": self.factor_id,
            "code": self.code,
            "description": self.description,
            "order": self.order
        }

    def jsonComputed(self):
        """Returns the models data converted to JSON"""
        return {"factorClassId": self.id, "computedValue": self.computed_value}

    @classmethod
    def findAllFactors(cls):
        return cls.query.all()

    @classmethod
    def getComputedRefValue(cls, referenceId, factorClass):
        engine = db.engine
        return engine.execute(
            func.calc_computed_value_ref(referenceId,
                                         factorClass)).fetchone()[0]

    @staticmethod
    def delete():
        """Empties the table specified in the model"""
        db.session.execute(
            "SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE wew_factor_class; SET FOREIGN_KEY_CHECKS = 1;"
        )
        db.session.commit()

    def save(self):
        """Saves the object to the table specified in the model"""
        db.session.add(self)
        db.session.commit()
Пример #20
0
class RoleRight(db.Model):
    __tablename__ = "roleright"
    Id = db.Column(db.BIGINT, primary_key=True)
    RightId = db.Column(db.BIGINT, db.ForeignKey('right.Id'))
    RoleId = db.Column(db.BIGINT, db.ForeignKey('role.Id'))
    Checked = db.Column(db.BOOLEAN)

    def __init__(self, rightId, roleId, checked):
        self.RightId = rightId
        self.RoleId = roleId
        self.Checked = checked
Пример #21
0
class ContractClips(db.Model):
    __tablename__ = "contractclips"
    Id = db.Column(db.BIGINT, primary_key=True)
    ContractId = db.Column(db.BIGINT, db.ForeignKey('contract.Id'))
    Version = db.Column(db.BIGINT)
    Detail = db.Column(db.TEXT)
    ContractClipsHistory = db.relation('ContractClipsHistory')

    def __init__(self, version, contractId):
        self.Version = version
        self.ContractId = contractId
Пример #22
0
class FinalVideo(db.Model):
    __tablename__ = "finalvideo"
    Id = db.Column(db.BIGINT, primary_key=True)
    ContractId = db.Column(db.BIGINT, db.ForeignKey('contract.Id'))
    Version = db.Column(db.BIGINT)
    Detail = db.Column(db.TEXT)
    FinalVideoHistory = db.relation('FinalVideoHistory')

    def __init__(self, version, contractId):
        self.Version = version
        self.ContractId = contractId
Пример #23
0
class WeiXinToken(db.Model):
    __tablename__ = "weixin_token"
    Id = db.Column(db.INT, primary_key=True)
    AccessToken = db.Column(db.VARCHAR(1024))
    CreateTime = db.Column(db.TIMESTAMP)
    Expires_in = db.Column(db.INT)

    def __init__(self, access_token, expires_in):
        self.AccessToken = access_token
        self.Expires_in = expires_in
        self.CreateTime = datetime.datetime.now()
Пример #24
0
class AttachmentProtect(db.Model):
    __tablename__ = "attachment_protect"
    Id = db.Column(db.BIGINT, primary_key=True)
    ObjectId = db.Column(db.INT)
    ContractId = db.Column(db.INT)
    Deadline = db.Column(db.DATETIME)

    def __init__(self, objectid, contractid, deadline):
        self.ObjectId = objectid
        self.ContractId = contractid
        self.Deadline = deadline
Пример #25
0
class ProducerSetting(db.Model):
    __tablename__ = "setting_producer"
    DomainId = db.Column(db.BIGINT,
                         db.ForeignKey('domain.Id'),
                         primary_key=True)
    Position = db.Column(db.INT)
    Domain = db.relation('Domain', foreign_keys='ProducerSetting.DomainId')

    def __init__(self, did, position):
        self.DomainId = did
        self.Position = position
Пример #26
0
class RequirementSegment(db.Model):
    __tablename__ = 'requirement_segment'
    Id = db.Column(db.BIGINT, primary_key=True)
    RequirementId = db.Column(db.BIGINT, db.ForeignKey('requirement.Id'))
    SegmentId = db.Column(db.INT, db.ForeignKey('segment.Id'))
    Segment = db.relation('Segment', lazy='joined')
    Requirement = db.relation('Requirement', backref=db.backref('Segments', lazy='joined'), lazy='joined')

    def __init__(self, req_id, seg_id):
        self.RequirementId = req_id
        self.SegmentId = seg_id
Пример #27
0
class RequirementTemplate(db.Model):
    __tablename__ = "requirement_template"
    Id = db.Column(db.BIGINT, primary_key=True)
    Category_1 = db.Column(db.INT)
    Category_2 = db.Column(db.INT)
    Detail = db.Column(db.TEXT)

    def __init__(self, category_1, category_2, content):
        self.Category_1 = category_1
        self.Category_2 = category_2
        self.Detail = content
Пример #28
0
class MarkPoint(db.Model):
    __tablename__ = "markpoint"
    Id = db.Column(db.BIGINT, primary_key=True)
    AttachmentId = db.Column(db.BIGINT)
    Time = db.Column(db.TIME)
    Content = db.Column(db.TEXT)

    def __init__(self, attachmentId, time, content):
        self.AttachmentId = attachmentId
        self.Time = time
        self.Content = content
Пример #29
0
class RechargeAccountOrder(db.Model):
    __tablename__ = "rechargeAccount_order"
    Id = db.Column(db.BIGINT, primary_key=True)
    Amount = db.Column(db.BIGINT)
    OrderId = db.Column(db.BIGINT, db.ForeignKey("order.Id"))
    CreateTime = db.Column(db.TIMESTAMP)
    Order = db.relation('Order', lazy="joined")

    def __init__(self, amount, orderId):
        self.Amount = amount
        self.OrderId = orderId
Пример #30
0
class RequirementReplyGroup(db.Model):
    __tablename__ = "requirement_reply_group"
    Id = db.Column(db.BIGINT, primary_key=True)
    RequirementId = db.Column(db.BIGINT, db.ForeignKey('requirement.Id'))
    ServiceDomainId = db.Column(db.BIGINT)
    FollowerId = db.Column(db.BIGINT)  # 方案Id

    def __init__(self, requirementId, serviceDomainId, followerId):
        self.RequirementId = requirementId
        self.ServiceDomainId = serviceDomainId
        self.FollowerId = followerId