package com.bonus.material.countersign.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.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.countersign.domain.SignConfigVo;
import com.bonus.material.countersign.domain.SignProcessVo;
import com.bonus.material.countersign.service.ISignConfigService;
import com.bonus.material.countersign.service.ISignProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会签流程管理Controller
 * 
 * @author hongchao
 * @date 2025-01-16
 */
@Api(tags = "会签流程管理接口")
@RestController
@RequestMapping("/sign_process")
public class signProcessController extends BaseController {

    @Autowired
    private ISignProcessService signProcessService;

    /**
     * 查询会签流程配置管理列表
     */
    @ApiOperation(value = "查询会签配置管理列表")
    @RequiresPermissions("signProcess:info:list")
    @GetMapping("/list")
    public TableDataInfo getList(SignProcessVo signProcessVo) {
        startPage();
        List<SignProcessVo> list = signProcessService.getList(signProcessVo);
        return getDataTable(list);
    }

    /**
     * 新增会签流程配置管理
     */
    @ApiOperation(value = "新增会签流程配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signProcess:info:add")
    @SysLog(title = "会签流程配置管理", businessType = OperaType.INSERT, logType = 1,module = "会签流程配置管理->新增会签流程配置管理")
    @PostMapping("/addProcess")
    public AjaxResult addProcess(@RequestBody SignProcessVo signProcessVo) {
        try {
            return signProcessService.insertProcessInfo(signProcessVo);
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    /**
     * 获取会签流程配置详细信息
     */
    @ApiOperation(value = "获取会签流程配置管理详细信息")
    @RequiresPermissions("signProcess:info:query")
    @GetMapping(value = "/{ids}")
    public AjaxResult getInfo(@PathVariable("ids") Long[] ids) {
        return success(signProcessService.selectProcessInfoById(ids));
    }


    /**
     * 修改会签流程配置管理
     */
    @ApiOperation(value = "修改会签流程配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signProcess:info:edit")
    @SysLog(title = "会签流程配置管理", businessType = OperaType.UPDATE, logType = 1,module = "会签流程配置管理->修改会签流程配置管理")
    @PostMapping("/editProcess")
    public AjaxResult editProcess(@RequestBody SignProcessVo signProcessVo) {
        try {
            return signProcessService.updateProcessInfo(signProcessVo);
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    /**
     * 删除会签流程配置
     */
    @ApiOperation(value = "删除会签流程配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signProcess:info:remove")
    @SysLog(title = "会签流程配置管理", businessType = OperaType.DELETE, module = "会签流程配置管理->删除会签流程配置管理")
	@PostMapping("/delProcess/{ids}")
    public AjaxResult delProcess(@PathVariable("ids") Long[] ids) {
        return signProcessService.delProcess(ids);
    }
}
