package com.heyu.api.controller.common;


import com.heyu.api.baidu.handle.common.BHandwritingHandle;
import com.heyu.api.baidu.request.common.AHandwritingRequest;
import com.heyu.api.baidu.response.common.AHandwritingResp;
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=1740295688238#/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%2Fhandwriting&method=post
 * <p>
 * 手写文字识别
 *
 * 接口描述
 * 支持对各类手写文字进行检测和识别，包括中、英、日、韩、法等 20+ 语言类型，可按单字维度输出置信度、候选字等信息。针对手写作文场景，支持涂改痕迹检测。
 *
 */
@Slf4j
@RestController
@RequestMapping("/handwriting")
@NotIntercept
public class HandwritingController {


    @Autowired
    private BHandwritingHandle aHandwritingHandle;


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

        ApiR<AHandwritingResp> apiR = aHandwritingHandle.handle(request);
        if (apiR.isSuccess()) {
            return R.ok().setData(apiR.getData());
        }


        return R.error(apiR.getErrorMsg());
    }


}
