package com.huimv.admin.system.controller;

import com.huimv.admin.system.entity.ScreenSysMenu;
import com.huimv.admin.system.service.IScreenSysMenuService;
import com.huimv.common.token.TokenSign;
import com.huimv.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/screen/menu")
public class ScreenMenuController {
    @Autowired
    private IScreenSysMenuService menuService;

    @PostMapping("/add")
    public Result addMenu(@RequestBody ScreenSysMenu menu , HttpServletRequest request){
        Integer userId = TokenSign.getMemberIdByJwtToken(request);

        return menuService.addMenu(menu,userId);
    }


    @PostMapping("/edit")
    public Result editMenu(@RequestBody ScreenSysMenu menu){
        return menuService.editMenu(menu);
    }


    @RequestMapping("/remove")
    public Result removeMenu(@RequestParam(name = "menuId") Integer menuId){
        return menuService.removeMenu(menuId);
    }

    @PostMapping("/list")
    public Result optimizeList() {
        return menuService.optimizeList();
    }

    @PostMapping("/list1")
    public Result list1() {
        return menuService.list1();
    }
}
