package com.bonus.material.countersign.controller;

import com.bonus.common.core.utils.poi.ExcelUtil;
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.service.ISignConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

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

    @Autowired
    private ISignConfigService signConfigService;

    /**
     * 查询会签配置管理列表
     */
    @ApiOperation(value = "查询会签配置管理列表")
    @RequiresPermissions("signConfig:info:list")
    @GetMapping("/list")
    public TableDataInfo getList(SignConfigVo signConfigVo) {
        startPage();
        List<SignConfigVo> list = signConfigService.getList(signConfigVo);
        return getDataTable(list);
    }

    /**
     * 新增会签配置管理
     */
    @ApiOperation(value = "新增会签配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signConfig:info:add")
    @SysLog(title = "会签配置管理", businessType = OperaType.INSERT, logType = 1,module = "会签配置管理->新增会签配置管理")
    @PostMapping("/addConfig")
    public AjaxResult addConfig(@RequestBody SignConfigVo signConfigVo) {
        try {
            return signConfigService.insertConfigInfo(signConfigVo);
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    /**
     * 获取会签配置详细信息
     */
    @ApiOperation(value = "获取会签配置管理详细信息")
    @RequiresPermissions("signConfig:info:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(signConfigService.selectConfigInfoById(id));
    }


    /**
     * 修改会签配置管理
     */
    @ApiOperation(value = "修改会签配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signConfig:info:edit")
    @SysLog(title = "会签配置管理", businessType = OperaType.UPDATE, logType = 1,module = "会签配置管理->修改会签配置管理")
    @PostMapping("/editConfig")
    public AjaxResult editConfig(@RequestBody SignConfigVo signConfigVo) {
        try {
            return signConfigService.updateConfigInfo(signConfigVo);
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    /**
     * 删除会签配置
     */
    @ApiOperation(value = "删除会签配置管理")
    @PreventRepeatSubmit
    @RequiresPermissions("signConfig:info:remove")
    @SysLog(title = "会签配置管理", businessType = OperaType.DELETE, module = "会签配置管理->删除会签配置管理")
	@PostMapping("/delConfig/{id}")
    public AjaxResult delConfig(@PathVariable("id") Long id) {
        return signConfigService.delConfig(id);
    }
}
