hanbinsite commited on
Commit
32ddb29
·
0 Parent(s):

chore: initialize FastAPI project scaffold

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .env.example +11 -0
  2. .gitignore +17 -0
  3. README.md +39 -0
  4. alembic.ini +36 -0
  5. alembic/env.py +54 -0
  6. alembic/script.py.mako +25 -0
  7. app/__init__.py +0 -0
  8. app/config.py +15 -0
  9. app/database.py +23 -0
  10. app/dependencies.py +96 -0
  11. app/main.py +36 -0
  12. app/models/__init__.py +30 -0
  13. app/models/admin.py +20 -0
  14. app/models/category.py +27 -0
  15. app/models/favorite.py +15 -0
  16. app/models/permission.py +31 -0
  17. app/models/play_history.py +21 -0
  18. app/models/role.py +27 -0
  19. app/models/source_health.py +18 -0
  20. app/models/source_site.py +29 -0
  21. app/models/sync_log.py +22 -0
  22. app/models/user.py +22 -0
  23. app/models/vod.py +34 -0
  24. app/models/vod_source.py +22 -0
  25. app/routers/__init__.py +22 -0
  26. app/routers/admin/__init__.py +0 -0
  27. app/routers/admin/admin_mgmt.py +33 -0
  28. app/routers/admin/auth.py +33 -0
  29. app/routers/admin/category.py +18 -0
  30. app/routers/admin/role_mgmt.py +28 -0
  31. app/routers/admin/source.py +43 -0
  32. app/routers/admin/sync.py +13 -0
  33. app/routers/admin/system.py +13 -0
  34. app/routers/admin/user_mgmt.py +23 -0
  35. app/routers/admin/vod.py +33 -0
  36. app/routers/user/__init__.py +14 -0
  37. app/routers/user/auth.py +18 -0
  38. app/routers/user/category.py +8 -0
  39. app/routers/user/favorite.py +18 -0
  40. app/routers/user/history.py +18 -0
  41. app/routers/user/vod.py +28 -0
  42. app/schemas/__init__.py +0 -0
  43. app/schemas/admin/__init__.py +0 -0
  44. app/schemas/admin/admin_mgmt.py +0 -0
  45. app/schemas/admin/auth.py +0 -0
  46. app/schemas/admin/category.py +0 -0
  47. app/schemas/admin/role_mgmt.py +0 -0
  48. app/schemas/admin/source.py +0 -0
  49. app/schemas/admin/sync.py +0 -0
  50. app/schemas/admin/system.py +0 -0
