feat:重新初始化

This commit is contained in:
2025-09-23 15:13:29 +08:00
parent de43a551bc
commit 842da15886
31 changed files with 2500 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from sqlalchemy.orm import Session
from schemas.session import SessionResponse
from config.auth import create_token, create_payload
from middleware.exceptions import AppException
def create(db: Session, username: str, password: str) -> SessionResponse:
# 1. 校验账户是否存在
if username != "admin":
raise AppException(f"该账户{username}不存在")
# 2. 校验密码是否正确
if password != "19940822Cxx":
raise AppException("密码错误")
return SessionResponse(
access_token=create_token(create_payload(username)),
token_type="Bearer"
)