package com.heyu.api.alibaba.handle.objectdet;


import com.aliyun.objectdet20191230.models.DetectIPCObjectRequest;
import com.aliyun.objectdet20191230.models.DetectIPCObjectResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.objectdet.ADetectIPCObjectRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/objectdet/2019-12-30/DetectIPCObject?tab=DOC
 * <p>
 * IPC图像目标检测
 * <p>
 * DetectIPCObject
 */
@Component
@Slf4j
@CustomPath("detectIPCObject")
public class ADetectIPCObjectHandle extends AlibabaBaseHandle<ADetectIPCObjectRequest, DetectIPCObjectResponse> {


    @Autowired
    private com.aliyun.objectdet20191230.Client client;


    @Override
    public String check(ADetectIPCObjectRequest aDetectIPCObjectRequest) {
        return checkUrlBase64(aDetectIPCObjectRequest);
    }


    @Override
    public DetectIPCObjectResponse run(ADetectIPCObjectRequest aDetectIPCObjectRequest, RuntimeOptions runtime) throws Exception {
        DetectIPCObjectRequest detectIPCObjectRequest = new DetectIPCObjectRequest();
        detectIPCObjectRequest.setImageURL(aDetectIPCObjectRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.detectIPCObjectWithOptions(detectIPCObjectRequest, runtime);
    }
}
