package com.docus.server.controller;

import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.api.segmentation.OcrRuleTestApi;
import com.docus.server.dto.segmentation.ocrruletest.AddOcrRuleTestDTO;
import com.docus.server.dto.segmentation.ocrruletest.DeleteOcrRuleTestDTO;
import com.docus.server.dto.segmentation.ocrruletest.EditOcrRuleTestDTO;
import com.docus.server.entity.segmentation.OcrFileInfoTest;
import com.docus.server.service.IOcrRuleTestService;
import com.docus.server.service.handler.StartOcrTestHandler;
import com.docus.server.service.handler.StartSegmentTestHandler;
import com.docus.server.vo.segmentation.ocrruletest.OcrRuleTestVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 匹配策略表-调试 控制器类
 *
 * @author AutoGenerator
 * @since 2023-08-29
 */
@Api(value = "匹配策略表-调试", tags = "匹配策略表-调试")
@RestController
public class OcrRuleTestController implements OcrRuleTestApi {
    @Resource
    private IOcrRuleTestService iOcrRuleTestService;
    @Resource
    private StartSegmentTestHandler startSegmentTestHandler;


    @ApiOperation("开始分类ocr")
    @Override
    public List<OcrFileInfoTest> start(String id) {
       return startSegmentTestHandler.startSegment(id);
    }

    /**
     * 按主键查询
     *
     * @param id 主键Id
     * @return 实体
     */
    @ApiOperation("按主键查询")
    @Override
    public OcrRuleTestVO findById(Long id) {
        return iOcrRuleTestService.findById(id);
    }

    /**
     * 查询所有
     *
     * @return 实体
     */
    @ApiOperation("查询所有")
    @Override
    public List<OcrRuleTestVO> findAll() {
        return iOcrRuleTestService.findAll();
    }

    /**
     * 关键字搜索
     *
     * @param searchDTO 搜索参数
     * @return 分页列表
     */
    @ApiOperation("关键字搜索")
    @Override
    public PageResult<OcrRuleTestVO> search(SearchDTO searchDTO) {
        return iOcrRuleTestService.search(searchDTO);
    }

    /**
     * 新增
     *
     * @param addOcrRuleTestDTO 编辑参数
     */
    @ApiOperation("新增")
    @Override
    public void add(AddOcrRuleTestDTO addOcrRuleTestDTO) {
        iOcrRuleTestService.add(addOcrRuleTestDTO);
    }

    /**
     * 编辑
     *
     * @param editOcrRuleTestDTO 编辑参数
     */
    @ApiOperation("编辑")
    @Override
    public void edit(EditOcrRuleTestDTO editOcrRuleTestDTO) {
        iOcrRuleTestService.edit(editOcrRuleTestDTO);
    }

    @ApiOperation("批量更新规则")
    @Override
    public void deleteAndAdd(List<EditOcrRuleTestDTO> editOcrRuleTestDTOList) {
        iOcrRuleTestService.deleteAndAdd(editOcrRuleTestDTOList);
    }

    /**
     * 批量删除
     *
     * @param deleteOcrRuleTestDTO 删除参数
     * @return 成功或失败
     */
    @ApiOperation("批量删除")
    @Override
    public int delete(DeleteOcrRuleTestDTO deleteOcrRuleTestDTO) {
        return iOcrRuleTestService.delete(deleteOcrRuleTestDTO);
    }
}
