package org.jk.rag.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.jk.common.core.domain.R;
import org.jk.common.excel.utils.ExcelUtil;
import org.jk.common.log.annotation.Log;
import org.jk.common.log.enums.BusinessType;
import org.jk.common.mybatis.core.page.PageQuery;
import org.jk.common.mybatis.core.page.TableDataInfo;
import org.jk.common.web.core.BaseController;
import org.jk.system.domain.DocumentAuditConfig;
import org.jk.system.domain.bo.DocumentAuditConfigBo;
import org.jk.system.service.IDocumentAuditConfigService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 审核配置Controller
 *
 * @author takai
 * @date 2025-06-03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/system/audit/config")
public class DocumentAuditConfigController extends BaseController
{
    private final IDocumentAuditConfigService documentAuditConfigService;

    /**
     * 查询审核配置列表
     */
    //@SaCheckPermission("system:auditconfig:list")
    @GetMapping("/list")
    public TableDataInfo list(DocumentAuditConfig documentAuditConfig, PageQuery pageQuery)
    {
        Page<DocumentAuditConfig> list = documentAuditConfigService.selectPageList(documentAuditConfig,pageQuery);
        return TableDataInfo.build(list);
    }

    /**
     * 导出审核配置列表
     */
    //@SaCheckPermission("system:auditconfig:export")
    @Log(title = "审核配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocumentAuditConfig documentAuditConfig)
    {
        List<DocumentAuditConfig> list = documentAuditConfigService.selectDocumentAuditConfigList(documentAuditConfig);
        ExcelUtil.exportExcel( list, "审核配置数据",DocumentAuditConfig.class,response);
    }

    /**
     * 获取审核配置详细信息
     */
    //@SaCheckPermission("system:auditconfig:query")
    @GetMapping(value = "/{id}")
    public R<DocumentAuditConfig> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(documentAuditConfigService.selectDocumentAuditConfigById(id));
    }

    /**
     * 新增审核配置
     */
    //@SaCheckPermission("system:auditconfig:add")
    @Log(title = "审核配置", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Integer> add(@RequestBody DocumentAuditConfig documentAuditConfig)
    {
        return R.ok(documentAuditConfigService.insertDocumentAuditConfig(documentAuditConfig));
    }

    /**
     * 修改审核配置
     */
    //@SaCheckPermission("system:auditconfig:edit")
    @Log(title = "审核配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Integer> edit(@RequestBody DocumentAuditConfig documentAuditConfig)
    {
        return R.ok(documentAuditConfigService.updateDocumentAuditConfig(documentAuditConfig));
    }

    /**
     * 删除审核配置
     */
    //@SaCheckPermission("system:auditconfig:remove")
    @Log(title = "审核配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable Long[] ids)
    {
        return R.ok(documentAuditConfigService.deleteDocumentAuditConfigByIds(ids));
    }

    @PostMapping("/allList")
    public TableDataInfo allList(@RequestBody DocumentAuditConfigBo documentAuditConfigBo,PageQuery pageQuery)
    {
        Page<DocumentAuditConfig> list = documentAuditConfigService.selectDocumentPageList(documentAuditConfigBo,pageQuery);
        return TableDataInfo.build(list);
    }
}
