from typing import List from fastapi import APIRouter, Depends from sqlalchemy.ext.asyncio import AsyncSession from apis.base import standard_response, StandardResponse from db.database import get_db from entity.push_config import PushConfig, PushConfigCreate from services.push_config_service import PushConfigService router = APIRouter() @router.get("/list", response_model=StandardResponse[List[PushConfig]]) async def get_push_config_list(db: AsyncSession = Depends(get_db)): service = PushConfigService(db) push_configs = await service.get_push_config_list() return standard_response(data=push_configs) @router.get("/get_by_type", response_model=StandardResponse[PushConfig]) async def get_by_type(push_type: int, db: AsyncSession = Depends(get_db)): service = PushConfigService(db) push_config = await service.get_push_config(push_type) return standard_response(data=push_config) @router.post("/set_push_config", response_model=StandardResponse[PushConfig]) async def set_push_config(push_config: PushConfigCreate, db: AsyncSession = Depends(get_db)): service = PushConfigService(db) push_config = await service.set_push_config(push_config) return standard_response(data=push_config)