package com.ycwl.basic.controller.pc;

import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.model.pc.menu.entity.MenuEntity;
import com.ycwl.basic.service.pc.MenuService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：longbinbin
 * @Date：2024/12/3 10:03
 */
@RestController
@RequestMapping("/api/menu/v1")
@Api(tags = "系统菜单管理")
public class MenuController {

    private MenuService menuService;


    @GetMapping(value = "/list/{type}")
    @ApiOperation(value = " 菜单列表")
    @IgnoreToken
    public ApiResponse list(@PathVariable("type") Integer type) {
        return menuService.list(type);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加菜单")
    public ApiResponse add(@RequestBody MenuEntity menu) {
        return menuService.add(menu);
    }
    @PostMapping("/update")
    @ApiOperation(value = "修改菜单")
    public ApiResponse update(@RequestBody MenuEntity menu) {
        return menuService.update(menu);
    }
    @GetMapping("/delete/{id}")
    @ApiOperation(value = "删除菜单")
    public ApiResponse delete(@PathVariable("id") Long id) {
        return menuService.deleteById(id);
    }
}
