package com.sunxung.factoring.web.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sunxung.factoring.service.sys.PermissionService;

/**
 * @Description:系统权限控制层
 * @Date:2017年6月7日 上午11:09:24
 */
@Controller
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @RequestMapping(value = "/permission/findRootByParentId", method = {
            RequestMethod.GET, RequestMethod.POST
    })
    @ResponseBody
    public Object findRootByParentId() {
        return permissionService.findRootByParentId();
    }

    @RequestMapping(value = "/permission/findNodeByParentId", method = {
            RequestMethod.GET, RequestMethod.POST
    })
    @ResponseBody
    public Object findNodeByParentId(Long parentId) {
        return permissionService.findNodeByParentId(parentId);
    }

    @RequestMapping(value = "/permission/findPermisionTree", method = {
            RequestMethod.GET, RequestMethod.POST
    })
    @ResponseBody
    public Object do_findPermisionTree() {
        return permissionService.findPermisionTree();
    }

    @RequestMapping("/permission/findUpdateRootByParentId")
    @ResponseBody
    public Object findUpdateRootByParentId(Long roleId) {
        return permissionService.findUpdateRootByParentId(roleId);
    }

    @RequestMapping("/permission/findUpdateNodeByParentId")
    @ResponseBody
    public Object findUpdateNodeByParentId(Long parentId, Long roleId) {
        return permissionService.findUpdateNodeByParentId(parentId, roleId);
    }

    @RequestMapping("/permission/get_menu")
    @ResponseBody
    public Object getMenu(Model model) {
        return permissionService.findAll();
    }

    /**
     * 跳转到菜单页面
     */
    @RequestMapping("/permission/sidebar")
    public String siderbar() {
        return "common/sidebar";
    }
}
