/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtymis.custom.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.xrtymis.custom.service.GdglflowService;
import com.tofly.xrtymis.entity.Gdglflow;
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;

import java.util.Arrays;
/**
 * 业务工单驳回记录表
 *
 * @author fu
 * @date Fri Mar 19 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/gdglflow")
@Api(tags="业务工单驳回记录表接口")
public class GdglflowController {

    private final GdglflowService gdglflowService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param gdglflow 业务工单驳回记录表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getGdglflowPage(Page page, @ModelAttribute Gdglflow gdglflow) {
      return ResultRespone.success(gdglflowService.page(page, Wrappers.query(gdglflow)));
    }


    /**
     * 通过id查询业务工单驳回记录表
     * @param  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(gdglflowService.getById(id));
    }

    /**
     * 新增业务工单驳回记录表
     * @param gdglflow 业务工单驳回记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增业务工单驳回记录表" )
    @ApiOperation(value = "新增业务工单驳回记录表")
    @PostMapping
    public ResultRespone save(@RequestBody Gdglflow gdglflow) {
      return ResultRespone.success(gdglflowService.save(gdglflow));
    }

    /**
     * 修改业务工单驳回记录表
     * @param gdglflow 业务工单驳回记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改业务工单驳回记录表" )
    @ApiOperation(value = "修改业务工单驳回记录表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Gdglflow gdglflow) {
      return ResultRespone.success(gdglflowService.updateById(gdglflow));
    }

    /**
     * 通过id删除业务工单驳回记录表
     * @param lsbh id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除业务工单驳回记录表" )
    @ApiOperation(value = "通过ID删除业务工单驳回记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lsbh", value = "ID", required = true, dataType = "String")
    })

    @DeleteMapping("/{lsbh}" )
    public ResultRespone removeById(@PathVariable String lsbh) {
      return ResultRespone.success(gdglflowService.removeById(lsbh));
    }

    /**
     * 通过id批量删除业务工单驳回记录表
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id批量删除业务工单驳回记录表" )
    @ApiOperation(value = "通过ID批量删除业务工单驳回记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(gdglflowService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
