package com.heyu.api.baidu.handle.doc;


import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.doc.BRemoveHandwritingRequest;
import com.heyu.api.baidu.response.doc.BRemoveHandwritingResp;
import org.springframework.stereotype.Component;

/***
 * https://console.bce.baidu.com/support/?_=1740667714316&timestamp=1740670833444#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%96%87%E6%A1%A3%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86&api=%2Frest%2F2.0%2Focr%2Fv1%2Fremove_handwriting&method=post
 *
 * 文档去手写
 */
@Component
public class BRemoveHandwritingHandle extends BaiduBaseHandle<BRemoveHandwritingRequest, BRemoveHandwritingResp> {
    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/remove_handwriting";
    }

    @Override
    public String check(BRemoveHandwritingRequest bRemoveHandwritingRequest) {
        if (checkNotTrueFalse(bRemoveHandwritingRequest.getEnableDetect())) {
            return "enableDetect 必须为 " + trueOrFalse + ", 是否去除文件边缘后再识别,  true：去除，适用于有背景/边缘的拍摄件, false：不去除，适用于不含背景/边缘的扫描件 ";
        }

        return checkPdf(bRemoveHandwritingRequest);
    }

    @Override
    public String getContent(BRemoveHandwritingRequest bRemoveHandwritingRequest) {
        StringBuffer sb = getPdfContent(bRemoveHandwritingRequest);
        if (StringUtils.isNotBlank(bRemoveHandwritingRequest.getEnableDetect())) {
            sb.append("&enable_detect=" + bRemoveHandwritingRequest.getEnableDetect());
        }
        return sb.toString();
    }
}
