package com.xindazhou.user.api.permission;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.user.dal.dataobject.permission.MenuDO;
import com.xindazhou.user.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 * 菜单 RPC 接口
 *
 * @author xindazhou
 */
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 菜单")
public interface MenuApi {

    String PREFIX = "/rpc-api/user/menu";

    @GetMapping(PREFIX + "/list-by-ids")
    @Operation(summary = "根据 ID 列表获取菜单")
    @Parameter(name = "ids", description = "菜单编号数组", example = "1,2", required = true)
    CommonResult<List<MenuDO>> getMenuList(@RequestParam("ids") Collection<Long> ids);

    @GetMapping(PREFIX + "/list")
    @Operation(summary = "获取所有菜单列表")
    CommonResult<List<MenuDO>> getMenuList();

    @PostMapping(PREFIX + "/filter-disable")
    @Operation(summary = "过滤禁用的菜单")
    CommonResult<List<MenuDO>> filterDisableMenus(@RequestBody List<MenuDO> list);

    @GetMapping(PREFIX + "/menu-id-list-by-permission")
    @Operation(summary = "根据权限获取菜单 ID 列表（从缓存）")
    @Parameter(name = "permission", description = "权限标识", example = "system:user:query", required = true)
    CommonResult<List<Long>> getMenuIdListByPermissionFromCache(@RequestParam("permission") String permission);

}

