class UserModel(BaseModel): __tablename__ = 'user_client' username = db.Column(db.String(32), unique=True) _password = db.Column(db.String(256)) phone = db.Column(db.String(32), unique=True) is_delete = db.Column(db.Boolean, default=False) permission = db.Column(db.Integer, default=COMMON_USER_CLIENT_PERMISSION) @property def password(self): return self._password @password.setter def password(self, passwd): self._password = generate_password_hash(password=passwd) def check_password(self, passwd=None): if passwd is None: passwd = '' if check_password_hash(self._password, passwd): return True return False def check_permission(self, permission): return permission & self.permission == permission
class CinemaUserModel(BaseModel): __tablename__ = 'cinema_user' username = db.Column(db.String(256), unique=True) _password = db.Column(db.String(256), nullable=False) is_delete = db.Column(db.Boolean, default=False) is_verify = db.Column(db.Boolean, default=False) @property def password(self): return self._password @password.setter def password(self, passwd): self._password = generate_password_hash(password=passwd) def check_password(self, passwd=None): if passwd is None: passwd = '' if check_password_hash(self._password, passwd): return True return False
class BaseModel(db.Model): __abstract__ = True id = db.Column(db.Integer, primary_key=True, autoincrement=True) def save(self): try: db.session.add(self) db.session.commit() return True except Exception as e: return False def delete(self): pass
class CityModel(BaseModel): __tablename__ = 'city' city_id = db.Column(db.Integer, unique=True) parent_id = db.Column(db.Integer, default=0) region_name = db.Column(db.String(256), nullable=True) city_code = db.Column(db.Integer, unique=True, default=0) pin_yin = db.Column(db.String(256), nullable=True) letter = db.Column(db.String(256), nullable=False)
class Permissions(BaseModel): __tablename__ = 'permissions' p_name = db.Column(db.String(256), unique=True)
class CinemaUserPermission(BaseModel): __tablename__ = 'cinema_user_permission' cinema_user_id = db.Column(db.Integer, db.ForeignKey('cinema_user.id')) cinema_permission_id = db.Column(db.Integer, db.ForeignKey('permissions.id'))
class MovieModel(BaseModel): __tablename__ = 'movies' ''' insert into movies(id, showname, shownameen, director, leadingRole, type, country, language, duration, screeningmodel, openday, backgroundpicture, flag, isdelete) values(228830,"梭哈人生","The Drifting Red Balloon","郑来志","谭佑铭,施予斐,赵韩樱子,孟智超,李林轩","剧情,爱情,喜剧","中国大陆","汉语普通话",90,"4D" ,date("2018-01-30 00:00:00"),"i1/TB19_XCoLDH8KJjy1XcXXcpdXXa_.jpg",1,0); ''' show_name = db.Column(db.String(256), name='showname', ) show_name_en = db.Column(db.String(256), name='shownameen') director = db.Column(db.String(256)) leading_role = db.Column(db.String(256), name='leadingRole') type = db.Column(db.String(256)) country = db.Column(db.String(256)) language = db.Column(db.String(256)) duration = db.Column(db.Integer) screening_model = db.Column(db.String(256), name='screeningmodel') open_day = db.Column(db.Date, name='openday') background_picture = db.Column(db.String(256), name='backgroundpicture') flag = db.Column(db.Integer, default=1) is_delete = db.Column(db.Boolean, default=0, name='isdelete')
class CinemaModel(BaseModel): ''' insert into cinemas(name,city,district,address,phone,score,hallnum,servicecharge,astrict,flag,isdelete) values("深圳戏院影城","深圳","罗湖","罗湖区新园路1号东门步行街西口","0755-82175808",9.7,9,1.2,20,1,0); ''' __tablename__ = 'cinemas' name = db.Column(db.String(256), name='name') city = db.Column(db.String(256), name='city') district = db.Column(db.String(256), name='district') address = db.Column(db.String(256), name='address') phone = db.Column(db.String(256), name='phone') score = db.Column(db.Integer, name='score') hall_num = db.Column(db.Integer, name='hallnum') service_charge = db.Column(db.Integer, name='servicecharge') astrict = db.Column(db.Integer, name='astrict') flag = db.Column(db.Integer, name='flag') is_delete = db.Column(db.Boolean, name='isdelete') cinema_user_id = db.Column(db.Integer, db.ForeignKey(CinemaUserModel.id), default=1)