class Member(db.Model): id = db.Column(db.Integer, primary_key=True) member_id = db.Column(db.Integer) date_year = db.Column(db.Integer, index=True) #会籍年份 date_half_year = db.Column(db.String(6), index=True) #上下半年 name = db.Column(db.String(64), index=True) #姓名 ID_num = db.Column(db.String(20)) #身份证号 salary = db.Column(db.Float) #月基本工资 membership_fee = db.Column(db.Float) #会费 personnel_type = db.Column(db.String(10), index=True) #职工类型 def __repr__(self): return "id={},date_year={},date_half_year={}, name={},ID_num={}, salary={}, menbership_fee={},personnel_type={}".format( self.id, self.date_year, self.date_half_year, self.name, self.ID_num, self.salary, self.membership_fee, self.personnel_type)
class Condolence(db.Model): id = db.Column(db.Integer,primary_key=True) c_date = db.Column(db.Date) c_year = db.Column(db.Integer) c_quarter = db.Column(db.Integer) c_name = db.Column(db.String(10)) c_type = db.Column(db.String(10)) c_count = db.Column(db.Float(20,2)) remark = db.Column(db.String(50)) in_account = db.Column(db.String(5)) def __repr__(self): return "id={}, c_date={}, c_name={}, c_type={},c_count={},remark={},in_account={}".format( self.id,self.c_date,self.c_name,self.c_type,self.c_count,self.remark,self.in_account )
class Account(db.Model): id = db.Column(db.Integer, primary_key=True) a_date = db.Column(db.Date, index=True) matters = db.Column(db.String(50)) a_type = db.Column(db.String(60), index=True) a_count = db.Column(db.Float) in_out = db.Column(db.String(2), index=True) remark = db.Column(db.String(50)) create_time = db.Column(db.DateTime, default=datetime.utcnow) def __repr__(self): return "id={}, a_date={}, matters={}, a_type={},a_count={},in_out={},remark={},create_time={}".format( self.id, self.a_date, self.matters, self.a_type, self.a_count, self.in_out, self.remark, self.create_time)
class User(UserMixin,db.Model): id = db.Column(db.Integer,primary_key=True) username = db.Column(db.String(64),unique=True,index=True) email = db.Column(db.String(64),unique=True,index=True) password_hash = db.Column(db.String(128)) def __repr__(self): return 'id={},username={},email={},password_hash={}'.format( self.id,self.username,self.email,self.password_hash ) def set_password(self,password): self.password_hash = generate_password_hash(password) def check_password(self,password): return check_password_hash(self.password_hash,password) def get_jwt(self,expire=7200): #生成token expire为超时时间 return jwt.encode( { 'email':self.email, #当前用户email地址 'exp':time.time() + expire #超时时间 }, current_app.config['SECRET_KEY'], #加密方法 algorithm='HS256' ).decode('utf-8') @staticmethod #静态方法 def verify_jwt(token): #验证 try: email = jwt.decode( token, current_app.config['SECRET_KEY'], algorithms=['HS256'] ) email = email['email'] except: return return User.query.filter_by(email=email).first()
class Member_info(db.Model): id = db.Column(db.Integer, primary_key=True) ID_num = db.Column(db.String(20), unique=True) #身份证号 date_birth = db.Column(db.Date) #出生日期 gender = db.Column(db.String(2)) #性别 nation = db.Column(db.String(20)) #民族 political_status = db.Column(db.String(20)) #政治面貌 native_place = db.Column(db.String(60)) #籍贯 education = db.Column(db.String(20)) #学历 phone = db.Column(db.String(20)) #联系电话 email = db.Column(db.String(64)) #电子邮箱 remark = db.Column(db.String(60)) #备注 def __repr__(self): return "id={}, ID_num={}, date_birth={},gender={}, nation={},political_status={},native_place={},education={},phone={},email={},remark={}".format( self.id, self.ID_num, self.date_birth, self.gender, self.nation, self.political_status, self.native_place, self.education, self.phone, self.email, self.remark) def check_IDnum_exist(self): if Member_info.query.filter_by(ID_num=self).first(): return True else: return False