.env.example ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 环境
2
+ DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/binv
3
+ SECRET_KEY=change-me-to-a-random-secret-key
4
+ ACCESS_TOKEN_EXPIRE_MINUTES=1440
5
+
6
+ # CORS
7
+ CORS_ORIGINS=http://localhost:3000,http://localhost:5555
8
+
9
+ # 同步
10
+ SYNC_CRON_HOUR=1
11
+ SYNC_MAX_CONCURRENT=3
.gitignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ .venv/
5
+ venv/
6
+ .env
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .eggs/
11
+ *.egg
12
+ alembic/versions/__pycache__/
13
+ .pytest_cache/
14
+ .mypy_cache/
15
+ .idea/
16
+ .vscode/
17
+ *.sqlite3
README.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BinV API
2
+
3
+ 影视资源聚合 API 服务
4
+
5
+ ## 快速开始
6
+
7
+ ```bash
8
+ # 创建虚拟环境
9
+ python -m venv .venv
10
+ # Windows
11
+ .venv\Scripts\activate
12
+ # Linux/Mac
13
+ source .venv/bin/activate
14
+
15
+ # 安装依赖
16
+ pip install -r requirements.txt
17
+
18
+ # 复制环境变量
19
+ cp .env.example .env
20
+
21
+ # 初始化数据库
22
+ alembic upgrade head
23
+
24
+ # 创建超级管理员
25
+ python scripts/create_superadmin.py
26
+
27
+ # 初始化权限和角色
28
+ python scripts/seed_permissions.py
29
+ python scripts/seed_roles.py
30
+
31
+ # 启动开发服务
32
+ uvicorn app.main:app --reload --port 9999
33
+ ```
34
+
35
+ ## API 文档
36
+
37
+ 启动后访问:
38
+ - Swagger UI: http://localhost:9999/docs
39
+ - ReDoc: http://localhost:9999/redoc
alembic.ini ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [alembic]
2
+ script_location = alembic
3
+ sqlalchemy.url = postgresql+asyncpg://postgres:password@localhost:5432/binv
4
+
5
+ [loggers]
6
+ keys = root,sqlalchemy,alembic
7
+
8
+ [handlers]
9
+ keys = console
10
+
11
+ [formatters]
12
+ keys = generic
13
+
14
+ [logger_root]
15
+ level = WARN
16
+ handlers = console
17
+
18
+ [logger_sqlalchemy]
19
+ level = WARN
20
+ handlers =
21
+ qualname = sqlalchemy.engine
22
+
23
+ [logger_alembic]
24
+ level = INFO
25
+ handlers =
26
+ qualname = alembic
27
+
28
+ [handler_console]
29
+ class = StreamHandler
30
+ args = (sys.stderr,)
31
+ level = NOTSET
32
+ formatter = generic
33
+
34
+ [formatter_generic]
35
+ format = %(levelname)-5.5s [%(name)s] %(message)s
36
+ datefmt = %H:%M:%S
alembic/env.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ from logging.config import fileConfig
3
+
4
+ from alembic import context
5
+ from sqlalchemy import pool
6
+ from sqlalchemy.ext.asyncio import async_engine_from_config
7
+
8
+ from app.database import Base
9
+ from app.models import * # noqa: F401,F403
10
+
11
+ config = context.config
12
+ if config.config_file_name is not None:
13
+ fileConfig(config.config_file_name)
14
+
15
+ target_metadata = Base.metadata
16
+
17
+
18
+ def run_migrations_offline() -> None:
19
+ url = config.get_main_option("sqlalchemy.url")
20
+ context.configure(
21
+ url=url,
22
+ target_metadata=target_metadata,
23
+ literal_binds=True,
24
+ dialect_opts={"paramstyle": "named"},
25
+ )
26
+ with context.begin_transaction():
27
+ context.run_migrations()
28
+
29
+
30
+ def do_run_migrations(connection):
31
+ context.configure(connection=connection, target_metadata=target_metadata)
32
+ with context.begin_transaction():
33
+ context.run_migrations()
34
+
35
+
36
+ async def run_async_migrations() -> None:
37
+ connectable = async_engine_from_config(
38
+ config.get_section(config.config_ini_section, {}),
39
+ prefix="sqlalchemy.",
40
+ poolclass=pool.NullPool,
41
+ )
42
+ async with connectable.connect() as connection:
43
+ await connection.run_sync(do_run_migrations)
44
+ await connectable.dispose()
45
+
46
+
47
+ def run_migrations_online() -> None:
48
+ asyncio.run(run_async_migrations())
49
+
50
+
51
+ if context.is_offline_mode():
52
+ run_migrations_offline()
53
+ else:
54
+ run_migrations_online()
alembic/script.py.mako ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """${message}
2
+
3
+ Revision ID: ${up_revision}
4
+ Revises: ${down_revision | comma,n}
5
+ Create Date: ${create_date}
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ ${imports if imports else ""}
13
+
14
+ revision: str = ${repr(up_revision)}
15
+ down_revision: Union[str, None] = ${repr(down_revision)}
16
+ branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
17
+ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
18
+
19
+
20
+ def upgrade() -> None:
21
+ ${upgrades if upgrades else "pass"}
22
+
23
+
24
+ def downgrade() -> None:
25
+ ${downgrades if downgrades else "pass"}
app/__init__.py ADDED
File without changes
app/config.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic_settings import BaseSettings
2
+
3
+
4
+ class Settings(BaseSettings):
5
+ DATABASE_URL: str = "postgresql+asyncpg://postgres:password@localhost:5432/binv"
6
+ SECRET_KEY: str = "change-me-to-a-random-secret-key"
7
+ ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440
8
+ CORS_ORIGINS: str = "http://localhost:3000,http://localhost:5555"
9
+ SYNC_CRON_HOUR: int = 1
10
+ SYNC_MAX_CONCURRENT: int = 3
11
+
12
+ model_config = {"env_file": ".env", "extra": "ignore"}
13
+
14
+
15
+ settings = Settings()
app/database.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import AsyncGenerator
2
+
3
+ from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
4
+ from sqlalchemy.orm import DeclarativeBase
5
+
6
+ from app.config import settings
7
+
8
+ engine = create_async_engine(settings.DATABASE_URL, echo=False)
9
+ async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
10
+
11
+
12
+ class Base(DeclarativeBase):
13
+ pass
14
+
15
+
16
+ async def get_db() -> AsyncGenerator[AsyncSession, None]:
17
+ async with async_session() as session:
18
+ try:
19
+ yield session
20
+ await session.commit()
21
+ except Exception:
22
+ await session.rollback()
23
+ raise
app/dependencies.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import AsyncGenerator
2
+
3
+ from fastapi import Depends, HTTPException, status
4
+ from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
5
+ from jose import JWTError, jwt
6
+ from sqlalchemy import select
7
+ from sqlalchemy.ext.asyncio import AsyncSession
8
+
9
+ from app.config import settings
10
+ from app.database import get_db
11
+ from app.models.admin import Admin
12
+ from app.models.role import Role, AdminRole
13
+ from app.models.permission import Permission, RolePermission
14
+ from app.models.user import User
15
+
16
+ security = HTTPBearer()
17
+
18
+
19
+ async def get_current_admin(
20
+ credentials: HTTPAuthorizationCredentials = Depends(security),
21
+ db: AsyncSession = Depends(get_db),
22
+ ) -> Admin:
23
+ token = credentials.credentials
24
+ try:
25
+ payload = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
26
+ admin_id: int | None = payload.get("sub")
27
+ if admin_id is None:
28
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
29
+ except JWTError:
30
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
31
+
32
+ result = await db.execute(select(Admin).where(Admin.id == int(admin_id)))
33
+ admin = result.scalar_one_or_none()
34
+ if admin is None or not admin.is_active:
35
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Admin not found")
36
+ return admin
37
+
38
+
39
+ async def get_current_user(
40
+ credentials: HTTPAuthorizationCredentials = Depends(security),
41
+ db: AsyncSession = Depends(get_db),
42
+ ) -> User:
43
+ token = credentials.credentials
44
+ try:
45
+ payload = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
46
+ user_id: int | None = payload.get("sub")
47
+ user_type: str | None = payload.get("type")
48
+ if user_id is None or user_type != "user":
49
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
50
+ except JWTError:
51
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
52
+
53
+ result = await db.execute(select(User).where(User.id == int(user_id)))
54
+ user = result.scalar_one_or_none()
55
+ if user is None or not user.is_active:
56
+ raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found")
57
+ return user
58
+
59
+
60
+ async def get_admin_roles(admin: Admin, db: AsyncSession = Depends(get_db)) -> list[str]:
61
+ result = await db.execute(
62
+ select(Role.code)
63
+ .join(AdminRole, AdminRole.role_id == Role.id)
64
+ .where(AdminRole.admin_id == admin.id, Role.status == 1)
65
+ )
66
+ return [r[0] for r in result.all()]
67
+
68
+
69
+ async def get_admin_permissions(admin: Admin, db: AsyncSession = Depends(get_db)) -> list[str]:
70
+ result = await db.execute(
71
+ select(Permission.code)
72
+ .join(RolePermission, RolePermission.permission_id == Permission.id)
73
+ .join(AdminRole, AdminRole.role_id == RolePermission.role_id)
74
+ .where(AdminRole.admin_id == admin.id, Permission.status == 1)
75
+ .distinct()
76
+ )
77
+ return [p[0] for p in result.all()]
78
+
79
+
80
+ def require_permission(permission_code: str):
81
+ async def permission_checker(
82
+ admin: Admin = Depends(get_current_admin),
83
+ db: AsyncSession = Depends(get_db),
84
+ ) -> Admin:
85
+ roles = await get_admin_roles(admin, db)
86
+ if "super_admin" in roles:
87
+ return admin
88
+ permissions = await get_admin_permissions(admin, db)
89
+ if permission_code not in permissions:
90
+ raise HTTPException(
91
+ status_code=status.HTTP_403_FORBIDDEN,
92
+ detail=f"Permission denied: {permission_code}",
93
+ )
94
+ return admin
95
+
96
+ return permission_checker
app/main.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from contextlib import asynccontextmanager
2
+
3
+ from fastapi import FastAPI
4
+ from fastapi.middleware.cors import CORSMiddleware
5
+
6
+ from app.config import settings
7
+ from app.routers import admin_router, user_router
8
+
9
+
10
+ @asynccontextmanager
11
+ async def lifespan(app: FastAPI):
12
+ yield
13
+
14
+
15
+ app = FastAPI(
16
+ title="BinV API",
17
+ description="影视资源聚合API服务",
18
+ version="0.1.0",
19
+ lifespan=lifespan,
20
+ )
21
+
22
+ app.add_middleware(
23
+ CORSMiddleware,
24
+ allow_origins=[o.strip() for o in settings.CORS_ORIGINS.split(",")],
25
+ allow_credentials=True,
26
+ allow_methods=["*"],
27
+ allow_headers=["*"],
28
+ )
29
+
30
+ app.include_router(admin_router, prefix="/admin")
31
+ app.include_router(user_router, prefix="/user")
32
+
33
+
34
+ @app.get("/health")
35
+ async def health_check():
36
+ return {"status": "ok"}
app/models/__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from app.models.source_site import SourceSite
2
+ from app.models.vod import Vod
3
+ from app.models.vod_source import VodSource
4
+ from app.models.category import Category, CategoryMapping
5
+ from app.models.admin import Admin
6
+ from app.models.role import Role, AdminRole
7
+ from app.models.permission import Permission, RolePermission
8
+ from app.models.user import User
9
+ from app.models.favorite import Favorite
10
+ from app.models.play_history import PlayHistory
11
+ from app.models.sync_log import SyncLog
12
+ from app.models.source_health import SourceHealth
13
+
14
+ __all__ = [
15
+ "SourceSite",
16
+ "Vod",
17
+ "VodSource",
18
+ "Category",
19
+ "CategoryMapping",
20
+ "Admin",
21
+ "Role",
22
+ "AdminRole",
23
+ "Permission",
24
+ "RolePermission",
25
+ "User",
26
+ "Favorite",
27
+ "PlayHistory",
28
+ "SyncLog",
29
+ "SourceHealth",
30
+ ]
app/models/admin.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Admin(Base):
10
+ __tablename__ = "admin"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ username: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="用户名")
14
+ password_hash: Mapped[str] = mapped_column(String(128), nullable=False, comment="bcrypt哈希")
15
+ nickname: Mapped[str | None] = mapped_column(String(30), comment="昵称")
16
+ avatar: Mapped[str | None] = mapped_column(String(500), comment="头像URL")
17
+ is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")
18
+ last_login_at: Mapped[datetime | None] = mapped_column(DateTime, comment="最后登录时间")
19
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
20
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/models/category.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Category(Base):
10
+ __tablename__ = "category"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ name: Mapped[str] = mapped_column(String(30), nullable=False, comment="分类名称")
14
+ parent_id: Mapped[int | None] = mapped_column(Integer, comment="父分类ID")
15
+ sort_order: Mapped[int] = mapped_column(Integer, default=0, comment="排序")
16
+ is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")
17
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
18
+
19
+
20
+ class CategoryMapping(Base):
21
+ __tablename__ = "category_mapping"
22
+
23
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
24
+ category_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="统一分类ID")
25
+ source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
26
+ source_type_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="源站分类ID")
27
+ source_type_name: Mapped[str] = mapped_column(String(30), nullable=False, comment="源站分类名称")
app/models/favorite.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import DateTime, Integer, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Favorite(Base):
10
+ __tablename__ = "favorite"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ user_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="用户ID")
14
+ vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="影片ID")
15
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
app/models/permission.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Permission(Base):
10
+ __tablename__ = "permission"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ code: Mapped[str] = mapped_column(String(60), unique=True, nullable=False, comment="权限码")
14
+ name: Mapped[str] = mapped_column(String(50), nullable=False, comment="权限名称")
15
+ type: Mapped[str] = mapped_column(String(10), nullable=False, comment="menu/page/btn")
16
+ parent_id: Mapped[int | None] = mapped_column(Integer, comment="父权限ID")
17
+ path: Mapped[str | None] = mapped_column(String(200), comment="路由路径(仅menu)")
18
+ component: Mapped[str | None] = mapped_column(String(200), comment="前端组件路径(仅menu)")
19
+ redirect: Mapped[str | None] = mapped_column(String(200), comment="重定向路径(仅menu)")
20
+ icon: Mapped[str | None] = mapped_column(String(50), comment="菜单图标(仅menu)")
21
+ sort_order: Mapped[int] = mapped_column(Integer, default=0, comment="排序")
22
+ status: Mapped[int] = mapped_column(Integer, default=1, comment="1=启用 0=禁用")
23
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
24
+
25
+
26
+ class RolePermission(Base):
27
+ __tablename__ = "role_permission"
28
+
29
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
30
+ role_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="角色ID")
31
+ permission_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="权限ID")
app/models/play_history.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class PlayHistory(Base):
10
+ __tablename__ = "play_history"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ user_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="用户ID")
14
+ vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="影片ID")
15
+ source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
16
+ episode: Mapped[str | None] = mapped_column(String(50), comment="集名")
17
+ play_url: Mapped[str] = mapped_column(String, nullable=False, comment="播放地址")
18
+ progress: Mapped[int] = mapped_column(Integer, default=0, comment="播放进度(秒)")
19
+ duration: Mapped[int] = mapped_column(Integer, default=0, comment="总时长(秒)")
20
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
21
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/models/role.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Role(Base):
10
+ __tablename__ = "role"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ name: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="角色名称")
14
+ code: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="角色编码")
15
+ description: Mapped[str | None] = mapped_column(String(200), comment="角色描述")
16
+ is_builtin: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否内置角色")
17
+ status: Mapped[int] = mapped_column(Integer, default=1, comment="1=启用 0=禁用")
18
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
19
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
20
+
21
+
22
+ class AdminRole(Base):
23
+ __tablename__ = "admin_role"
24
+
25
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
26
+ admin_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="管理员ID")
27
+ role_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="角色ID")
app/models/source_health.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class SourceHealth(Base):
10
+ __tablename__ = "source_health"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
14
+ check_type: Mapped[str] = mapped_column(String(20), nullable=False, comment="api/play")
15
+ is_success: Mapped[bool] = mapped_column(Boolean, nullable=False, comment="是否成功")
16
+ response_time_ms: Mapped[int | None] = mapped_column(Integer, comment="响应时间(ms)")
17
+ error_message: Mapped[str | None] = mapped_column(String, comment="错误信息")
18
+ checked_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
app/models/source_site.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, Text, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class SourceSite(Base):
10
+ __tablename__ = "source_site"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ name: Mapped[str] = mapped_column(String(50), nullable=False, comment="站点名称")
14
+ code: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="站点编码")
15
+ base_url: Mapped[str] = mapped_column(String(500), nullable=False, comment="API基础地址")
16
+ site_url: Mapped[str | None] = mapped_column(String(500), comment="官网地址")
17
+ play_from_m3u8: Mapped[str | None] = mapped_column(String(30), comment="M3U8来源标识")
18
+ play_from_yun: Mapped[str | None] = mapped_column(String(30), comment="云播来源标识")
19
+ parse_url: Mapped[str | None] = mapped_column(String(500), comment="M3U8解析接口")
20
+ is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")
21
+ sync_interval: Mapped[int] = mapped_column(Integer, default=60, comment="同步间隔(分钟)")
22
+ last_sync_at: Mapped[datetime | None] = mapped_column(DateTime, comment="最后同步时间")
23
+ last_sync_status: Mapped[str | None] = mapped_column(String(20), comment="最后同步状态")
24
+ last_sync_count: Mapped[int] = mapped_column(Integer, default=0, comment="最后同步新增数量")
25
+ total_count: Mapped[int] = mapped_column(Integer, default=0, comment="资源总数")
26
+ sort_order: Mapped[int] = mapped_column(Integer, default=0, comment="排序权重")
27
+ remark: Mapped[str | None] = mapped_column(String(200), comment="备注")
28
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
29
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/models/sync_log.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class SyncLog(Base):
10
+ __tablename__ = "sync_log"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
14
+ status: Mapped[str] = mapped_column(String(20), nullable=False, comment="running/success/failed")
15
+ started_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="开始时间")
16
+ finished_at: Mapped[datetime | None] = mapped_column(DateTime, comment="结束时间")
17
+ total_fetched: Mapped[int] = mapped_column(Integer, default=0, comment="拉取总数")
18
+ new_count: Mapped[int] = mapped_column(Integer, default=0, comment="新增数")
19
+ update_count: Mapped[int] = mapped_column(Integer, default=0, comment="更新数")
20
+ fail_count: Mapped[int] = mapped_column(Integer, default=0, comment="失败数")
21
+ error_message: Mapped[str | None] = mapped_column(String, comment="错误信息")
22
+ duration_seconds: Mapped[int | None] = mapped_column(Integer, comment="耗时秒数")
app/models/user.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class User(Base):
10
+ __tablename__ = "user"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ username: Mapped[str | None] = mapped_column(String(30), unique=True, comment="用户名")
14
+ email: Mapped[str | None] = mapped_column(String(100), unique=True, comment="邮箱")
15
+ phone: Mapped[str | None] = mapped_column(String(20), unique=True, comment="手机号")
16
+ password_hash: Mapped[str] = mapped_column(String(128), nullable=False, comment="bcrypt哈希")
17
+ nickname: Mapped[str | None] = mapped_column(String(30), comment="昵称")
18
+ avatar: Mapped[str | None] = mapped_column(String(500), comment="头像URL")
19
+ is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")
20
+ last_login_at: Mapped[datetime | None] = mapped_column(DateTime, comment="最后登录时间")
21
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
22
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/models/vod.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, Float, Integer, String, Text, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class Vod(Base):
10
+ __tablename__ = "vod"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ name: Mapped[str] = mapped_column(String(200), nullable=False, comment="影片名称")
14
+ sub_name: Mapped[str | None] = mapped_column(String(500), comment="副标题/别名")
15
+ en_name: Mapped[str | None] = mapped_column(String(200), comment="英文拼音")
16
+ category_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="分类ID")
17
+ cover: Mapped[str | None] = mapped_column(String(500), comment="封面图URL")
18
+ actor: Mapped[str | None] = mapped_column(String(2000), comment="演员,逗号分隔")
19
+ director: Mapped[str | None] = mapped_column(String(200), comment="导演")
20
+ area: Mapped[str | None] = mapped_column(String(50), comment="地区")
21
+ lang: Mapped[str | None] = mapped_column(String(50), comment="语言")
22
+ year: Mapped[str | None] = mapped_column(String(10), comment="年份")
23
+ duration: Mapped[str | None] = mapped_column(String(20), comment="时长")
24
+ score: Mapped[float | None] = mapped_column(Float, comment="评分 0-10")
25
+ douban_id: Mapped[int | None] = mapped_column(Integer, comment="豆瓣ID")
26
+ blurb: Mapped[str | None] = mapped_column(Text, comment="简介")
27
+ content: Mapped[str | None] = mapped_column(Text, comment="详细介绍(HTML)")
28
+ remarks: Mapped[str | None] = mapped_column(String(100), comment="备注(如第39集)")
29
+ is_end: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否完结")
30
+ is_hidden: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否隐藏")
31
+ is_recommended: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否推荐")
32
+ view_count: Mapped[int] = mapped_column(Integer, default=0, comment="播放次数")
33
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
34
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/models/vod_source.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Boolean, DateTime, Integer, String, func
4
+ from sqlalchemy.orm import Mapped, mapped_column
5
+
6
+ from app.database import Base
7
+
8
+
9
+ class VodSource(Base):
10
+ __tablename__ = "vod_source"
11
+
12
+ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
13
+ vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="影片ID")
14
+ source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
15
+ source_vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="源站影片ID")
16
+ play_from: Mapped[str] = mapped_column(String(30), nullable=False, comment="播放来源")
17
+ play_url: Mapped[str] = mapped_column(String, nullable=False, comment="播放地址(原始)")
18
+ parse_url: Mapped[str | None] = mapped_column(String, comment="解析后URL")
19
+ is_available: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否可用")
20
+ last_check_at: Mapped[datetime | None] = mapped_column(DateTime, comment="可用性检查时间")
21
+ created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
22
+ updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
app/routers/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ from app.routers.admin import auth as admin_auth
4
+ from app.routers.admin import source as admin_source
5
+ from app.routers.admin import vod as admin_vod
6
+ from app.routers.admin import category as admin_category
7
+ from app.routers.admin import user_mgmt as admin_user_mgmt
8
+ from app.routers.admin import admin_mgmt as admin_admin_mgmt
9
+ from app.routers.admin import role_mgmt as admin_role_mgmt
10
+ from app.routers.admin import sync as admin_sync
11
+ from app.routers.admin import system as admin_system
12
+
13
+ admin_router = APIRouter()
14
+ admin_router.include_router(admin_auth.router, prefix="/auth", tags=["Admin-Auth"])
15
+ admin_router.include_router(admin_source.router, prefix="/source", tags=["Admin-Source"])
16
+ admin_router.include_router(admin_vod.router, prefix="/vod", tags=["Admin-Vod"])
17
+ admin_router.include_router(admin_category.router, prefix="/category", tags=["Admin-Category"])
18
+ admin_router.include_router(admin_user_mgmt.router, prefix="/user", tags=["Admin-User"])
19
+ admin_router.include_router(admin_admin_mgmt.router, prefix="/admin", tags=["Admin-Admin"])
20
+ admin_router.include_router(admin_role_mgmt.router, prefix="/role", tags=["Admin-Role"])
21
+ admin_router.include_router(admin_sync.router, prefix="/sync", tags=["Admin-Sync"])
22
+ admin_router.include_router(admin_system.router, prefix="/system", tags=["Admin-System"])
app/routers/admin/__init__.py ADDED
File without changes
app/routers/admin/admin_mgmt.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_admins():
8
+ pass
9
+
10
+
11
+ @router.post("")
12
+ async def create_admin():
13
+ pass
14
+
15
+
16
+ @router.put("/{admin_id}")
17
+ async def update_admin(admin_id: int):
18
+ pass
19
+
20
+
21
+ @router.delete("/{admin_id}")
22
+ async def delete_admin(admin_id: int):
23
+ pass
24
+
25
+
26
+ @router.put("/{admin_id}/reset-password")
27
+ async def reset_password(admin_id: int):
28
+ pass
29
+
30
+
31
+ @router.put("/{admin_id}/assign-roles")
32
+ async def assign_roles(admin_id: int):
33
+ pass
app/routers/admin/auth.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.post("/login")
7
+ async def login():
8
+ pass
9
+
10
+
11
+ @router.post("/logout")
12
+ async def logout():
13
+ pass
14
+
15
+
16
+ @router.get("/user-info")
17
+ async def get_user_info():
18
+ pass
19
+
20
+
21
+ @router.get("/codes")
22
+ async def get_access_codes():
23
+ pass
24
+
25
+
26
+ @router.get("/menus")
27
+ async def get_menus():
28
+ pass
29
+
30
+
31
+ @router.get("/permissions")
32
+ async def get_permissions():
33
+ pass
app/routers/admin/category.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_categories():
8
+ pass
9
+
10
+
11
+ @router.put("/{category_id}")
12
+ async def update_category(category_id: int):
13
+ pass
14
+
15
+
16
+ @router.put("/mapping")
17
+ async def update_mapping():
18
+ pass
app/routers/admin/role_mgmt.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_roles():
8
+ pass
9
+
10
+
11
+ @router.post("")
12
+ async def create_role():
13
+ pass
14
+
15
+
16
+ @router.put("/{role_id}")
17
+ async def update_role(role_id: int):
18
+ pass
19
+
20
+
21
+ @router.delete("/{role_id}")
22
+ async def delete_role(role_id: int):
23
+ pass
24
+
25
+
26
+ @router.put("/{role_id}/permissions")
27
+ async def assign_permissions(role_id: int):
28
+ pass
app/routers/admin/source.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_sources():
8
+ pass
9
+
10
+
11
+ @router.post("")
12
+ async def create_source():
13
+ pass
14
+
15
+
16
+ @router.get("/{source_id}")
17
+ async def get_source(source_id: int):
18
+ pass
19
+
20
+
21
+ @router.put("/{source_id}")
22
+ async def update_source(source_id: int):
23
+ pass
24
+
25
+
26
+ @router.delete("/{source_id}")
27
+ async def delete_source(source_id: int):
28
+ pass
29
+
30
+
31
+ @router.post("/{source_id}/test")
32
+ async def test_source(source_id: int):
33
+ pass
34
+
35
+
36
+ @router.post("/{source_id}/sync")
37
+ async def sync_source(source_id: int):
38
+ pass
39
+
40
+
41
+ @router.put("/{source_id}/enable")
42
+ async def enable_source(source_id: int):
43
+ pass
app/routers/admin/sync.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("/log")
7
+ async def list_sync_logs():
8
+ pass
9
+
10
+
11
+ @router.post("/trigger")
12
+ async def trigger_sync():
13
+ pass
app/routers/admin/system.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("/config")
7
+ async def get_config():
8
+ pass
9
+
10
+
11
+ @router.put("/config")
12
+ async def update_config():
13
+ pass
app/routers/admin/user_mgmt.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_users():
8
+ pass
9
+
10
+
11
+ @router.get("/{user_id}")
12
+ async def get_user(user_id: int):
13
+ pass
14
+
15
+
16
+ @router.put("/{user_id}/ban")
17
+ async def ban_user(user_id: int):
18
+ pass
19
+
20
+
21
+ @router.delete("/{user_id}")
22
+ async def delete_user(user_id: int):
23
+ pass
app/routers/admin/vod.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_vods():
8
+ pass
9
+
10
+
11
+ @router.get("/{vod_id}")
12
+ async def get_vod(vod_id: int):
13
+ pass
14
+
15
+
16
+ @router.put("/{vod_id}")
17
+ async def update_vod(vod_id: int):
18
+ pass
19
+
20
+
21
+ @router.delete("/{vod_id}")
22
+ async def delete_vod(vod_id: int):
23
+ pass
24
+
25
+
26
+ @router.put("/{vod_id}/hide")
27
+ async def toggle_hide(vod_id: int):
28
+ pass
29
+
30
+
31
+ @router.put("/{vod_id}/recommend")
32
+ async def toggle_recommend(vod_id: int):
33
+ pass
app/routers/user/__init__.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ from app.routers.user import auth as user_auth
4
+ from app.routers.user import vod as user_vod
5
+ from app.routers.user import category as user_category
6
+ from app.routers.user import favorite as user_favorite
7
+ from app.routers.user import history as user_history
8
+
9
+ user_router = APIRouter()
10
+ user_router.include_router(user_auth.router, prefix="/auth", tags=["User-Auth"])
11
+ user_router.include_router(user_vod.router, prefix="/vod", tags=["User-Vod"])
12
+ user_router.include_router(user_category.router, prefix="/category", tags=["User-Category"])
13
+ user_router.include_router(user_favorite.router, prefix="/favorite", tags=["User-Favorite"])
14
+ user_router.include_router(user_history.router, prefix="/history", tags=["User-History"])
app/routers/user/auth.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.post("/register")
7
+ async def register():
8
+ pass
9
+
10
+
11
+ @router.post("/login")
12
+ async def login():
13
+ pass
14
+
15
+
16
+ @router.get("/profile")
17
+ async def get_profile():
18
+ pass
app/routers/user/category.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_categories():
8
+ pass
app/routers/user/favorite.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_favorites():
8
+ pass
9
+
10
+
11
+ @router.post("")
12
+ async def add_favorite():
13
+ pass
14
+
15
+
16
+ @router.delete("/{vod_id}")
17
+ async def remove_favorite(vod_id: int):
18
+ pass
app/routers/user/history.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_history():
8
+ pass
9
+
10
+
11
+ @router.post("")
12
+ async def record_history():
13
+ pass
14
+
15
+
16
+ @router.delete("/{history_id}")
17
+ async def delete_history(history_id: int):
18
+ pass
app/routers/user/vod.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+
3
+ router = APIRouter()
4
+
5
+
6
+ @router.get("")
7
+ async def list_vods():
8
+ pass
9
+
10
+
11
+ @router.get("/search")
12
+ async def search_vods():
13
+ pass
14
+
15
+
16
+ @router.get("/recommended")
17
+ async def recommended_vods():
18
+ pass
19
+
20
+
21
+ @router.get("/latest")
22
+ async def latest_vods():
23
+ pass
24
+
25
+
26
+ @router.get("/{vod_id}")
27
+ async def get_vod(vod_id: int):
28
+ pass
app/schemas/__init__.py ADDED
File without changes
app/schemas/admin/__init__.py ADDED
File without changes
app/schemas/admin/admin_mgmt.py ADDED
File without changes
app/schemas/admin/auth.py ADDED
File without changes
app/schemas/admin/category.py ADDED
File without changes
app/schemas/admin/role_mgmt.py ADDED
File without changes
app/schemas/admin/source.py ADDED
File without changes
app/schemas/admin/sync.py ADDED
File without changes
app/schemas/admin/system.py ADDED
File without changes