首次提交

This commit is contained in:
sansenhoshi
2026-01-08 10:25:45 +08:00
commit 5c30dd725f
13 changed files with 190 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
from repositories.user_repo import UserRepository
from common.exceptions import BusinessException
from flask_jwt_extended import create_access_token
class AuthService:
@staticmethod
def login(username: str, password: str):
user = UserRepository.find_by_username(username)
if not user:
raise BusinessException(40101, "User not found")
if user.password != password:
raise BusinessException(40102, "Invalid credentials")
token = create_access_token(identity=user.id)
return {
"token": token,
"user": user.to_dict()
}
+8
View File
@@ -0,0 +1,8 @@
from repositories.user_repo import UserRepository
class UserService:
@staticmethod
def list_users():
users = UserRepository.find_all()
return [u.to_dict() for u in users]