package com.zd.airbottle.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.zd.airbottle.domain.vo.QpFlowVO;
import com.zd.common.core.web.domain.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.airbottle.domain.QpFlow;
import com.zd.airbottle.service.IQpFlowService;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.zd.common.core.web.page.TableDataInfo;

/**
 * 气瓶审核流程Controller
 *
 * @author zd
 * @date 2022-06-13
 */
@RestController
@Api(tags = "【气瓶审核流程】")
@RequestMapping("/flow")
public class QpFlowController extends BaseController<QpFlow>
{
    @Autowired
    private IQpFlowService qpFlowService;

    /**
     * 查询气瓶审核流程列表
     */
    @PreAuthorize(hasPermi = "airbottle:flow:list")
    @GetMapping("/list")
    @ApiOperation(value = "查询气瓶审核流程列表")
    public TableDataInfo<QpFlow> list(QpFlow qpFlow)
    {
        startPage();
        List<QpFlow> list = qpFlowService.selectQpFlowList(qpFlow);
        return getDataTable(list);
    }

    /**
     * 导出气瓶审核流程列表
     */
    @ApiOperation(value = "导出气瓶审核流程列表")
    @PreAuthorize(hasPermi = "airbottle:flow:export")
    @Log(title = "气瓶审核流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QpFlow qpFlow) throws IOException
    {
        List<QpFlow> list = qpFlowService.selectQpFlowList(qpFlow);
        ExcelUtil<QpFlow> util = new ExcelUtil<QpFlow>(QpFlow.class);
        util.exportExcel(response, list, "气瓶审核流程数据");
    }

    /**
     * 获取气瓶审核流程详细信息
     */
    @ApiOperation(value = "获取气瓶审核流程详细信息")
    @PreAuthorize(hasPermi = "airbottle:flow:query")
    @GetMapping(value = "/{id}")
    public ResultData<QpFlow> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(qpFlowService.selectQpFlowById(id));
    }

    /**
     * 新增气瓶审核流程
     */
    @ApiOperation(value = "新增气瓶审核流程")
    @PreAuthorize(hasPermi = "airbottle:flow:add")
    @Log(title = "气瓶审核流程", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody QpFlowVO qpFlow)
    {
        return ResultData.result(qpFlowService.insertQpFlow(qpFlow));
    }

    /**
     * 修改气瓶审核流程
     */
    @ApiOperation(value = "修改气瓶审核流程")
    @PreAuthorize(hasPermi = "airbottle:flow:edit")
    @Log(title = "气瓶审核流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody QpFlow qpFlow)
    {
        return  ResultData.result(qpFlowService.updateQpFlow(qpFlow));
    }

    /**
     * 删除气瓶审核流程
     */
    @ApiOperation(value = "删除气瓶审核流程")
    @PreAuthorize(hasPermi = "airbottle:flow:remove")
    @Log(title = "气瓶审核流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(qpFlowService.deleteQpFlowByIds(ids));
    }
}
