package com.heyu.api.controller.common;

import com.heyu.api.baidu.handle.common.BWebImageLocHandle;
import com.heyu.api.baidu.request.common.BWebImageLocRequest;
import com.heyu.api.baidu.response.common.BWebImageLocResp;
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;

@Slf4j
@RestController
@RequestMapping("/image/web/line")
@NotIntercept
public class WebImageLocLineController {

    @Autowired
    private BWebImageLocHandle bWebImageLocHandle;

    @RequestMapping("/recognize")
    @CacheResult
    public R recognize(BWebImageLocRequest request) {
        request.setRecognizeGranularity("big");
        ApiR<BWebImageLocResp> bR = bWebImageLocHandle.handle(request);
        if (bR.isSuccess()) {
            return R.ok().setData(bR.getData());
        }
        return R.error(bR.getErrorMsg());
    }
}
