package com.cm.common.plugin.oauth.controller.apis.menu;

import com.alibaba.fastjson.JSONArray;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.AccessTokenException;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.oauth.service.menu.IMenuService;
import com.cm.common.result.ErrorResult;
import io.swagger.annotations.*;
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.RestController;

import java.util.Map;

/**
 * @ClassName: MenuController
 * @Description: 菜单
 * @Author: WangGeng
 * @Date: 2019/4/22 1:59 PM
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "菜单管理")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/menu")
public class MenuController extends AbstractController {

    @Autowired
    private IMenuService menuService;

    @ApiOperation(value = "全部菜单列表", notes = "全部菜单列表接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listmenu")
    public JSONArray listMenu() throws AccessTokenException, SearchException {
        Map<String, Object> params = requestParams();
        return menuService.listMenu(params);
    }

    @ApiOperation(value = "我的菜单列表", notes = "我的菜单列表接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listmenuofmine")
    public JSONArray listMenuOfMine() throws AccessTokenException, SearchException {
        return menuService.listMenuOfMine();
    }

}
