package com.bonus.material.work.controller;


import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.material.work.domain.SysWorkflowType;
import com.bonus.material.work.service.SysWorkflowTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "审批类型接口")
@RestController
@RequestMapping("/sysWorkflowType")
public class SysWorkflowTypeController extends BaseController {


    @Resource
    private SysWorkflowTypeService sysWorkflowTypeService;

    /**
     * 审批类型列表
     */
    @ApiOperation(value = "审批类型列表")
    @GetMapping("/list")
    public TableDataInfo list(SysWorkflowType sysWorkflowType)
    {
        try {
            startPage();
            List<SysWorkflowType> list = sysWorkflowTypeService.selectSysWorkflowTypeList(sysWorkflowType);
            return getDataTable(list);
        }catch (Exception e){
            return getDataTableError(null);
        }
    }

    /**
     * 新增审批类型
     */
    @ApiOperation(value = "新增审批类型")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysWorkflowType sysWorkflowType)
    {
        try {
            sysWorkflowTypeService.addSysWorkflowType(sysWorkflowType);
            return new AjaxResult(200,"新增成功！");
        }catch (Exception e){
            return error();
        }
    }

    /**
     * 删除审批类型
     */
    @ApiOperation(value = "删除审批类型")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody SysWorkflowType sysWorkflowType)
    {
        try {
            sysWorkflowTypeService.deleteSysWorkflowType(sysWorkflowType);
            return new AjaxResult(200,"删除成功！");
        }catch (Exception e){
            return error();
        }
    }

    /**
     * 修改审批类型
     */
    @ApiOperation(value = "修改审批类型")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody SysWorkflowType sysWorkflowType)
    {
        try {
            sysWorkflowTypeService.updateSysWorkflowType(sysWorkflowType);
            return new AjaxResult(200,"修改成功！");
        }catch (Exception e){
            return error();
        }
    }

}
