package com.manage.controller;

import com.manage.entity.Power_Menu;
import com.manage.service.cache.CacheManager;
import com.manage.service.Power_MenuService;
import com.manage.util.ActionScopeUtils;
import com.manage.util.Constant;
import com.manage.util.Msg;
import com.manage.vo.Power_UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author:hjl
 * @Date:Creatid in 1:28 2019/4/17
 * @Description:菜單管理
 */
@Controller
@RequestMapping("menuPower/")
public class Power_MenuController {
    @Autowired
    private Power_MenuService powerMenuService;

    @RequestMapping("indexMenu")
    @ResponseBody
    public Msg indexMenu() throws Exception{
        Power_UserVo user = (Power_UserVo) ActionScopeUtils.getSessionAttribute( Constant.CURRENT_USER);
        List<Power_Menu> list = null;
        if(user.getRoleId().equals(0) || user.getRoleId().equals(-100)){
            list = powerMenuService.queryAllPowerMenu("power",user.getRoleId());
        } else{
            list = powerMenuService.selectUserAndRoleMenuListPower(user.getUserId(),"power");
        }
        CacheManager.addExcCount("noExc");
        return Msg.success().add("listPower", list);
    }

}
