/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.base.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.base.entity.Menutest;
import com.tofly.base.service.MenutestService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

/**
 * 菜单测试表
 *
 * @author admin
 * @date Fri Feb 28 00:00:00 CST 2020
 */
@RestController
@AllArgsConstructor
@RequestMapping("/menutest")
@Api(tags="菜单测试表接口")
public class MenutestController {

    private final  MenutestService menutestService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param menutest 菜单测试表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getMenutestPage(Page page, @ModelAttribute Menutest menutest) {
      return ResultRespone.success(menutestService.page(page, Wrappers.query(menutest)));
    }


    /**
     * 通过id查询菜单测试表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(menutestService.getById(id));
    }

    /**
     * 新增菜单测试表
     * @param menutest 菜单测试表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增菜单测试表" )
    @ApiOperation(value = "新增菜单测试表")
    @PostMapping
    public ResultRespone save(@RequestBody Menutest menutest) {
      return ResultRespone.success(menutestService.save(menutest));
    }

    /**
     * 修改菜单测试表
     * @param menutest 菜单测试表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改菜单测试表" )
    @ApiOperation(value = "修改菜单测试表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Menutest menutest) {
      return ResultRespone.success(menutestService.updateById(menutest));
    }

    /**
     * 通过id删除菜单测试表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除菜单测试表" )
    @ApiOperation(value = "通过ID删除菜单测试表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(menutestService.removeById(id));
    }
}
