现在已经可以部署了,就是前端还有点丑。
简要描述:
pip install -i https://pypi.douban.com/simple
jobpuls --jobplus |---__init__.py |---app.py |---config.py |---forms.py |---models.py |---decorator.py |---handlers ||---front.py ||---admin.py |---static ||---js ||---css |---templates --manage.py
下载flask-migarte
pip install flask-migarte
models设计完成之后运行
export FLASK_APP=manage.py
export FLASK_DEBUG=1
flask db init
flask migarte -m "init database"
flask upgrade
更新models.py
class Base(db.Model):
__abstract__ = True
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
deleted = db.Column(db.Integer, default=0) # 逻辑删除:0表示显示,1表示删除
user_job = db.Table(
'user_job',
db.Column('user_id', db.Integer, db.ForeignKey('user.id', ondelete='CASCADE')),
db.Column('job_id', db.Integer, db.ForeignKey('jobs.id', ondelete='CASCADE'))
)
class User(Base, UserMixin):
"""
用户表
"""
__tablename__ = 'user'
ROLE_USER = 10
ROLE_STAFF = 20
ROLE_ADMIN = 30
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(40), unique=True)
email = db.Column(db.String(40), unique=True)
phone = db.Column(db.Integer)
_password = db.Column('password', db.String(256), nullable=False)
role = db.Column(db.SmallInteger, default=ROLE_USER)
def __repr__(self):
return '<Admin:{}>'.format(self.username)
@property
def password(self):
return self._password
@password.setter
def password(self, orig_password):
self._password = generate_password_hash(orig_password)
def check_password(self, password):
return check_password_hash(self._password, password)
@property
def is_admin(self):
return self.role == self.ROLE_ADMIN
@property
def is_staf(self):
return self.role == self.ROLE_STAFF
class Resume(Base):
"""
用户简历表
"""
__tabalename__ = 'resume'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
user = db.relationship('User', uselist=False)
job_experiences = db.relationship('JobExperience')
edu_experiences = db.relationship('EduExperience')
project_experiences = db.relationship('ProjectExperice')
def profile(self):
pass
class Experience(Base):
__abstract__ = True
id = db.Column(db.Integer, primary_key=True)
begin_at = db.Column(db.DateTime)
end_at = db.Column(db.DateTime)
# 在职期间,做了什么,解决了什么问题,做出了什么贡献
# 在校期间做过什么,取得过什么荣誉
# 项目期间,做了什么,解决了什么问题,做出了什么贡献
description = db.Column(db.String(1024))
class JobExperience(Experience):
__tablename__ = 'job_experience'
company = db.Column(db.String(32), nullable=False)
city = db.Column(db.String(32), nullable=False)
resume_id = db.Column(db.Integer, db.ForeignKey('resume.id'))
resume = db.relationship('Resume', uselist=False)
class ProjectExperice(Experience):
__tablename__ = 'project_experience'
name = db.Column(db.String(32), nullable=False)
# 在项目中扮演的角色
role = db.Column(db.String(32))
# 多个技术用逗号隔开
technologys = db.Column(db.String(64))
resume_id = db.Column(db.Integer, db.ForeignKey('resume.id'))
resume = db.relationship('Resume', uselist=False)
class EduExperience(Experience):
__tablename__ = 'edu_experience'
school = db.Column(db.String(32), nullable=False)
# 所学专业
specialty = db.Column(db.String(32), nullable=False)
degree = db.Column(db.String(16))
resume_id = db.Column(db.Integer, db.ForeignKey('resume.id'))
resume = db.relationship('Resume', uselist=False)
class Jobs(Base):
__tablename__ = 'jobs'
id = db.Column(db.Integer, primary_key=True)
# 职位名称
name = db.Column(db.String(24))
salary_low = db.Column(db.Integer, nullable=False)
salary_high = db.Column(db.Integer, nullable=False)
location = db.Column(db.String(24))
# 职位标签,多个标签用逗号隔开,最多10个
tags = db.Column(db.String(128))
experience_requirement = db.Column(db.String(32))
degree_requirement = db.Column(db.String(32))
is_fulltime = db.Column(db.Boolean, default=True)
# 是否在招聘
is_open = db.Column(db.Boolean, default=True)
company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete='CASCADE'))
company = db.relationship('Company', uselist=False)
views_count = db.Column(db.Integer, default=0)
def __repr__(self):
return '<Job {}>'.format(self.name)
class Company(Base):
__tablename__ = 'company'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), nullable=False, index=True, unique=True)
slug = db.Column(db.String(24), nullable=False, index=True, unique=True)
logo = db.Column(db.String(64), nullable=False)
site = db.Column(db.String(64), nullable=False)
contact = db.Column(db.String(24), nullable=False)
email = db.Column(db.String(24), nullable=False)
location = db.Column(db.String(24), nullable=False)
# 一句话描述
description = db.Column(db.String(100))
# 关于我们,公司详情描述
about = db.Column(db.String(1024))
# 公司标签,多个标签用逗号隔开,最多10个
tags = db.Column(db.String(128))
# 公司技术栈,多个技术用逗号隔开,最多10个
stack = db.Column(db.String(128))
# 团队介绍
team_introduction = db.Column(db.String(256))
# 公司福利,多个福利用分号隔开,最多 10 个
welfares = db.Column(db.String(256))
user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'))
user = db.relationship('User', uselist=False, backref=db.backref('company', uselist=False))
class Dilivery(Base):
__tablename__ = 'delivery'
# 等待企业审核
STATUS_WAITING = 1
# 被拒绝
STATUS_REJECT = 2
# 被接收,等待通知面试
STATUS_ACCEPT = 3
id = db.Column(db.Integer, primary_key=True)
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id', ondelete='SET NULL'))
user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'))
status = db.Column(db.SmallInteger, default=STATUS_WAITING)
# 企业回应
response = db.Column(db.String(256))
后面再改表的显示吧
用户表
这 | 里 | 是 | 字 | 段 |
---|---|---|---|---|
1 | 2 | 3 | 4 | 5 |
Tags: None