package com.td.WaDa.sys.sysmenu.controller;

import com.td.WaDa.annotation.Decrypt;
import com.td.WaDa.annotation.Encrypt;
import com.td.WaDa.common.controller.CommonController;
import com.td.WaDa.common.pojo.Result;
import com.td.WaDa.sys.sysmenu.pojo.SysMenu;
import com.td.WaDa.sys.sysmenu.service.SysMenuService;
import com.td.WaDa.sys.sysmenu.vo.SysMenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("/sys/sysMenu/")
public class SysMenuController extends CommonController<SysMenuVo, SysMenu, String> {
    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("menu")
    public ModelAndView menu(){
        return new ModelAndView("sys/menu/menu");
    }

    @PostMapping("save1")
    @ResponseBody
    public ModelAndView menu(SysMenuVo sysMenuVo){
        super.save(sysMenuVo);
        return new ModelAndView("sys/menu/menu");
    }


    /**
     * 分层级
     */
    @PostMapping("listByTier")
    @Decrypt
    @Encrypt
    public Result<List<SysMenuVo>> listByTier(SysMenuVo entityVo) {
        return sysMenuService.listByTier(entityVo);
    }
}
