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.BDocCropEnhanceRequest;
import com.heyu.api.baidu.response.others.BDocCropEnhanceResp;
import org.springframework.stereotype.Component;

/***
 * https://console.bce.baidu.com/support/?_=1740667714316&timestamp=1740670330930#/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=rest%2F2.0%2Focr%2Fv1%2Fdoc_crop_enhance&method=post
 *文档矫正增强
 *
 *
 *
 */
@Component
public class BDocCropEnhanceHandle extends BaiduBaseHandle<BDocCropEnhanceRequest, BDocCropEnhanceResp> {


    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/doc_crop_enhance";
    }

    @Override
    public String check(BDocCropEnhanceRequest bDocCropEnhanceRequest) {
        return checkPdf(bDocCropEnhanceRequest);
    }

    @Override
    public String getContent(BDocCropEnhanceRequest bDocCropEnhanceRequest) {
        StringBuffer sb = getPdfContent(bDocCropEnhanceRequest);
        if (StringUtils.isNotBlank(bDocCropEnhanceRequest.getScanType())) {
            sb.append("&scan_type=" + bDocCropEnhanceRequest.getScanType());
        }
        if (StringUtils.isNotBlank(bDocCropEnhanceRequest.getPoints())) {
            sb.append("&points=" + bDocCropEnhanceRequest.getPoints());
        }
        if (StringUtils.isNotBlank(bDocCropEnhanceRequest.getEnhanceType())) {
            sb.append("&enhance_type=" + bDocCropEnhanceRequest.getEnhanceType());
        }
        return sb.toString();
    }
}
