增加数据库迁移命令和数据库初始化命令,分离schemas

This commit is contained in:
mkg
2021-06-12 23:05:30 +08:00
parent 5e08f3e49b
commit 14a32e6d3c
35 changed files with 198 additions and 174 deletions
+1 -20
View File
@@ -1,9 +1,7 @@
import datetime
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from applications.extensions import db, ma
from marshmallow import fields
from applications.models import Dept
from applications.extensions import db
class User(db.Model, UserMixin):
@@ -25,20 +23,3 @@ class User(db.Model, UserMixin):
def validate_password(self, password):
return check_password_hash(self.password_hash, password)
# 用户models的序列化类
class UserSchema(ma.Schema):
id = fields.Integer()
username = fields.Str()
realname = fields.Str()
enable = fields.Integer()
create_at = fields.DateTime()
update_at = fields.DateTime()
dept = fields.Method("get_dept")
def get_dept(self, obj):
if obj.dept_id != None:
return Dept.query.filter_by(id=obj.dept_id).first().dept_name
else:
return None