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


import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.financial.BBankReceiptNewRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * https://console.bce.baidu.com/support/?_=1740575657628&timestamp=1740575720695#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E8%B4%A2%E5%8A%A1%E7%A5%A8%E6%8D%AEOCR&api=rest%2F2.0%2Focr%2Fv1%2Fbank_receipt_new&method=post
 * <p>
 * <p>
 * 银行回单识别
 */
@Component
@Slf4j
@CustomPath("bankReceiptNew")
public class BBankReceiptNewHandle extends BaiduBaseHandle<BBankReceiptNewRequest, Map> {
    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/bank_receipt_new";
    }

    @Override
    public String check(BBankReceiptNewRequest bBankReceiptNewRequest) {
        if (checkNotTrueFalse(bBankReceiptNewRequest.getProbability())) {
            return "probability 必须为" + trueOrFalse + ", 是否返回字段置信度";
        }
        if (checkNotTrueFalse(bBankReceiptNewRequest.getLocation())) {
            return "location 必须为" + trueOrFalse + ",是否返回字段位置坐标 ";
        }
        return checkOfd(bBankReceiptNewRequest);
    }

    @Override
    public String getContent(BBankReceiptNewRequest bBankReceiptNewRequest) {
        StringBuffer sb = getOfdContent(bBankReceiptNewRequest);
        if (StringUtils.isNotBlank(bBankReceiptNewRequest.getProbability())) {
            sb.append("&probability=" + bBankReceiptNewRequest.getProbability());
        }
        if (StringUtils.isNotBlank(bBankReceiptNewRequest.getLocation())) {
            sb.append("&location=" + bBankReceiptNewRequest.getLocation());
        }
        return sb.toString();
    }
}
