package com.sky.ioc.controller.system;

import com.sky.ioc.entity.domain.system.Menus;
import com.sky.ioc.service.system.MenuService;
import com.sky.ioc.tool.ReturnMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "系统设置--菜单")
@Slf4j
@RestController
@RequestMapping("/system_menu")
public class MenuController {

    @Autowired
    MenuService menuService;
    @ApiOperation("查询所有菜单")
    @GetMapping("getMenusList")
    public ReturnMsg getMenusList( @RequestParam(value = "parentId", required=false,defaultValue = "0")  long parentId){
        return menuService.getMenusInfoList(parentId);
    }

    @ApiOperation("查询常用菜单")
    @GetMapping("getCommonMenus")
    public ReturnMsg getCommonMenus(@RequestParam(value = "userId", required=true)  Integer userId){
        return menuService.listByUserId(userId);
    }

}
