Example #1
0
class Complain(db.Model):
    __tablename__ = 'Complain'
    id = db.Column(db.Integer, primary_key=True)
    userid= db.Column(db.Integer,db.ForeignKey('User.id'), nullable=False)
    mob_no=db.Column(db.Integer,nullable=False)
    landmark=db.Column(db.String(200),nullable=False)
    pincode=db.Column(db.Integer,nullable=False)
    tycomp=db.Column(db.String(20),nullable=False) #type of complain
    Complaint=db.Column(db.String(200),nullable=False)
    photo=db.Column(db.String(20), nullable=False, default="default2.jpg")
    dateposted=db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
    


    def __init__(self,mob_no,landmark,pincode,Complaint,photo,dateposted,tycomp):
        
        self.mob_no=mob_no
        self.landmark=landmark
        self.pincode=pincode
        self.Complaint=Complaint
        self.photo=photo
        self.dateposted=dateposted
        self.tycomp=tycomp

    def __repr__(self):
        return f"Complain('{self.mob_no}','{self.landmark}','{self.pincode}','{self.Complaint}','{self.photo}','{self.dateposted}','{self.tycomp}'')"    
Example #2
0
class admin(db.Model):
    __tablename__ = 'admin'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20),unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default="default.jpg")

    def __init__ (self,username,image_file,password):
        self.name=username
        self.image_file=image_file
        self.password=password

    def __repr__(self):
        return f"admin('{self.name}','{self.image_file}','{self.password}')"
Example #3
0
class Project(db.Model, BaseModel):
    """项目模型"""
    __tablename__ = 'project'

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 工程id
    name = db.Column(db.String(20))  # 工程名
    address = db.Column(db.String(50))  # 工地所在地
    status = db.Column(db.Integer, default=0)  # 默认 0 存在 1 删除
    start_time = db.Column(db.DATETIME, default=datetime.now())

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'address': self.address,
            'start_time': self.start_time.strftime('%Y-%m-%d'),
        }
Example #4
0
class Facility(db.Model, BaseModel):
    """设备模型"""
    __tablename__ = 'facility'

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 借支id
    name = db.Column(db.String(20))  # 设备名称
    borrow_time = db.Column(db.DATETIME)  # 借出时间
    return_time = db.Column(db.DATETIME)  # 归还时间
    worker_id = db.Column(db.Integer, db.ForeignKey('worker.id'))
Example #5
0
class Income(db.Model, BaseModel):
    """入账模型"""
    __tablename__ = 'income'

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 借支id
    money = db.Column(db.Integer)  # 金额
    signature = db.Column(db.String(256))  # 经办人签字
    time = db.Column(db.DATETIME)  # 收款时间
    remark = db.Column(db.Text)  # 备注
Example #6
0
class Profession(db.Model, BaseModel):
    """工种"""
    __tablename__ = 'profession'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 工人id
    name = db.Column(db.String(20))
    worker = db.relationship('Worker', backref='profession', lazy=True)

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name
        }
Example #7
0
class Worker(db.Model, BaseModel):
    # 工人
    __tablename__ = 'worker'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 工人id
    name = db.Column(db.String(10), unique=True)  # 工人名字
    age = db.Column(db.Integer)  # 年龄
    sex = db.Column(db.Integer, default=1)  # 性别 默认 1 男
    phone = db.Column(db.String(11))  # 电话号码
    id_card = db.Column(db.String(18), unique=True)  # 身份证号
    card_img = db.Column(db.String(256))  # 身份证照片
    salary = db.Column(db.Integer)  # 薪资
    bank_card_no = db.Column(db.String(20))  # 银行卡号
    bank_card_name = db.Column(db.String(10))  # 持卡人姓名
    status = db.Column(db.Integer, default=0)  # 默认 0 存在 1 删除
    pro_id = db.Column(db.Integer, db.ForeignKey('profession.id'))  # 工种

    roster = db.relationship('Roster', backref='worker', lazy=True)  # 工天
    advances = db.relationship('Advances', backref='worker', lazy=True)  # 借支
    facility = db.relationship('Facility', backref='worker', lazy=True)  # 设备

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'sex': '男' if self.sex else '女',
            'age': self.age,
            'phone': self.phone,
            'id_card': self.id_card,
            'card_img': self.card_img,
            'salary': self.salary,
            'bank_card_no': self.bank_card_no,
            'bank_card_name': self.bank_card_name,
            'pro_id': self.pro_id
        }
Example #8
0
class User(db.Model):
    __tablename__ = 'User'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20),unique=True, nullable=False)
    email = db.Column(db.String(120),unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default="default.jpg")
    password = db.Column(db.String(60), nullable=False)
    address = db.Column(db.String(400), nullable=False, default="No Address")
    mobno = db.Column(db.Integer,unique=True,default="0000")
    Complain= db.relationship('Complain',backref='author',lazy=True)
    

    def __init__ (self,username,email,image_file,address,mobno,password):
        self.name=username
        self.email=email
        self.image_file=image_file
        self.address=address
        self.mobno=mobno
        self.password=password

    def __repr__(self):
        return f"User('{self.username}','{self.email}','{self.image_file}','{self.address}','{self.mobno}','{self.password}')"
Example #9
0
class Advances(db.Model, BaseModel):
    """借支模型"""
    __tablename__ = 'advances'

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)  # 借支id
    money = db.Column(db.Integer)  # 金额
    signature = db.Column(db.String(256))  # 经办人签字
    time = db.Column(db.DATETIME, default=datetime.now())  # 借款时间
    mode = db.Column(db.String(20))  # 借款方式 现金/微信转账等
    remark = db.Column(db.Text, default=None)  # 备注
    worker_id = db.Column(db.Integer, db.ForeignKey('worker.id'))

    def to_dict(self):
        return {
            'id': self.id,
            'money': self.money,
            'signature': self.signature,
            'time': self.time.strftime('%Y-%m-%d'),
            'mode': self.mode,
            'remark': self.remark,
            'worker_id': self.worker_id
        }
Example #10
0
class Solved(db.Model):
    __tablename__ = 'Solved'
    id = db.Column(db.Integer, primary_key=True)
    userid= db.Column(db.Integer,db.ForeignKey('User.id'), nullable=False)
    mob_no=db.Column(db.Integer,nullable=False)
    landmark=db.Column(db.String(200),nullable=False)
    pincode=db.Column(db.Integer,nullable=False)
    tycomp=db.Column(db.String(20),nullable=False) #type of complain
    Complaint=db.Column(db.String(200),nullable=False)
    datesaw=db.Column(db.DateTime,nullable=False,default=datetime.utcnow)



    def __init__(self,userid,mob_no,landmark,pincode,Complaint,datesaw,tycomp):
        self.userid=userid
        self.mob_no=mob_no
        self.landmark=landmark
        self.pincode=pincode
        self.Complaint=Complaint
        self.datesaw=datesaw
        self.tycomp=tycomp

    def __repr__(self):
        return f"Complain('{ self.userid}','{self.mob_no}','{self.landmark}','{self.pincode}','{self.Complaint}','{self.datesaw}','{self.tycomp}'')"