"""首页入口控制器。"""

from typing import Any

from fastapi import Depends

from fastapi_common.fastapi_common_security.security import verify_access_token
from fastapi_common.fastapi_common_web.controller import BaseController
from fastapi_common.fastapi_common_web.domain.responses import Result

from fastapi_modules.fastapi_leaudit.domian.vo.homeVo import HomeEntryModuleVO
from fastapi_modules.fastapi_leaudit.services import IHomeService
from fastapi_modules.fastapi_leaudit.services.impl.homeServiceImpl import HomeServiceImpl


class HomeController(BaseController):
    """首页入口控制器。"""

    def __init__(self):
        super().__init__(prefix="/home", tags=["首页"])
        self.HomeService: IHomeService = HomeServiceImpl()

        @self.router.get("/entry-modules", response_model=Result[list[HomeEntryModuleVO]])
        async def GetEntryModules(payload: dict[str, Any] = Depends(verify_access_token)):
            """获取当前用户可见的首页入口模块。"""
            Data = await self.HomeService.GetEntryModules(UserId=int(payload["user_id"]))
            return Result.success(data=Data)
