package com.springboot.cloud.sysadmin.organization.rest;

/*
 **********************************************
 *      DATE           PERSON       REASON
 *    2021-01-05          FXY        Created
 **********************************************
 */

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
import com.springboot.cloud.sysadmin.organization.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @GetMapping("/index")
    public Result index(@RequestParam("companyId")String companyId){
        Optional.ofNullable(companyId).orElseThrow(UserNotFoundException::new);
        return Result.success(menuService.index(companyId));
    }

}
