refactor(backend): 统一返回的数据格式
This commit is contained in:
+6
-10
@@ -10,7 +10,7 @@ from ._base import BaseORM
|
||||
class UserORM(BaseORM):
|
||||
__tablename__ = "ums_user"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, comment="自增id")
|
||||
id = db.Column(db.Integer, primary_key=True, comment="自增 id")
|
||||
nickname = db.Column(db.String(128), nullable=False, comment="昵称")
|
||||
username = db.Column(db.String(128), nullable=False, comment="登录名")
|
||||
password_hash = db.Column(db.String(102), nullable=False, comment="登录密码")
|
||||
@@ -24,7 +24,7 @@ class UserORM(BaseORM):
|
||||
default=datetime.now,
|
||||
)
|
||||
department_id = db.Column(
|
||||
db.Integer, db.ForeignKey("ums_department.id"), default=1, comment="部门id"
|
||||
db.Integer, db.ForeignKey("ums_department.id"), default=1, comment="部门 id"
|
||||
)
|
||||
|
||||
role_list = db.relationship(
|
||||
@@ -35,14 +35,10 @@ class UserORM(BaseORM):
|
||||
)
|
||||
|
||||
def json(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"username": self.username,
|
||||
"nickname": self.nickname,
|
||||
"mobile": self.mobile,
|
||||
"email": self.email,
|
||||
"create_at": self.create_at.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
}
|
||||
create_at = (self.create_at.strftime("%Y-%m-%d %H:%M:%S"),)
|
||||
data = super().json()
|
||||
data["create_at"] = create_at
|
||||
return data
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
|
||||
Reference in New Issue
Block a user