add test
This commit is contained in:
parent
4d122b554f
commit
f71db279ec
|
|
@ -18,6 +18,7 @@ from utils.jwt_token import create_token
|
||||||
from utils.response import success_200, error_211
|
from utils.response import success_200, error_211
|
||||||
from fastapi.security import OAuth2PasswordRequestForm
|
from fastapi.security import OAuth2PasswordRequestForm
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
router = APIRouter(prefix="/api", tags=["用户模块"])
|
router = APIRouter(prefix="/api", tags=["用户模块"])
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,5 +36,6 @@ async def login(user: OAuth2PasswordRequestForm = Depends(), db: Session = Depen
|
||||||
if user[0]:
|
if user[0]:
|
||||||
expire_time = timedelta(minutes=settings.ACCESS.ACCESS_TOKEN_EXPIRE_MINUTES)
|
expire_time = timedelta(minutes=settings.ACCESS.ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||||
token = create_token(AutomationResponse.model_to_dict(user[1]), expire_time)
|
token = create_token(AutomationResponse.model_to_dict(user[1]), expire_time)
|
||||||
return {"code": 200, "message": "登录成功", "access_token": token, "user": AutomationResponse.model_to_dict(user[1], "password"), "token_type": "Bearer"}
|
return {"code": 200, "message": "登录成功", "access_token": token,
|
||||||
|
"user": AutomationResponse.model_to_dict(user[1], "password"), "token_type": "Bearer"}
|
||||||
return error_211(message=user[1])
|
return error_211(message=user[1])
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ class User(DatabaseModel):
|
||||||
用户表
|
用户表
|
||||||
"""
|
"""
|
||||||
__tablename__ = "user"
|
__tablename__ = "user"
|
||||||
id = Column(INT, primary_key=True)
|
id = Column(INT, primary_key=True,comment='主键id')
|
||||||
username = Column(String(16), unique=True, index=True, comment="用户名")
|
username = Column(String(16), unique=True, index=True, comment="用户名")
|
||||||
password = Column(String(64), unique=False, comment="密码")
|
password = Column(String(256), comment="密码")
|
||||||
email = Column(String(64), unique=True, nullable=False, comment="邮箱")
|
email = Column(String(64), unique=True, nullable=False, comment="邮箱")
|
||||||
created_time = Column(DATETIME, comment='创建时间')
|
created_time = Column(DATETIME, comment='创建时间')
|
||||||
deleted_time = Column(DATETIME, comment="更新时间")
|
deleted_time = Column(DATETIME, comment="更新时间")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue