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


import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.convert.BExtractRequest;
import com.heyu.api.baidu.response.convert.BExtractResp;
import org.springframework.stereotype.Component;

/***
 *
 * https://console.bce.baidu.com/support/?_=1740703582749&timestamp=1740705642373#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv1%2Fextract%2Ftask&method=post
 *
 *
 * 文档抽取-提交请求
 */
@Component
public class BExtractHandle extends BaiduBaseHandle<BExtractRequest, BExtractResp> {
    @Override
    public String getUri() {
        return "/rest/2.0/brain/online/v1/extract/task";
    }

    @Override
    public String check(BExtractRequest bExtractRequest) {
        return null;
    }

    @Override
    public String getContent(BExtractRequest bExtractRequest) {
        StringBuffer sb = new StringBuffer();
        if (StringUtils.isNotBlank(bExtractRequest.getFile())) {
            sb.append("&file=").append(bExtractRequest.getFile());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getFileName())) {
            sb.append("&fileName=").append(bExtractRequest.getFileName());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getFileURLs())) {
            sb.append("&fileURLs=").append(bExtractRequest.getFileURLs());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getManifest())) {
            sb.append("&manifest=").append(bExtractRequest.getManifest());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getRemoveDuplicates())) {
            sb.append("&removeDuplicates=").append(bExtractRequest.getRemoveDuplicates());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getPageRange())) {
            sb.append("&pageRange=").append(bExtractRequest.getRemoveDuplicates());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getExtractSeal())) {
            sb.append("&extractSeal=").append(bExtractRequest.getExtractSeal());
        }
        if (StringUtils.isNotBlank(bExtractRequest.getEraseWatermark())) {
            sb.append("&eraseWatermark=").append(bExtractRequest.getEraseWatermark());
        }
        return sb.toString();
    }
}
