package com.zd.chemical.controller;

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

import com.zd.chemical.domain.vo.ActAuditconfigVo;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
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.chemical.domain.ActAuditconfig;
import com.zd.chemical.service.IActAuditconfigService;
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-08-16
 */
@RestController
@Api(tags = "【工作流审批】")
@RequestMapping("/auditconfig")
public class ActAuditconfigController extends BaseController<ActAuditconfig>
{
    @Autowired
    private IActAuditconfigService actAuditconfigService;

    /**
     * 查询工作流审批列表
     */
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:list")
    @GetMapping("/list")
    @ApiOperation(value = "查询工作流审批列表")
    public TableDataInfo<ActAuditconfig> list(ActAuditconfig actAuditconfig)
    {
        startPage();
        List<ActAuditconfig> list = actAuditconfigService.selectActAuditconfigList(actAuditconfig);
        return getDataTable(list);
    }

    /**
     * 查询工作流审批列表
     */
    @PreAuthorize(hasPermi = PerPrefix.ACT_HXP_AUDITCONFIG+ PerFun.LIST)
    @GetMapping("/getConfigList")
    @ApiOperation(value = "查询工作流审批列表")
    public TableDataInfo<ActAuditconfigVo> getConfigList(ActAuditconfig actAuditconfig)
    {
        startPage();
        List<ActAuditconfigVo> list = actAuditconfigService.getConfigList(actAuditconfig);
        TableDataInfo<ActAuditconfigVo> info=new TableDataInfo<>();
        info.getDataTable(list);
        return info;
    }

    /**
     * 导出工作流审批列表
     */
    @ApiOperation(value = "导出工作流审批列表")
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:export")
    @Log(title = "工作流审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActAuditconfig actAuditconfig) throws IOException
    {
        List<ActAuditconfig> list = actAuditconfigService.selectActAuditconfigList(actAuditconfig);
        ExcelUtil<ActAuditconfig> util = new ExcelUtil<ActAuditconfig>(ActAuditconfig.class);
        util.exportExcel(response, list, "工作流审批数据");
    }

    /**
     * 获取工作流审批详细信息
     */
    @ApiOperation(value = "获取工作流审批详细信息")
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:query")
    @GetMapping(value = "/{id}")
    public ResultData<ActAuditconfig> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(actAuditconfigService.selectActAuditconfigById(id));
    }

    /**
     * 新增工作流审批
     */
    @ApiOperation(value = "新增工作流审批")
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:add")
    @Log(title = "工作流审批", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody List<ActAuditconfigVo> actAuditconfigList)
    {
        return ResultData.result(actAuditconfigService.insertActAuditconfig(actAuditconfigList));
    }

    /**
     * 修改工作流审批
     */
    @ApiOperation(value = "修改工作流审批")
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:edit")
    @Log(title = "工作流审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody ActAuditconfig actAuditconfig)
    {
        return  ResultData.result(actAuditconfigService.updateActAuditconfig(actAuditconfig));
    }

    /**
     * 删除工作流审批
     */
    @ApiOperation(value = "删除工作流审批")
//    @PreAuthorize(hasPermi = "laboratory:auditconfig:remove")
    @Log(title = "工作流审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(actAuditconfigService.deleteActAuditconfigByIds(ids));
    }
}
