package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.SysMenu;
import com.jiayue.ipfcst.service.SysMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 菜单
 *
 * @author xsl
 * @version 3.0
 */
@RestController
@Slf4j
@RequestMapping(value = "sysMenu")
public class SysMenuController {
  private final SysMenuService sysMenuService;

  @Autowired
  public SysMenuController(SysMenuService sysMenuService) {
    this.sysMenuService = sysMenuService;
  }

  /**
   * 获取菜单信息
   *
   * @return 菜单信息
   */

  @GetMapping("/getMenufindByName/{user}/{url}")
  public ResponseVO getMenufindByName(@PathVariable("user") String user,@PathVariable("url") String url) {

    try {
      List<SysMenu> menu = this.sysMenuService.getMenuFindByUserName(user,url);
      return ResponseVO.success(menu);
    } catch (Exception e) {
      e.printStackTrace();
      log.error(" 获取所有用户异常");
      return ResponseVO.error(null);
    }

  }

}
