package com.YuyeTech.HeartRate.sys.sysmenu.controller;

import com.YuyeTech.HeartRate.annotation.Decrypt;
import com.YuyeTech.HeartRate.annotation.Encrypt;
import com.YuyeTech.HeartRate.common.controller.CommonController;
import com.YuyeTech.HeartRate.common.pojo.Result;
import com.YuyeTech.HeartRate.sys.sysmenu.pojo.SysMenu;
import com.YuyeTech.HeartRate.sys.sysmenu.service.SysMenuService;
import com.YuyeTech.HeartRate.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);
    }
}
