package com.heyu.api.controller.common;


import com.heyu.api.baidu.handle.common.BNumbersHandle;
import com.heyu.api.baidu.request.common.ANumbersRequest;
import com.heyu.api.baidu.response.common.ANumbersResp;
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=1740299353970#/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%2Fnumbers&method=post
 * <p>
 * <p>
 * 数字识别
 */
@Slf4j
@RestController
@RequestMapping("/numbers")
@NotIntercept
public class NumbersController {

    @Autowired
    private BNumbersHandle bNumbersHandle;

    @RequestMapping("/recognize")
    @CacheResult
    public R recognize(ANumbersRequest request) {

        ApiR<ANumbersResp> bR = bNumbersHandle.handle(request);


        if (bR.isSuccess()) {
            return R.ok().setData(bR.getData());
        }
        return R.error(bR.getErrorMsg());

    }
}
