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.DocumentAuditInfo;
import org.jk.system.service.IDocumentAuditInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author takai
 * @date 2025-05-29
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/system/info")
public class DocumentAuditInfoController extends BaseController
{
    private final IDocumentAuditInfoService documentAuditInfoService;

    /**
     * 查询【请填写功能名称】列表
     */
    //@SaCheckPermission("system:info:list")
    @GetMapping("/list")
    public TableDataInfo list(DocumentAuditInfo documentAuditInfo, PageQuery pageQuery)
    {
        Page<DocumentAuditInfo> list = documentAuditInfoService.selectPageList(documentAuditInfo,pageQuery);
        return TableDataInfo.build(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    //@SaCheckPermission("system:info:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocumentAuditInfo documentAuditInfo)
    {
        List<DocumentAuditInfo> list = documentAuditInfoService.selectDocumentAuditInfoList(documentAuditInfo);
        ExcelUtil.exportExcel( list, "【请填写功能名称】数据",DocumentAuditInfo.class,response);
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    //@SaCheckPermission("system:info:query")
    @GetMapping(value = "/{documentId}")
    public R<DocumentAuditInfo> getInfo(@PathVariable("documentId") String documentId)
    {
        return R.ok(documentAuditInfoService.selectDocumentAuditInfoByDocumentId(documentId));
    }

    /**
     * 新增【请填写功能名称】
     */
    //@SaCheckPermission("system:info:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Integer> add(@RequestBody DocumentAuditInfo documentAuditInfo)
    {
        return R.ok(documentAuditInfoService.insertDocumentAuditInfo(documentAuditInfo));
    }

    /**
     * 修改【请填写功能名称】
     */
    //@SaCheckPermission("system:info:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Integer> edit(@RequestBody DocumentAuditInfo documentAuditInfo)
    {
        return R.ok(documentAuditInfoService.updateDocumentAuditInfo(documentAuditInfo));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@SaCheckPermission("system:info:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentIds}")
    public R<Integer> remove(@PathVariable String[] documentIds)
    {
        return R.ok(documentAuditInfoService.deleteDocumentAuditInfoByDocumentIds(documentIds));
    }

    @GetMapping(value = "/all/{appId}")
    public R<List<DocumentAuditInfo>> getList(@PathVariable("appId") String appId)
    {
        DocumentAuditInfo documentAuditInfo = new DocumentAuditInfo();
        documentAuditInfo.setAppId(appId);
        List<DocumentAuditInfo> list = documentAuditInfoService.selectDocumentAuditInfoList(documentAuditInfo);
        return R.ok(list);
    }

}
