Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / zhz / MenuNewController.java
package com.newfiber.api.pc.controller.zhz;

import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.commons.ResultCode;
import com.newfiber.api.core.commons.ResultObj;
import com.newfiber.api.core.exception.RRException;
import com.newfiber.api.pc.dto.MenuDTO;
import com.newfiber.api.pc.model.zhz.Menu;
import com.newfiber.api.pc.service.MenusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:zhz
 * @CreateDate:2020/11/19 15:01
 * @Description:
 */
@RestController
@Api(value = "MenuNewController",tags = "SYS-01、新版本菜单管理控制层", position = 100)
@RequestMapping("/newMenu")
public class MenuNewController {

    @Autowired
    private MenusService menusService;


    @PostMapping("/menuTree")
    @ApiOperation("返回菜单树")
    @SysLog(actionType = "4",value = "返回菜单树")
    public ResultObj<List<Menu>> selectMenuTree(){
        List<Menu> tree =  menusService.selectMenuTree();
        return new ResultObj<List<Menu>>(ResultCode.OK,tree);
    }

    @PostMapping("/add")
    @ApiOperation("新增菜单")
    @SysLog(actionType = "1",value = "新增菜单")
    public ResultObj addMenu(@RequestBody MenuDTO menuDTO){
        menusService.addMenu(menuDTO);
        return ResultObj.ok();
    }
    @PostMapping("/update")
    @ApiOperation("修改菜单")
    @SysLog(actionType = "4",value = "修改菜单")
    public ResultObj updateMenu(@RequestBody MenuDTO menuDTO){
        menusService.updateMenu(menuDTO);
        return ResultObj.ok();
    }

    @PostMapping("/delete")
    @ApiOperation("删除菜单")
    @SysLog(actionType = "2",value = "删除菜单")
    public ResultObj deleteMenu(@RequestParam("menuNo")String menuNo){
        if(StringUtils.isEmpty(menuNo)){
            throw new RRException("请选择一条菜单数据",408);
        }
        menusService.deleteMenu(menuNo);
        return ResultObj.ok();
    }




}