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.service.permission.MenuService;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static com.xindazhou.framework.common.pojo.CommonResult.success;

/**
 * 菜单 RPC 接口实现类
 *
 * @author xindazhou
 */
@RestController
@Validated
@Primary
public class MenuApiImpl implements MenuApi {

    @Resource
    private MenuService menuService;

    @Override
    public CommonResult<List<MenuDO>> getMenuList(Collection<Long> ids) {
        return success(menuService.getMenuList(ids));
    }

    @Override
    public CommonResult<List<MenuDO>> getMenuList() {
        return success(menuService.getMenuList());
    }

    @Override
    public CommonResult<List<MenuDO>> filterDisableMenus(List<MenuDO> list) {
        return success(menuService.filterDisableMenus(list));
    }

    @Override
    public CommonResult<List<Long>> getMenuIdListByPermissionFromCache(String permission) {
        return success(menuService.getMenuIdListByPermissionFromCache(permission));
    }

}

