加入用户登录体系,session cookie 鉴权,默认账号 admin/admin123
This commit is contained in:
+11
-1
@@ -1,7 +1,7 @@
|
||||
"""Seed database from existing data files. Run once manually or on first start."""
|
||||
from datetime import date
|
||||
from app.database import engine, Base, SessionLocal
|
||||
from app.models import DailyBar, PositionSnapshot, Product, Contract
|
||||
from app.models import DailyBar, PositionSnapshot, Product, Contract, User
|
||||
from app.engine.lock_strategy import compute_amp_5d
|
||||
|
||||
# --- Seed OHLCV data ---
|
||||
@@ -202,6 +202,16 @@ def seed():
|
||||
db = SessionLocal()
|
||||
|
||||
try:
|
||||
# --- Seed default user ---
|
||||
if not db.query(User).first():
|
||||
admin = User(
|
||||
username="admin",
|
||||
password_hash=User.hash_password("admin123"),
|
||||
role="admin",
|
||||
)
|
||||
db.add(admin)
|
||||
db.flush()
|
||||
|
||||
# --- Seed products and contracts ---
|
||||
if not db.query(Product).first():
|
||||
fg = Product(code="FG", name="玻璃", exchange="CZCE")
|
||||
|
||||
Reference in New Issue
Block a user