package com.duanledexianxianxian.demo.controller;


import com.duanledexianxianxian.demo.domain.model.query.MenuForm;
import com.duanledexianxianxian.demo.service.IMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单接口
 *
 * @author duanledexianxianxian
 * @since 2020 -03-19
 */
@RestController
@RequestMapping("/api/v1/menus")
@Slf4j
public class MenuController {
    /**
     * The Menu service.
     */
    @Autowired
    private IMenuService menuService;

    /**
     * 添加菜单
     *
     * @param form 菜单表单
     * @return the long
     */
    @PostMapping
    public Long addMenu(@RequestBody MenuForm form) {
        return menuService.addMenu(form);
    }


    /**
     * 编辑菜单
     *
     * @param form 菜单表单
     * @return the long
     */
    @PutMapping
    public Boolean editMenu(@RequestBody MenuForm form) {
        return menuService.editMenu(form);
    }


    /**
     * 编辑菜单
     *
     * @param menuId 菜单编码
     * @return the long
     */
    @DeleteMapping("/{menuId}")
    public Boolean deleteMenu(@PathVariable("menuId") Long menuId) {
        return menuService.deleteMenu(menuId);
    }
}
