package com.kcim.web;

import com.kcim.common.util.Result;
import com.kcim.dao.model.dto.MenuEditDTO;
import com.kcim.dao.model.dto.MenuSaveDTO;
import com.kcim.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Arrays;


/**
 * 菜单管理
 *
 * @author huangrui
 * @date 2021-08-03 08:56:22
 */
@Api(tags = "菜单管理")
@RestController
@RequestMapping("menu")
public class MenuController extends AbstractController {

    private final MenuService menuService;

    public MenuController(MenuService menuService) {
        this.menuService = menuService;
    }


    @ApiOperation("保存菜单")
    @PostMapping("/save")
    public Result save(@RequestBody @Valid MenuSaveDTO menuSaveDTO) {
//        menuService.saveMenu(menuSaveDTO, getUser());
        return Result.ok();
    }

    /**
     * 分页查询列表
     */
    @ApiOperation("菜单列表")
    @GetMapping("/list")
    public Result list(@RequestParam(defaultValue = "1", value = "current") Integer page,
                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                       @RequestParam(value = "name",required = false) String name) {
//        PageUtils pageUtils = menuService.selectList(page, pageSize, getUser(),name);
//        return Result.ok(pageUtils);
        return Result.ok();

    }

    @ApiOperation("编辑某个菜单")
    @PostMapping("/edit")
    public Result update(@RequestBody @Valid MenuEditDTO menuDTO) {
//        menuService.updateMenu(menuDTO, getUser());
        return Result.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除某个菜单")
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] menuIds) {
        menuService.deleteByIds(Arrays.asList(menuIds));
        return Result.ok();
    }

    @ApiOperation("获取当前登录人拥有的菜单")
    @GetMapping("/nav")
    public Result nav() {
//        List<NavVO> list = menuService.getNav(getUser());
        return Result.ok();
    }

}
