同步更新:重构路由、服务模块,更新前端构建
This commit is contained in:
26
services/accounts_service.py
Normal file
26
services/accounts_service.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import database
|
||||
from services.models import Account
|
||||
from services.state import safe_set_user_accounts
|
||||
|
||||
|
||||
def load_user_accounts(user_id: int) -> None:
|
||||
"""从数据库加载用户的账号到内存(保持原逻辑不变)。"""
|
||||
accounts_by_id = {}
|
||||
accounts_data = database.get_user_accounts(user_id)
|
||||
for acc_data in accounts_data:
|
||||
account = Account(
|
||||
account_id=acc_data["id"],
|
||||
user_id=user_id,
|
||||
username=acc_data["username"],
|
||||
password=acc_data["password"],
|
||||
remember=bool(acc_data["remember"]),
|
||||
remark=acc_data["remark"] or "",
|
||||
)
|
||||
accounts_by_id[account.id] = account
|
||||
|
||||
safe_set_user_accounts(user_id, accounts_by_id)
|
||||
|
||||
Reference in New Issue
Block a user