package com.heyu.api.controller.common;

import com.heyu.api.baidu.handle.common.BSealHandle;
import com.heyu.api.baidu.request.common.BSealRequest;
import com.heyu.api.baidu.response.common.BSealResp;
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;

@Slf4j
@RestController
@RequestMapping("/seal")
@NotIntercept
public class SealController extends BaseController {

    @Autowired
    private BSealHandle bSealHandle;

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