package com.heyu.api.controller.common;


import com.heyu.api.baidu.handle.common.BSmartStructHandle;
import com.heyu.api.baidu.request.common.ASmartStructRequest;
import com.heyu.api.baidu.response.common.ASmartStructResp;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740300649701#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E9%80%9A%E7%94%A8%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fsmart_struct&method=post
 * 智能结构化
 *
 * 接口描述
 * 支持智能提取图片中的字段结构化信息，无需训练灵活提取。适用于各类证照、票据、表单等版式中的结构化信息录入场景。
 *
 *
 */
@Slf4j
@RestController
@RequestMapping("/smartStruct")
@NotIntercept
public class SmartStructController extends BaseController {


    @Autowired
    private BSmartStructHandle bSmartStructHandle;


    @RequestMapping("/recognize")
    @CacheResult
    public R recognize(ASmartStructRequest request) {
        ApiR<ASmartStructResp> bR = bSmartStructHandle.handle(request);
        if (bR.isSuccess()) {
            return R.ok().setData(bR.getData());
        }
        return R.error(bR.getErrorMsg());
    }
}
