package com.qqchen.deploy.backend.system.api;

import com.qqchen.deploy.backend.system.entity.Menu;
import com.qqchen.deploy.backend.framework.api.Response;
import com.qqchen.deploy.backend.framework.controller.BaseController;
import com.qqchen.deploy.backend.system.model.MenuDTO;
import com.qqchen.deploy.backend.system.model.query.MenuQuery;
import com.qqchen.deploy.backend.system.model.response.MenuPermissionTreeResponse;
import com.qqchen.deploy.backend.system.model.response.MenuResponse;
import com.qqchen.deploy.backend.system.service.IMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/v1/menu")
@Tag(name = "菜单管理API", description = "对外提供的菜单管理接口")
public class MenuApiController extends BaseController<Menu, MenuDTO, Long, MenuQuery> {

    @Resource
    private IMenuService menuService;

    /**
     * 获取当前用户的菜单
     */
    @Operation(summary = "获取当前用户的菜单")
    @GetMapping("/current")
    public Response<List<MenuResponse>> getCurrentUserMenus() {
        return Response.success(menuService.getUserMenus());
    }

    @Operation(summary = "获取菜单树")
    @GetMapping("/tree")
    public Response<List<MenuResponse>> getTree() {
        return Response.success(menuService.getMenuTree());
    }

    @Operation(summary = "获取菜单树")
    @GetMapping("/permission-tree")
    public Response<List<MenuPermissionTreeResponse>> getPermissionTree() {
        return Response.success(menuService.getPermissionTree());
    }

    @Override
    protected void exportData(HttpServletResponse response, List<MenuDTO> data) {

    }
}