package com.ruoyi.web.controller.common;


import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.IdCardVo;
import com.ruoyi.common.core.domain.SysUserIdcardVo;
import com.ruoyi.common.utils.IdCardUtil;
import com.ruoyi.system.domain.idcard.SysUserIdcard;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * @Author: tjf
 * @Date: 2024/4/22 14:24
 * @Describe:
 */
@RestController
@RequestMapping("/ocr")
public class OcrController {
    /**
     * 身份证识别
     *
     * @return
     */
    @PostMapping("/ocrIdCard")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult ocrIdCard(@RequestBody IdCardVo idCardVo) {
        return IdCardUtil.idCard(idCardVo.getImage(),idCardVo.getIdCardSide());
    }

    /**
     * 营业执照识别
     *
     * @return
     */
    @PostMapping("/ocrBusinessLicense")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult ocrBusinessLicense(@RequestBody IdCardVo idCardVo) {
        return IdCardUtil.businessLicense(idCardVo.getImage());
    }

    /**
     * 人脸识别百度V4版本
     *
     * @return
     */
    @PostMapping("/ocrSample")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult ocrSample(@RequestBody SysUserIdcardVo sysUserIdcardVo) {
        return IdCardUtil.sample(sysUserIdcardVo);
    }

    /**
     * 人脸识别阿里云金融级实人认证
     *
     * @return
     */
    @PostMapping("/ocrSampleAliYun")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult ocrSampleAliYun(@RequestBody SysUserIdcardVo sysUserIdcardVo) {
        return IdCardUtil.ocrSampleAliYun(sysUserIdcardVo);
    }

    /**
     * 手写识别
     *
     * @return
     */
    @PostMapping("/ocrHandWriting")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult ocrHandWriting(@RequestBody IdCardVo idCardVo) {
        return IdCardUtil.ocrHandWriting(idCardVo.getImage());
    }

}
