package com.jiayue.ipp.idp.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipp.common.data.entity.SysMenu;
import com.jiayue.ipp.idp.service.SysMenuService;
import com.jiayue.ipp.idp.util.R;
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 zy
 * @version 3.0
 * @since 2020/6/28 10:12
 */
@RestController
@Slf4j
@RequestMapping(value = "sysMenu")
public class SysMenuController {

    private final SysMenuService sysMenuService;

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

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

    @GetMapping()
    public R getAll() {

        try {
            List<SysMenu> menu = this.sysMenuService.getAllMenu();
            return R.ok(menu);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(" 获取所有用户异常");
            return R.failed(null);
        }

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

  @GetMapping("/getMenufindByName")
  public R getMenufindByName(String username) {

    try {
      List<SysMenu> menu = this.sysMenuService.getMenuFindByUserName(username);
      return R.ok(menu);
    } catch (Exception e) {
      e.printStackTrace();
      log.error(" 获取所有用户异常");
      return R.failed(null);
    }

  }
}
