优化用户部门查询逻辑
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .admin_user import UserOutSchema
|
||||
|
||||
from .admin_role import RoleOutSchema
|
||||
from .admin_power import PowerOutSchema, PowerOutSchema2
|
||||
from .admin_dict import DictDataOutSchema, DictTypeOutSchema
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
from applications.extensions import ma
|
||||
from marshmallow import fields
|
||||
from applications.models import Dept
|
||||
|
||||
|
||||
# 用户models的序列化类
|
||||
class UserOutSchema(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
|
||||
Reference in New Issue
Block a user